Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2543 by niro, Wed Sep 16 10:31:57 2015 UTC revision 2565 by niro, Thu Sep 17 09:41:26 2015 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    push_config idesk_icon
4    
5  # control_input_keymap $serial  # control_input_keymap $serial
6  control_input_keymap()  control_input_keymap()
7  {  {
# Line 55  set_idesk_icon() Line 57  set_idesk_icon()
57   local ypos   local ypos
58   local width   local width
59   local height   local height
60   local ids   local id
61     local enabled
62    
63   [[ -z ${action} ]] && help_idesk_icon && return 1   [[ -z ${action} ]] && help_idesk_icon && return 1
64    
# Line 71  set_idesk_icon() Line 74  set_idesk_icon()
74   height="${widthheight#*,}"   height="${widthheight#*,}"
75   fi   fi
76    
  local id  
   
77   case "${action}" in   case "${action}" in
78   add)   add) enabled=1 ;;
79   id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';")   del) enabled=0 ;;
80   if [[ -n ${id} ]]   *)
81   then   eecho "Unknown action '${action}'"
82   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  
83   ;;   ;;
84   esac   esac
85    
86     id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';")
87     if [[ -n ${id} ]]
88     then
89     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};"
90     else
91     mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled)
92     values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');"
93     fi
94  }  }
95    
96  control_idesk_icon()  control_idesk_icon()
97  {  {
98   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
99     push_config_idesk_icon "${serial}"
100    }
101    
102    push_config_idesk_icon()
103    {
104     local serial="$1"
105   local values   local values
106   local id   local id
107     local xypos
108     local widthheight
109    
  # first delete all icons then regen all  
  control_client "${serial}" set idesk.icon del  
110   values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")   values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")
111   for id in ${values}   for id in ${values}
112   do   do
# Line 112  control_idesk_icon() Line 116  control_idesk_icon()
116   eecho "Name must not be empty id->'${id}'"   eecho "Name must not be empty id->'${id}'"
117   continue   continue
118   fi   fi
119   if [[ -z ${cfg_idesk_icon_command} ]]   if [[ -z ${cfg_idesk_icon_enabled} ]]
120   then   then
121   eecho "Command must not be empty id->'${id}'"   eecho "Enabled must not be empty id->'${id}'"
122   continue   continue
123   fi   fi
124   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 [[ ${cfg_idesk_icon_enabled} = 1 ]]
125     then
126     if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]]
127     then
128     xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}"
129     fi
130     if [[ -n ${width} ]] && [[ -n ${height} ]]
131     then
132     widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}"
133     fi
134     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}"
135     elif [[ ${cfg_idesk_icon_enabled} = 0 ]]
136     then
137     control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}"
138     # remove from database too
139     mysqldo "delete from cfg_idesk_icon where id='${id}';"
140     else
141     eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'"
142     return 1
143     fi
144   done   done
145  }  }

Legend:
Removed from v.2543  
changed lines
  Added in v.2565