Annotation of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in
Parent Directory | Revision Log
Revision 2566 -
(hide annotations)
(download)
Thu Sep 17 10:09:32 2015 UTC (8 years, 7 months ago) by niro
File size: 4275 byte(s)
Thu Sep 17 10:09:32 2015 UTC (8 years, 7 months ago) by niro
File size: 4275 byte(s)
-name must not be empty
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 | niro | 2566 | if [[ -z ${name} ]] |
87 | then | ||
88 | eecho "No name given" | ||
89 | return 1 | ||
90 | fi | ||
91 | |||
92 | niro | 2544 | id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") |
93 | if [[ -n ${id} ]] | ||
94 | then | ||
95 | 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};" | ||
96 | else | ||
97 | mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled) | ||
98 | values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');" | ||
99 | fi | ||
100 | niro | 2543 | } |
101 | |||
102 | control_idesk_icon() | ||
103 | { | ||
104 | local serial="${CLASS_ARGV[0]}" | ||
105 | niro | 2565 | push_config_idesk_icon "${serial}" |
106 | } | ||
107 | |||
108 | push_config_idesk_icon() | ||
109 | { | ||
110 | local serial="$1" | ||
111 | niro | 2543 | local values |
112 | local id | ||
113 | niro | 2550 | local xypos |
114 | local widthheight | ||
115 | niro | 2543 | |
116 | values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") | ||
117 | for id in ${values} | ||
118 | do | ||
119 | evaluate_table_xml cfg_idesk_icon "where serial='${serial}'" | ||
120 | if [[ -z ${cfg_idesk_icon_name} ]] | ||
121 | then | ||
122 | eecho "Name must not be empty id->'${id}'" | ||
123 | continue | ||
124 | fi | ||
125 | niro | 2544 | if [[ -z ${cfg_idesk_icon_enabled} ]] |
126 | then | ||
127 | eecho "Enabled must not be empty id->'${id}'" | ||
128 | continue | ||
129 | fi | ||
130 | if [[ ${cfg_idesk_icon_enabled} = 1 ]] | ||
131 | then | ||
132 | niro | 2550 | if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]] |
133 | then | ||
134 | xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" | ||
135 | fi | ||
136 | if [[ -n ${width} ]] && [[ -n ${height} ]] | ||
137 | then | ||
138 | widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}" | ||
139 | fi | ||
140 | 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}" | ||
141 | niro | 2544 | elif [[ ${cfg_idesk_icon_enabled} = 0 ]] |
142 | niro | 2547 | then |
143 | niro | 2544 | control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}" |
144 | # remove from database too | ||
145 | mysqldo "delete from cfg_idesk_icon where id='${id}';" | ||
146 | else | ||
147 | eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'" | ||
148 | return 1 | ||
149 | niro | 2546 | fi |
150 | niro | 2543 | done |
151 | } |