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