Annotation of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in
Parent Directory | Revision Log
Revision 2885 -
(hide annotations)
(download)
Fri Aug 14 11:39:10 2020 UTC (3 years, 8 months ago) by niro
File size: 3119 byte(s)
Fri Aug 14 11:39:10 2020 UTC (3 years, 8 months ago) by niro
File size: 3119 byte(s)
-encapsulate all argument variables to control_client() to evaluate them properly later on
1 | niro | 2543 | # $Id$ |
2 | |||
3 | niro | 2577 | push_config 80_idesk_icon |
4 | niro | 2565 | |
5 | niro | 2543 | help_idesk_icon() |
6 | { | ||
7 | local serial="${CLASS_ARGV[0]}" | ||
8 | control_client "${serial}" help idesk.icon | ||
9 | } | ||
10 | |||
11 | set_idesk_icon() | ||
12 | { | ||
13 | local serial="${CLASS_ARGV[0]}" | ||
14 | local action="${CLASS_ARGV[1]}" | ||
15 | local name="${CLASS_ARGV[2]}" | ||
16 | local command="${CLASS_ARGV[3]}" | ||
17 | local icon="${CLASS_ARGV[4]}" | ||
18 | local filename="${CLASS_ARGV[5]}" | ||
19 | local xypos="${CLASS_ARGV[6]}" | ||
20 | local widthheight="${CLASS_ARGV[7]}" | ||
21 | local default_icon="${CLASS_ARGV[8]}" | ||
22 | local xpos | ||
23 | local ypos | ||
24 | local width | ||
25 | local height | ||
26 | niro | 2544 | local id |
27 | local enabled | ||
28 | niro | 2543 | |
29 | [[ -z ${action} ]] && help_idesk_icon && return 1 | ||
30 | |||
31 | if [[ -n ${xypos} ]] | ||
32 | then | ||
33 | xpos="${xypos%,*}" | ||
34 | ypos="${xypos#*,}" | ||
35 | fi | ||
36 | |||
37 | if [[ -n ${widthheight} ]] | ||
38 | then | ||
39 | width="${widthheight%,*}" | ||
40 | height="${widthheight#*,}" | ||
41 | fi | ||
42 | |||
43 | case "${action}" in | ||
44 | niro | 2544 | add) enabled=1 ;; |
45 | del) enabled=0 ;; | ||
46 | *) | ||
47 | eecho "Unknown action '${action}'" | ||
48 | return 1 | ||
49 | niro | 2543 | ;; |
50 | esac | ||
51 | niro | 2544 | |
52 | niro | 2566 | if [[ -z ${name} ]] |
53 | then | ||
54 | eecho "No name given" | ||
55 | return 1 | ||
56 | fi | ||
57 | |||
58 | niro | 2544 | id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") |
59 | if [[ -n ${id} ]] | ||
60 | then | ||
61 | 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};" | ||
62 | else | ||
63 | mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled) | ||
64 | values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');" | ||
65 | fi | ||
66 | niro | 2543 | } |
67 | |||
68 | control_idesk_icon() | ||
69 | { | ||
70 | local serial="${CLASS_ARGV[0]}" | ||
71 | niro | 2577 | push_config_80_idesk_icon "${serial}" |
72 | niro | 2565 | } |
73 | |||
74 | niro | 2577 | push_config_80_idesk_icon() |
75 | niro | 2565 | { |
76 | local serial="$1" | ||
77 | niro | 2543 | local values |
78 | local id | ||
79 | niro | 2550 | local xypos |
80 | local widthheight | ||
81 | niro | 2543 | |
82 | values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") | ||
83 | for id in ${values} | ||
84 | do | ||
85 | niro | 2874 | evaluate_table_xml cfg_idesk_icon "where id='${id}'" |
86 | niro | 2543 | if [[ -z ${cfg_idesk_icon_name} ]] |
87 | then | ||
88 | eecho "Name must not be empty id->'${id}'" | ||
89 | continue | ||
90 | fi | ||
91 | niro | 2544 | if [[ -z ${cfg_idesk_icon_enabled} ]] |
92 | then | ||
93 | eecho "Enabled must not be empty id->'${id}'" | ||
94 | continue | ||
95 | fi | ||
96 | if [[ ${cfg_idesk_icon_enabled} = 1 ]] | ||
97 | then | ||
98 | niro | 2550 | if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]] |
99 | then | ||
100 | xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" | ||
101 | fi | ||
102 | if [[ -n ${width} ]] && [[ -n ${height} ]] | ||
103 | then | ||
104 | widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}" | ||
105 | fi | ||
106 | niro | 2885 | 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}\"" |
107 | niro | 2544 | elif [[ ${cfg_idesk_icon_enabled} = 0 ]] |
108 | niro | 2547 | then |
109 | niro | 2885 | control_client "${serial}" set idesk.icon del "\"${cfg_idesk_icon_name}\"" |
110 | niro | 2544 | # remove from database too |
111 | mysqldo "delete from cfg_idesk_icon where id='${id}';" | ||
112 | else | ||
113 | eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'" | ||
114 | return 1 | ||
115 | niro | 2546 | fi |
116 | niro | 2543 | done |
117 | } |