Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/citrix.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2179 - (hide annotations) (download)
Fri Jan 10 14:17:06 2014 UTC (10 years, 4 months ago) by niro
File size: 5254 byte(s)
-moved daemon/client/include/citrix.client.class to src/modules/citrix/citrix.client.class.in
1 niro 1266 # $Id$
2    
3     provide citrix ica
4    
5     # needs fluxbox!
6     require fluxbox basic-video
7    
8     help_citrix_serverlist()
9     {
10     mecho "get citrix.serverlist"
11     mecho " Shows all hosts added on the serverlist."
12     mecho
13     mecho "set citrix.serverlist [action] [host]"
14     mecho " Adds or deletes a server from the ica serverlist."
15     mecho " [actions]:"
16     mecho " add - adds a server"
17     mecho " del - deletes a server"
18     mecho
19     mecho " host - dns hostname or ip of the server"
20     mecho
21     mecho " If no [host] was given, all entries are deleted."
22     }
23    
24     help_citrix_session()
25     {
26     mecho "get citrix.session"
27     mecho " Shows all configured ICA sessions"
28     mecho
29 niro 2038 mecho "set citrix.session [action] [name] [session] [mode] [user] [domain] [password]"
30 niro 1266 mecho " Adds or delets a ICA session."
31     mecho " Available actions:"
32     mecho " add - adds a new ica session"
33     mecho " del - deletes ica session with file name [file]"
34     mecho " if no [file] given, all sessions will be deleted"
35     mecho
36     mecho " Available modes:"
37     mecho " fullscreen - fullscreen session"
38     mecho " seamless - seamless windows session"
39     mecho " *x* - windowed session with given resolution"
40     mecho " any resonable resolution is fine like:"
41     mecho " 1024x768, 1280x1024, 1440x900 etc"
42     mecho
43     mecho " session - name of the Citrix session"
44     mecho " user - user inside the session - optional"
45     mecho " domain - logon domain of the user - optional"
46     mecho " password - password of the user - optional"
47     }
48    
49     set_citrix_session()
50     {
51     local action="$1"
52 niro 2038 local name="$2"
53     local session="$3"
54     local mode="$4"
55     local user="$5"
56     local domain="$6"
57     local password="$7"
58 niro 1266 local serverlist
59     local server
60     local server_num
61 niro 2021 local icafile
62 niro 1266 local CONFIG
63     local i
64    
65     [[ -z ${action} ]] && help_citrix_session && return 1
66 niro 2038 [[ -z ${name} ]] && help_citrix_session && return 1
67 niro 1266
68     case "${action}" in
69     add)
70     # action 'add' need mode too
71     [[ -z ${mode} ]] && help_citrix_session && return 1
72 niro 2038 # and session
73     [[ -z ${session} ]] && help_citrix_session && return 1
74 niro 1266
75     # other sanity checks
76     case "${mode}" in
77     fullscreen) ;;
78     seamless) ;;
79     *x*) ;;
80     *) help_citrix_session && return 1
81     esac
82    
83 niro 2038 icafile="${MCORE_CONFIG_PATH}/citrix/ica/${name}.ica"
84 niro 2021 CONFIG="${MROOT}/${icafile}"
85 niro 1266 clearconfig
86    
87     addconfig '[WFClient]'
88     addconfig 'Version=2'
89    
90     serverlist=$(NOCOLORS=true get_citrix_serverlist)
91     declare -i i=0
92     for server in ${serverlist}
93     do
94     (( i++ ))
95     server_num="${i}"
96     [[ ${i} -eq 1 ]] && server_num=""
97     addconfig "TcpBrowserAddress${server_num}=${server}"
98     done
99     addconfig 'ScreenPercent=0'
100     addconfig '[ApplicationServers]'
101     addconfig "${session}="
102     addconfig "[${session}]"
103     addconfig "Address=${session}"
104     addconfig "InitialProgram=#${session}"
105    
106     # mapping table xorg -> citrix
107     # citrix 1 = 16 colors
108     # citrix 2 = 256 colors
109     # citrix 4 = 16 bit
110     # citrix 8 = 32 bit
111     # try always 16 bit
112     addconfig "DesiredColor=4"
113    
114     addconfig 'TransportDriver=TCP/IP'
115     addconfig 'WinStationDriver=ICA 3.0'
116    
117     [[ -n ${user} ]] && addconfig "Username=${user}"
118     [[ -n ${domain} ]] && addconfig "Domain=${domain}"
119     [[ -n ${password} ]] && addconfig "ClearPassword=${password}"
120    
121     # use the right display settings
122     case "${mode}" in
123     # fullscreen mode
124     fullscreen)
125     addconfig 'UseFullScreen=Yes'
126     addconfig 'NoWindowManager=True'
127     addconfig "DesiredHRES=65535"
128     addconfig "DesiredVRES=65535"
129     ;;
130     # seamless window mode
131     seamless)
132     addconfig 'TWIMode=On'
133     ;;
134     # a desired resolution
135     *x*)
136     addconfig "DesiredHRES=${mode%x*}"
137     addconfig "DesiredVRES=${mode#*x}"
138     ;;
139     esac
140    
141     # generate fluxbox menu entry
142 niro 2038 set_fluxbox_menuitem add "${name}" "wfica ${icafile}"
143 niro 1266 ;;
144    
145     del)
146 niro 2038 if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica ]
147 niro 1266 then
148 niro 2038 rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica
149     set_fluxbox_menuitem del "${name}"
150 niro 1266
151     elif [[ -z ${file} ]]
152     then
153     # delete all items, needed to loop through every session
154     # or we delete *all* fluxbox menuitem too
155 niro 2023 for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica -type f)
156 niro 1266 do
157     rm ${i}
158     set_fluxbox_menuitem del "$(basename ${i} .ica)"
159     done
160     fi
161     ;;
162    
163     *) help_citrix_session && return 1 ;;
164     esac
165     }
166    
167     get_citrix_session()
168     {
169 niro 2022 list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica
170 niro 1266 }
171    
172     set_citrix_serverlist()
173     {
174     local action="$1"
175     local server="$2"
176     local CONFIG
177    
178     [[ -z ${action} ]] && help_citrix_serverlist && return 1
179    
180     case "${action}" in
181     add)
182     [[ -z ${server} ]] && help_citrix_serverlist && return 1
183 niro 2021 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server}"
184 niro 1266 clearconfig
185     addconfig "${server}"
186     ;;
187    
188     del)
189 niro 2021 if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server} ]]
190 niro 1266 then
191 niro 2021 rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/"${server}"
192 niro 1266 elif [[ -z ${server} ]]
193     then
194     # delete all items
195 niro 2023 find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist -type f | xargs --no-run-if-empty rm
196 niro 1266 fi
197     ;;
198    
199     *) help_citrix_serverlist && return 1 ;;
200     esac
201     }
202    
203     get_citrix_serverlist()
204     {
205 niro 2022 list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist
206 niro 1266 }