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 2566 by niro, Thu Sep 17 10:09:32 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     if [[ -z ${name} ]]
87     then
88     eecho "No name given"
89     return 1
90     fi
91    
92     id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';")
93     if [[ -n ${id} ]]
94     then
95     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};"
96     else
97     mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled)
98     values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');"
99     fi
100  }  }
101    
102  control_idesk_icon()  control_idesk_icon()
103  {  {
104   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
105     push_config_idesk_icon "${serial}"
106    }
107    
108    push_config_idesk_icon()
109    {
110     local serial="$1"
111   local values   local values
112   local id   local id
113     local xypos
114     local widthheight
115    
  # first delete all icons then regen all  
  control_client "${serial}" set idesk.icon del  
116   values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")   values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")
117   for id in ${values}   for id in ${values}
118   do   do
# Line 112  control_idesk_icon() Line 122  control_idesk_icon()
122   eecho "Name must not be empty id->'${id}'"   eecho "Name must not be empty id->'${id}'"
123   continue   continue
124   fi   fi
125   if [[ -z ${cfg_idesk_icon_command} ]]   if [[ -z ${cfg_idesk_icon_enabled} ]]
126   then   then
127   eecho "Command must not be empty id->'${id}'"   eecho "Enabled must not be empty id->'${id}'"
128   continue   continue
129   fi   fi
130   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 ]]
131     then
132     if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]]
133     then
134     xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}"
135     fi
136     if [[ -n ${width} ]] && [[ -n ${height} ]]
137     then
138     widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}"
139     fi
140     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}"
141     elif [[ ${cfg_idesk_icon_enabled} = 0 ]]
142     then
143     control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}"
144     # remove from database too
145     mysqldo "delete from cfg_idesk_icon where id='${id}';"
146     else
147     eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'"
148     return 1
149     fi
150   done   done
151  }  }

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