--- mcore-src/trunk/mcore-tools/src/modules/citrix/citrix.client.class.in 2014/01/13 14:39:52 2259 +++ mcore-src/trunk/mcore-tools/src/modules/citrix/citrix.client.class.in 2014/01/14 13:31:36 2276 @@ -39,8 +39,8 @@ mecho " Adds or delets a ICA session." mecho " Available actions:" mecho " add - adds a new ica session" - mecho " del - deletes ica session with file name [file]" - mecho " if no [file] given, all sessions will be deleted" + mecho " del - deletes ica session with name [name]" + mecho " if no [name] given, all sessions will be deleted" mecho mecho " Available modes:" mecho " fullscreen - fullscreen session" @@ -57,25 +57,21 @@ set_citrix_session() { - local action="$1" - local name="$2" - local session="$3" - local mode="$4" - local user="$5" - local domain="$6" - local password="$7" - local serverlist - local server - local server_num - local icafile - local CONFIG + local action="${CLASS_ARGV[0]}" + local name="${CLASS_ARGV[1]}" + local session="${CLASS_ARGV[2]}" + local mode="${CLASS_ARGV[3]}" + local user="${CLASS_ARGV[4]}" + local domain="${CLASS_ARGV[5]}" + local password="${CLASS_ARGV[6]}" local i [[ -z ${action} ]] && help_citrix_session && return 1 - [[ -z ${name} ]] && help_citrix_session && return 1 case "${action}" in add) + # requires name + [[ -z ${name} ]] && help_citrix_session && return 1 # action 'add' need mode too [[ -z ${mode} ]] && help_citrix_session && return 1 # and session @@ -86,85 +82,33 @@ fullscreen) ;; seamless) ;; *x*) ;; - *) help_citrix_session && return 1 + *) help_citrix_session && return 1 ;; esac - icafile="${MCORE_CONFIG_PATH}/citrix/ica/${name}.ica" - CONFIG="${MROOT}/${icafile}" - clearconfig - - addconfig '[WFClient]' - addconfig 'Version=2' - - serverlist=$(NOCOLORS=true get_citrix_serverlist) - declare -i i=0 - for server in ${serverlist} - do - (( i++ )) - server_num="${i}" - [[ ${i} -eq 1 ]] && server_num="" - addconfig "TcpBrowserAddress${server_num}=${server}" - done - addconfig 'ScreenPercent=0' - addconfig '[ApplicationServers]' - addconfig "${session}=" - addconfig "[${session}]" - addconfig "Address=${session}" - addconfig "InitialProgram=#${session}" - - # mapping table xorg -> citrix - # citrix 1 = 16 colors - # citrix 2 = 256 colors - # citrix 4 = 16 bit - # citrix 8 = 32 bit - # try always 16 bit - addconfig "DesiredColor=4" - - addconfig 'TransportDriver=TCP/IP' - addconfig 'WinStationDriver=ICA 3.0' - - [[ -n ${user} ]] && addconfig "Username=${user}" - [[ -n ${domain} ]] && addconfig "Domain=${domain}" - [[ -n ${password} ]] && addconfig "ClearPassword=${password}" - - # use the right display settings - case "${mode}" in - # fullscreen mode - fullscreen) - addconfig 'UseFullScreen=Yes' - addconfig 'NoWindowManager=True' - addconfig "DesiredHRES=65535" - addconfig "DesiredVRES=65535" - ;; - # seamless window mode - seamless) - addconfig 'TWIMode=On' - ;; - # a desired resolution - *x*) - addconfig "DesiredHRES=${mode%x*}" - addconfig "DesiredVRES=${mode#*x}" - ;; - esac + # create citrix session file + ${MCORE_LIBDIR}/citrix-session \ + --add \ + --name "${name}" \ + --session "${session}" \ + --mode "${mode}" \ + --user "${user}" \ + --domain "${domain}" \ + --password "${password}" # generate fluxbox menu entry set_fluxbox_menuitem add "${name}" "wfica ${icafile}" ;; del) - if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica ] + if [[ -n ${name} ]] then - rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica + ${MCORE_LIBDIR}/citrix-session --del --name "${name}" set_fluxbox_menuitem del "${name}" - - elif [[ -z ${file} ]] - then - # delete all items, needed to loop through every session - # or we delete *all* fluxbox menuitem too - for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica -type f) + else + for i in $(NOCOLORS=true ${MCORE_LIBDIR}/citrix-session --print) do - rm ${i} - set_fluxbox_menuitem del "$(basename ${i} .ica)" + ${MCORE_LIBDIR}/citrix-session --del --name "${i}" + set_fluxbox_menuitem del "${name}" done fi ;; @@ -175,128 +119,53 @@ get_citrix_session() { - local action="$1" - local server="$2" - local sessionlist - local sessioncount - local i - local exclude + local action="${CLASS_ARGV[0]}" [[ -z ${action} ]] && help_citrix_serverlist && return 1 case "${action}" in - print) list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica ;; - query) - [[ -n ${PNABROWSE_EXECUTABLE} ]] || eecho "\$PNABROWSE_EXECUTABLE not defined" - [[ -n ${PNABROWSE_CITRIX_BROWSER} ]] || eecho "\$PNABROWSE_CITRIX_BROWSER not defined" - if [ -x ${MROOT}/opt/ica-client/util/pnabrowse ] - then - if [[ -n ${PNABROWSE_SESSION_EXCLUDE} ]] - then - exclude="| grep -v '${PNABROWSE_SESSION_EXCLUDE}'" - fi - sessionlist=( $(${MROOT}/${PNABROWSE_EXECUTABLE} -A "${PNABROWSE_CITRIX_BROWSER}" ${exclude}) ) - sessioncount="${#sessionlist[*]}" - for (( i=0; i