Annotation of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in
Parent Directory | Revision Log
Revision 2565 -
(hide annotations)
(download)
Thu Sep 17 09:41:26 2015 UTC (8 years, 7 months ago) by niro
File size: 4208 byte(s)
Thu Sep 17 09:41:26 2015 UTC (8 years, 7 months ago) by niro
File size: 4208 byte(s)
-push_config support
1 | niro | 2543 | # $Id$ |
2 | |||
3 | niro | 2565 | push_config idesk_icon |
4 | |||
5 | niro | 2543 | # control_input_keymap $serial |
6 | control_input_keymap() | ||
7 | { | ||
8 | local serial="${CLASS_ARGV[0]}" | ||
9 | push_config_input_keymap "${serial}" | ||
10 | } | ||
11 | |||
12 | push_config_input_keymap() | ||
13 | { | ||
14 | local serial="$1" | ||
15 | local value | ||
16 | |||
17 | value=$(mysqldo "select keymap from cfg_input where serial='${serial}'") | ||
18 | control_client "${serial}" set input.keymap "${value}" | ||
19 | } | ||
20 | |||
21 | help_idesk_icon() | ||
22 | { | ||
23 | local serial="${CLASS_ARGV[0]}" | ||
24 | control_client "${serial}" help idesk.icon | ||
25 | |||
26 | mecho "get idesk.icon" | ||
27 | mecho " Shows all configured icons." | ||
28 | mecho | ||
29 | mecho "set idesk.icon [action] [name] [command] [icon] [filename] [x,y] [width,height] [default-icon]" | ||
30 | mecho " Adds or deletes an desktop icon." | ||
31 | mecho " [actions]:" | ||
32 | mecho " add - adds an icon" | ||
33 | mecho " del - deletes an icon" | ||
34 | mecho " if no [name] given, all desktop icons will be deleted" | ||
35 | mecho | ||
36 | mecho " name - Name of the icon" | ||
37 | mecho " command - command which will be run" | ||
38 | mecho " icon - icon pixmap [optional]" | ||
39 | mecho " filename - filename of the icon [optional]" | ||
40 | mecho " x,y - x,y position of the icon on the desktop [optional]" | ||
41 | mecho " width,height - width and height of the icon [optional]" | ||
42 | mecho " default-icon - default icon which will be selected if the icon pixmap was not found [optional]" | ||
43 | } | ||
44 | |||
45 | set_idesk_icon() | ||
46 | { | ||
47 | local serial="${CLASS_ARGV[0]}" | ||
48 | local action="${CLASS_ARGV[1]}" | ||
49 | local name="${CLASS_ARGV[2]}" | ||
50 | local command="${CLASS_ARGV[3]}" | ||
51 | local icon="${CLASS_ARGV[4]}" | ||
52 | local filename="${CLASS_ARGV[5]}" | ||
53 | local xypos="${CLASS_ARGV[6]}" | ||
54 | local widthheight="${CLASS_ARGV[7]}" | ||
55 | local default_icon="${CLASS_ARGV[8]}" | ||
56 | local xpos | ||
57 | local ypos | ||
58 | local width | ||
59 | local height | ||
60 | niro | 2544 | local id |
61 | local enabled | ||
62 | niro | 2543 | |
63 | [[ -z ${action} ]] && help_idesk_icon && return 1 | ||
64 | |||
65 | if [[ -n ${xypos} ]] | ||
66 | then | ||
67 | xpos="${xypos%,*}" | ||
68 | ypos="${xypos#*,}" | ||
69 | fi | ||
70 | |||
71 | if [[ -n ${widthheight} ]] | ||
72 | then | ||
73 | width="${widthheight%,*}" | ||
74 | height="${widthheight#*,}" | ||
75 | fi | ||
76 | |||
77 | case "${action}" in | ||
78 | niro | 2544 | add) enabled=1 ;; |
79 | del) enabled=0 ;; | ||
80 | *) | ||
81 | eecho "Unknown action '${action}'" | ||
82 | return 1 | ||
83 | niro | 2543 | ;; |
84 | esac | ||
85 | niro | 2544 | |
86 | id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") | ||
87 | if [[ -n ${id} ]] | ||
88 | then | ||
89 | mysqldo "update cfg_idesk_icon set name='${name}', command='${command}', icon='${icon}', filename='${filename}', xpos='${xpos}', ypos='${ypos}', width='${width}', height='${height}', default_icon='${default_icon}', enabled='${enabled}' where id=${id};" | ||
90 | else | ||
91 | mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled) | ||
92 | values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');" | ||
93 | fi | ||
94 | niro | 2543 | } |
95 | |||
96 | control_idesk_icon() | ||
97 | { | ||
98 | local serial="${CLASS_ARGV[0]}" | ||
99 | niro | 2565 | push_config_idesk_icon "${serial}" |
100 | } | ||
101 | |||
102 | push_config_idesk_icon() | ||
103 | { | ||
104 | local serial="$1" | ||
105 | niro | 2543 | local values |
106 | local id | ||
107 | niro | 2550 | local xypos |
108 | local widthheight | ||
109 | niro | 2543 | |
110 | values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") | ||
111 | for id in ${values} | ||
112 | do | ||
113 | evaluate_table_xml cfg_idesk_icon "where serial='${serial}'" | ||
114 | if [[ -z ${cfg_idesk_icon_name} ]] | ||
115 | then | ||
116 | eecho "Name must not be empty id->'${id}'" | ||
117 | continue | ||
118 | fi | ||
119 | niro | 2544 | if [[ -z ${cfg_idesk_icon_enabled} ]] |
120 | then | ||
121 | eecho "Enabled must not be empty id->'${id}'" | ||
122 | continue | ||
123 | fi | ||
124 | if [[ ${cfg_idesk_icon_enabled} = 1 ]] | ||
125 | then | ||
126 | niro | 2550 | if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]] |
127 | then | ||
128 | xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" | ||
129 | fi | ||
130 | if [[ -n ${width} ]] && [[ -n ${height} ]] | ||
131 | then | ||
132 | widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}" | ||
133 | fi | ||
134 | control_client "${serial}" set idesk.icon add "${cfg_idesk_icon_name}" "${cfg_idesk_icon_command}" "${cfg_idesk_icon_icon}" "${cfg_idesk_icon_filename}" "${xypos}" "${widthheight}" "${cfg_idesk_icon_default_icon}" | ||
135 | niro | 2544 | elif [[ ${cfg_idesk_icon_enabled} = 0 ]] |
136 | niro | 2547 | then |
137 | niro | 2544 | control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}" |
138 | # remove from database too | ||
139 | mysqldo "delete from cfg_idesk_icon where id='${id}';" | ||
140 | else | ||
141 | eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'" | ||
142 | return 1 | ||
143 | niro | 2546 | fi |
144 | niro | 2543 | done |
145 | } |