55 |
local ypos |
local ypos |
56 |
local width |
local width |
57 |
local height |
local height |
58 |
local ids |
local id |
59 |
|
local enabled |
60 |
|
|
61 |
[[ -z ${action} ]] && help_idesk_icon && return 1 |
[[ -z ${action} ]] && help_idesk_icon && return 1 |
62 |
|
|
72 |
height="${widthheight#*,}" |
height="${widthheight#*,}" |
73 |
fi |
fi |
74 |
|
|
|
local id |
|
|
|
|
75 |
case "${action}" in |
case "${action}" in |
76 |
add) |
add) enabled=1 ;; |
77 |
id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") |
del) enabled=0 ;; |
78 |
if [[ -n ${id} ]] |
*) |
79 |
then |
eecho "Unknown action '${action}'" |
80 |
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};" |
return 1 |
|
else |
|
|
mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon) |
|
|
values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}');" |
|
|
fi |
|
|
;; |
|
|
del) |
|
|
if [[ -n ${name} ]] |
|
|
then |
|
|
mysqldo "delete from cfg_idesk_icon where serial='${serial}' and name='${name}';" |
|
|
else |
|
|
mysqldo "delete from cfg_idesk_icon where serial='${serial}';" |
|
|
fi |
|
81 |
;; |
;; |
82 |
esac |
esac |
83 |
|
|
84 |
|
id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") |
85 |
|
if [[ -n ${id} ]] |
86 |
|
then |
87 |
|
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};" |
88 |
|
else |
89 |
|
mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled) |
90 |
|
values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');" |
91 |
|
fi |
92 |
} |
} |
93 |
|
|
94 |
control_idesk_icon() |
control_idesk_icon() |
97 |
local values |
local values |
98 |
local id |
local id |
99 |
|
|
|
# first delete all icons then regen all |
|
|
control_client "${serial}" set idesk.icon del |
|
100 |
values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") |
values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") |
101 |
for id in ${values} |
for id in ${values} |
102 |
do |
do |
111 |
eecho "Command must not be empty id->'${id}'" |
eecho "Command must not be empty id->'${id}'" |
112 |
continue |
continue |
113 |
fi |
fi |
114 |
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}" |
if [[ -z ${cfg_idesk_icon_enabled} ]] |
115 |
|
then |
116 |
|
eecho "Enabled must not be empty id->'${id}'" |
117 |
|
continue |
118 |
|
fi |
119 |
|
if [[ ${cfg_idesk_icon_enabled} = 1 ]] |
120 |
|
then |
121 |
|
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}" |
122 |
|
elif [[ ${cfg_idesk_icon_enabled} = 0 ]] |
123 |
|
control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}" |
124 |
|
# remove from database too |
125 |
|
mysqldo "delete from cfg_idesk_icon where id='${id}';" |
126 |
|
else |
127 |
|
eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'" |
128 |
|
return 1 |
129 |
done |
done |
130 |
} |
} |