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