# $Id$ push_config 80_idesk_icon help_idesk_icon() { local serial="${CLASS_ARGV[0]}" control_client "${serial}" help idesk.icon } set_idesk_icon() { local serial="${CLASS_ARGV[0]}" local action="${CLASS_ARGV[1]}" local name="${CLASS_ARGV[2]}" local command="${CLASS_ARGV[3]}" local icon="${CLASS_ARGV[4]}" local filename="${CLASS_ARGV[5]}" local xypos="${CLASS_ARGV[6]}" local widthheight="${CLASS_ARGV[7]}" local default_icon="${CLASS_ARGV[8]}" local xpos local ypos local width local height local id local enabled [[ -z ${action} ]] && help_idesk_icon && return 1 if [[ -n ${xypos} ]] then xpos="${xypos%,*}" ypos="${xypos#*,}" fi if [[ -n ${widthheight} ]] then width="${widthheight%,*}" height="${widthheight#*,}" fi case "${action}" in add) enabled=1 ;; del) enabled=0 ;; *) eecho "Unknown action '${action}'" return 1 ;; esac if [[ -z ${name} ]] then eecho "No name given" return 1 fi id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") if [[ -n ${id} ]] then 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};" else mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled) values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');" fi } control_idesk_icon() { local serial="${CLASS_ARGV[0]}" push_config_80_idesk_icon "${serial}" } push_config_80_idesk_icon() { local serial="$1" local values local id local xypos local widthheight values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") for id in ${values} do evaluate_table_xml cfg_idesk_icon "where serial='${serial}'" if [[ -z ${cfg_idesk_icon_name} ]] then eecho "Name must not be empty id->'${id}'" continue fi if [[ -z ${cfg_idesk_icon_enabled} ]] then eecho "Enabled must not be empty id->'${id}'" continue fi if [[ ${cfg_idesk_icon_enabled} = 1 ]] then if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]] then xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" fi if [[ -n ${width} ]] && [[ -n ${height} ]] then widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}" fi 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}" elif [[ ${cfg_idesk_icon_enabled} = 0 ]] then control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}" # remove from database too mysqldo "delete from cfg_idesk_icon where id='${id}';" else eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'" return 1 fi done }