Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/daemon/client/include/citrix.client.class

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1641 - (show annotations) (download)
Thu Mar 10 18:11:32 2011 UTC (13 years, 1 month ago) by niro
File size: 5169 byte(s)
-use rvecho() for function retvals
1 # $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 mecho "set citrix.session [action] [session] [mode] [user] [domain] [password]"
30 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 local session="$2"
53 local mode="$3"
54 local user="$4"
55 local domain="$5"
56 local password="$6"
57 local serverlist
58 local server
59 local server_num
60 local CONFIG
61 local i
62
63 [[ -z ${action} ]] && help_citrix_session && return 1
64 [[ -z ${session} ]] && help_citrix_session && return 1
65
66 case "${action}" in
67 add)
68 # action 'add' need mode too
69 [[ -z ${mode} ]] && help_citrix_session && return 1
70
71 # other sanity checks
72 case "${mode}" in
73 fullscreen) ;;
74 seamless) ;;
75 *x*) ;;
76 *) help_citrix_session && return 1
77 esac
78
79 CONFIG="${MCORE_CONFIG_PATH}/citrix/ica/${session}.ica"
80 clearconfig
81
82 addconfig '[WFClient]'
83 addconfig 'Version=2'
84
85 serverlist=$(NOCOLORS=true get_citrix_serverlist)
86 declare -i i=0
87 for server in ${serverlist}
88 do
89 (( i++ ))
90 server_num="${i}"
91 [[ ${i} -eq 1 ]] && server_num=""
92 addconfig "TcpBrowserAddress${server_num}=${server}"
93 done
94 addconfig 'ScreenPercent=0'
95 addconfig '[ApplicationServers]'
96 addconfig "${session}="
97 addconfig "[${session}]"
98 addconfig "Address=${session}"
99 addconfig "InitialProgram=#${session}"
100
101 # mapping table xorg -> citrix
102 # citrix 1 = 16 colors
103 # citrix 2 = 256 colors
104 # citrix 4 = 16 bit
105 # citrix 8 = 32 bit
106 # try always 16 bit
107 addconfig "DesiredColor=4"
108
109 addconfig 'TransportDriver=TCP/IP'
110 addconfig 'WinStationDriver=ICA 3.0'
111
112 [[ -n ${user} ]] && addconfig "Username=${user}"
113 [[ -n ${domain} ]] && addconfig "Domain=${domain}"
114 [[ -n ${password} ]] && addconfig "ClearPassword=${password}"
115
116 # use the right display settings
117 case "${mode}" in
118 # fullscreen mode
119 fullscreen)
120 addconfig 'UseFullScreen=Yes'
121 addconfig 'NoWindowManager=True'
122 addconfig "DesiredHRES=65535"
123 addconfig "DesiredVRES=65535"
124 ;;
125 # seamless window mode
126 seamless)
127 addconfig 'TWIMode=On'
128 ;;
129 # a desired resolution
130 *x*)
131 addconfig "DesiredHRES=${mode%x*}"
132 addconfig "DesiredVRES=${mode#*x}"
133 ;;
134 esac
135
136 # generate fluxbox menu entry
137 set_fluxbox_menuitem add "${session}" "wfica ${CONFIG}"
138 ;;
139
140 del)
141 if [[ -f ${MCORE_CONFIG_PATH}/citrix/ica/${session}.ica ]]
142 then
143 rm ${MCORE_CONFIG_PATH}/citrix/ica/"${session}".ica
144 set_fluxbox_menuitem del "${session}"
145
146 elif [[ -z ${file} ]]
147 then
148 # delete all items, needed to loop through every session
149 # or we delete *all* fluxbox menuitem too
150 for i in ${MCORE_CONFIG_PATH}/citrix/ica/*
151 do
152 rm ${i}
153 set_fluxbox_menuitem del "$(basename ${i} .ica)"
154 done
155 fi
156 ;;
157
158 *) help_citrix_session && return 1 ;;
159 esac
160 }
161
162 get_citrix_session()
163 {
164 local i
165 local item
166
167 for i in $(find ${MCORE_CONFIG_PATH}/citrix/ica -type f)
168 do
169 item="${item} $(basename ${i} .ica)"
170 done
171
172 rvecho "${item}"
173 }
174
175 set_citrix_serverlist()
176 {
177 local action="$1"
178 local server="$2"
179 local CONFIG
180
181 [[ -z ${action} ]] && help_citrix_serverlist && return 1
182
183 case "${action}" in
184 add)
185 [[ -z ${server} ]] && help_citrix_serverlist && return 1
186 CONFIG="${MCORE_CONFIG_PATH}/citrix/serverlist/${server}"
187 clearconfig
188 addconfig "${server}"
189 ;;
190
191 del)
192 if [[ -f ${MCORE_CONFIG_PATH}/citrix/serverlist/${server} ]]
193 then
194 rm ${MCORE_CONFIG_PATH}/citrix/serverlist/"${server}"
195 elif [[ -z ${server} ]]
196 then
197 # delete all items
198 rm ${MCORE_CONFIG_PATH}/citrix/serverlist/*
199 fi
200 ;;
201
202 *) help_citrix_serverlist && return 1 ;;
203 esac
204 }
205
206 get_citrix_serverlist()
207 {
208 local i
209 local item
210
211 for i in $(find ${MCORE_CONFIG_PATH}/citrix/serverlist -type f)
212 do
213 item="${item} $(basename ${i})"
214 done
215
216 rvecho "${item}"
217 }