This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch brokerclient in repository pyhoca-gui. commit 6f01566e989aa49bbb5b49b8dc03156fe4935c2c Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 17 14:11:24 2014 +0100 Add X2Go Session Broker support. --- debian/changelog | 1 + man/man1/pyhoca-gui.1 | 32 +++++++++++++++ pyhoca/wxgui/defaults.py | 6 +++ pyhoca/wxgui/frontend.py | 57 ++++++++++++++++++++++++++- pyhoca/wxgui/launcher.py | 50 +++++++++++++++-------- pyhoca/wxgui/menus_taskbar.py | 85 ++++++++++++++++++++++++++++------------ pyhoca/wxgui/messages.py | 3 +- pyhoca/wxgui/notify.py | 3 +- pyhoca/wxgui/profilemanager.py | 26 +++++++----- 9 files changed, 207 insertions(+), 56 deletions(-) diff --git a/debian/changelog b/debian/changelog index 59e98ba..b699b9a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ pyhoca-gui (0.5.0.0-0x2go1) UNRELEASED; urgency=low * New upstream version (0.5.0.0): + - Add X2Go Session Broker support. - Adapt to new backend concept found in Python X2Go (>= 0.5.0.0). - Move most code of the pyhoca-gui executable into a dedicated class named PyHocaGUI_Launcher. diff --git a/man/man1/pyhoca-gui.1 b/man/man1/pyhoca-gui.1 index de03803..44fac9c 100644 --- a/man/man1/pyhoca-gui.1 +++ b/man/man1/pyhoca-gui.1 @@ -126,6 +126,38 @@ Disconnect from a server if a session on that server has been terminated. .TP \*(T<\fB\-\-display <hostname>:<screennumber>\fR\*(T> Set the DISPLAY environment variable to <hostname>:<screennumber>. + +.SH BROKERAGE OPTIONS +In case you want to retrieve X2Go session profiles from an X2Go Session Broker use the following options: +.TP +\*(T<\fB\-\-broker\-url=<URL>\fR\*(T> +Specify the <URL> of the X2Go Session Broker. \fBpyhoca\-gui\fR can access http:// and ssh:// style URLs. + +Syntax of <URL> for HTTP brokerage: + +http(s)://<user>:<password>@<hostname>:<port>/path/to/broker + +Syntax of <URL> for SSH brokerage: + +ssh://<user>:<password>@<hostname>:<port>/usr/bin/x2gobroker (or any executable that +provides the broker via SSH). + +As a special <URL> you can type "HTTP" or "SSH" and then the application will provide a login window with +a pre-formatted / schematic URL. +.TP +\*(T<\fB\-\-broker\-password <password>\fR\*(T> +Session broker password for retrieving session profiles from the X2Go Session Broker. +The cleartext password that has been specified at the command line will be masqueraded in +the systems process list (Linux, MacOS). On Windows systems the usage of the \-\-broker-password option is +forbidden. +.TP +\*(T<\fB\-\-broker\-name <broker\-name>\fR\*(T> +Provide a human readable name for the session broker. This name overrides the default broker name ("X2Go Session Broker") +in the application's menus and notification bubbles. +.TP +\*(T<\fB\-\-broker\-autoconnect\fR\*(T> +If this command line option is given the session broker authentication dialog will appear on application startup. + .SH BRANDING OPTIONS The \fBpyhoca-gui\fR provides some feature that allow to easily brand its appearance. Here some options for tweaking the \fBpyhoca-gui\fR appearance and behaviour. diff --git a/pyhoca/wxgui/defaults.py b/pyhoca/wxgui/defaults.py index 64086e0..cc56778 100644 --- a/pyhoca/wxgui/defaults.py +++ b/pyhoca/wxgui/defaults.py @@ -68,6 +68,12 @@ default_options = { 'disconnect_on_terminate': False, 'display': '', + # brokerage + 'broker_url': '', + 'broker_password': '', + 'broker_name': 'X2Go Session Broker', + 'broker_autoconnect': False, + # branding 'splash_image': '', 'about_image': '', diff --git a/pyhoca/wxgui/frontend.py b/pyhoca/wxgui/frontend.py index e460a42..b927b83 100644 --- a/pyhoca/wxgui/frontend.py +++ b/pyhoca/wxgui/frontend.py @@ -51,6 +51,7 @@ import locale # PyHoca-GUI modules import about import logon +import brokerlogon import passphrase import taskbar import profilemanager @@ -212,6 +213,21 @@ class PyHocaGUI(wx.App, x2go.X2GoClient): if x2go.X2GOCLIENT_OS == 'Windows' and self.args.start_pulseaudio and os.environ.has_key('PYHOCAGUI_DEVELOPMENT') and os.environ['PYHOCAGUI_DEVELOPMENT'] == '1': _x2goclient_kwargs['pulseaudio_installdir'] = os.path.dirname(basepath.pulseaudio_binary) + self.broker_autoconnect = self.args.broker_autoconnect + if self.args.broker_url: + if self.args.broker_url in ('HTTP', 'SSH'): + self.broker_autoconnect = True + _x2goclient_kwargs['broker_url'] = self.args.broker_url + self.with_brokerage = True + else: + self.with_brokerage = False + + if self.args.broker_password: + _x2goclient_kwargs['broker_password'] = self.args.broker_password + + if self.args.broker_name: + self.broker_name = self.args.broker_name + try: if self.args.logon_window_position: self.logon_window_position_x = int(self.args.logon_window_position.split('x')[0]) @@ -352,13 +368,15 @@ class PyHocaGUI(wx.App, x2go.X2GoClient): self._pyhoca_logger('opening default session profile %s' % profile_name, loglevel=x2go.log.loglevel_NOTICE) self._X2GoClient__register_session(profile_name=profile_name, auto_connect=self.auto_connect) - if self.auto_connect: + if self.auto_connect or self.broker_autoconnect: gevent.spawn(self._auto_connect) def _auto_connect(self): """\ Register all available session profiles on application start. + If brokerage is used, handle auto connecting to the broker before that, as well. + The auto-registration of all session profiles will trigger the auto-connect feature implemented in C{X2GoClient} of Python X2Go. @@ -366,7 +384,12 @@ class PyHocaGUI(wx.App, x2go.X2GoClient): # wait for splash to appear if not self.args.disable_splash: gevent.sleep(1) - if not self.args.session_profile: + + # auto connect to the broker if requested + if self.with_brokerage and self.broker_autoconnect: + self.OnBrokerAuthenticate(None) + + if self.auto_connect and not self.args.session_profile: self._X2GoClient__register_all_session_profiles() def session_auto_connect(self, session_uuid, **kwargs): @@ -800,6 +823,36 @@ class PyHocaGUI(wx.App, x2go.X2GoClient): if not self.is_session_profile(profile_name): profilemanager.PyHocaGUI_ProfileManager(self, 'ADD_EXPLICITLY', profile_name=profile_name) + def OnBrokerAuthenticate(self, evt): + """\ + Gets called if the user requests connecting to a session profile. + + @param evt: event + @type evt: C{obj} + + """ + _broker_logon_window = brokerlogon.PyHocaGUI_BrokerDialogBoxPassword(self, caller=self) + + def OnBrokerDisconnect(self, evt): + """\ + Reset (disconnect from) the broker connection. + + @param evt: event + @type evt: C{obj} + + """ + self._hide_notifications_map = {} + self._temp_launching_pubapp_profiles = [] + self._temp_launching_pubapp_locks = {} + self._temp_disabled_profile_names = [] + self._temp_disabled_session_names = {} + self._remember_shared_folders = {} + + for profile_name in self._X2GoClient__client_connected_profiles(return_profile_names=True): + self._X2GoClient__disconnect_profile(profile_name) + + self.session_profiles.broker_disconnect() + def OnSessionStart(self, evt): """\ Gets called if the user requests to start a new X2Go session. diff --git a/pyhoca/wxgui/launcher.py b/pyhoca/wxgui/launcher.py index fc3299c..9030ddd 100644 --- a/pyhoca/wxgui/launcher.py +++ b/pyhoca/wxgui/launcher.py @@ -86,8 +86,16 @@ VERSION: %s self.VERSION_TEXT = text def setup_process(self): + PROG_OPTIONS = " ".join(sys.argv[1:]).replace("=", " ").split() + try: + _broker_password_index = PROG_OPTIONS.index('--broker-password')+1 + PROG_OPTIONS[_broker_password_index] = "XXXXXXXX" + except ValueError: + # ignore if --broker-password option is not specified + pass if X2GOCLIENT_OS in ('Linux', 'Mac'): import setproctitle + #setproctitle.setproctitle("%s %s" % (self.PROG_NAME, " ".join(PROG_OPTIONS))) setproctitle.setproctitle(self.PROG_NAME) if X2GOCLIENT_OS == 'Windows': @@ -103,40 +111,42 @@ VERSION: %s if sys.argv[0].startswith('./') or sys.argv[0].startswith('python'): sys.path.insert(0, os.getcwd()) os.environ['PYHOCAGUI_DEVELOPMENT'] = '1' - print '### %s running in development mode ###' % self.PROG_NAME + print '### {progname} running in development mode ###'.format(progname=self.PROG_NAME) basepath.reload_base_paths() def check_running(self): if X2GOCLIENT_OS in ('Linux', 'Mac'): + _executable = os.path.basename(sys.argv[0]).replace('.exe', '') + p = subprocess.Popen(['ps', '-U', CURRENT_LOCAL_USER, '-u', CURRENT_LOCAL_USER], stdout=subprocess.PIPE) psA_out = p.communicate() - if psA_out[0].count(self.PROG_NAME) <= 1: + if psA_out[0].count(_executable) <= 1: - if os.path.isdir(os.path.expanduser("~/.x2go/pyhoca-gui/")): - shutil.rmtree(os.path.expanduser("~/.x2go/pyhoca-gui/")) + if os.path.isdir(os.path.expanduser("~/.x2go/{progname}/".format(progname=_executable))): + shutil.rmtree(os.path.expanduser("~/.x2go/{progname}/".format(progname=_executable))) my_pid = str(os.getpid()) - if not os.path.exists(os.path.expanduser("~/.x2go/pyhoca-gui/")): - os.makedirs(os.path.expanduser("~/.x2go/pyhoca-gui/")) - my_pidfile = os.path.expanduser("~/.x2go/pyhoca-gui/display.{pid}".format(pid=my_pid)) + if not os.path.exists(os.path.expanduser("~/.x2go/{progname}/".format(progname=_executable))): + os.makedirs(os.path.expanduser("~/.x2go/{progname}/".format(progname=_executable))) + my_pidfile = os.path.expanduser("~/.x2go/{progname}/display.{pid}".format(progname=_executable, pid=my_pid)) my_display = os.environ['DISPLAY'] open(my_pidfile, 'w').write(my_display) already_running_for_this_display = False - for pidfile in os.listdir(os.path.expanduser("~/.x2go/pyhoca-gui/")): + for pidfile in os.listdir(os.path.expanduser("~/.x2go/{progname}/".format(progname=_executable))): # this is our own pid file... if my_pidfile.endswith(pidfile): continue - display = open(os.path.expanduser("~/.x2go/pyhoca-gui/") + pidfile, 'r').read() + display = open(os.path.expanduser("~/.x2go/{progname}/".format(progname=_executable)) + pidfile, 'r').read() if display.split('.')[0] == my_display.split('.')[0]: other_pid = pidfile.split('.')[1] print - print('One instance of PyHoca-GUI (PID: {other_pid}) is already running for this $DISPLAY {display}'.format(other_pid=other_pid, display=my_display)) + print('One instance of {progname} (PID: {other_pid}) is already running for this $DISPLAY {display}'.format(progname=_executable, other_pid=other_pid, display=my_display)) return True @@ -148,7 +158,7 @@ VERSION: %s _p_names = [] for process in w.Win32_Process(): _p_names.append(process.Name) - return len([ _p_name for _p_name in _p_names if _p_name == self.PROG_NAME]) > 1 + return len([ _p_name for _p_name in _p_names if _p_name == _executable]) > 1 def version(self): @@ -244,6 +254,13 @@ VERSION: %s {'args':['--published-applications-no-submenus'], 'default': _default_options['published_applications_no_submenus'], 'metavar': '<number>', 'help': 'the number of published applications that will be rendered without submenus', }, ] + broker_options = [ + {'args':['-B','--broker-url'], 'default': _default_options['broker_url'], 'help': 'retrieve session profiles via an X2Go Session Broker under the given URL', }, + {'args':['--broker-password'], 'default': _default_options['broker_password'], 'help': 'password for authenticating against the X2Go Session Broker', }, + {'args':['--broker-name'], 'default': _default_options['broker_name'], 'help': 'tweak the wording of \'X2Go Session Broker\'', }, + {'args':['--broker-autoconnect'], 'default': _default_options['broker_autoconnect'], 'action': 'store_true', 'help': 'trigger broker authentication directly after application startup', }, + ] + if X2GOCLIENT_OS == 'Windows': x2go_gui_options.append( {'args':['--lang'], 'default': _default_options['lang'], 'metavar': 'LANGUAGE', 'help': 'set the GUI language (currently available: en, de, nl, es)', }, @@ -277,7 +294,8 @@ VERSION: %s formatter_class=argparse.RawDescriptionHelpFormatter, \ add_help=True, argument_default=None) p_debugopts = p.add_argument_group('Debug options') - p_guiopts = p.add_argument_group('%s options' % self.PROG_NAME) + p_guiopts = p.add_argument_group('{progname} options'.format(progname=self.PROG_NAME)) + p_brokeropts = p.add_argument_group('Brokerage options') p_portableopts = p.add_argument_group('Portable application support') p_backendopts = p.add_argument_group('Python X2Go backend options (for experts only)') @@ -286,7 +304,7 @@ VERSION: %s p_portableopts = p.add_argument_group('File locations for portable setups (MS Windows only)') _option_groups = ((p_guiopts, x2go_gui_options), (p_debugopts, debug_options), (p_contribopts, contrib_options), (p_portableopts, portable_options), (p_backendopts, backend_options), ) else: - _option_groups = ((p_guiopts, x2go_gui_options), (p_debugopts, debug_options), (p_portableopts, portable_options), (p_backendopts, backend_options), ) + _option_groups = ((p_guiopts, x2go_gui_options), (p_brokeropts, broker_options), (p_debugopts, debug_options), (p_portableopts, portable_options), (p_backendopts, backend_options), ) for (p_group, opts) in _option_groups: required = False for opt in opts: @@ -341,7 +359,7 @@ VERSION: %s a.start_xserver = a.preferred_xserver if X2GOCLIENT_OS == 'Windows' and a.start_xserver and a.display: - self.runtime_error('You can tell %s to handle XServer startup and then specify a DISPLAY environment variable!' % self.PROG_NAME, parser=p) + self.runtime_error('You can tell %s to handle XServer startup and then specify a DISPLAY environment variable!'.format(progname=self.PROG_NAME), parser=p) if a.display: os.environ.update({'DISPLAY': a.display}) @@ -378,9 +396,9 @@ VERSION: %s if self.check_running(): sys.stderr.write("\n###############################\n### %s: already running for user %s\n###############################\n" % (self.PROG_NAME, CURRENT_LOCAL_USER)) - m = PyHoca_MessageWindow_Ok(wx.App(), shortmsg='ALREADY_RUNNING', title=u'%s (%s)...' % (self.PROG_NAME, self.VERSION), icon='pyhoca-trayicon') + m = PyHoca_MessageWindow_Ok(wx.App(), shortmsg='ALREADY_RUNNING', title=u'%s (%s)...' % (self.PROG_NAME, self.VERSION), icon='{progname}_trayicon'.format(progname=self.PROG_NAME)) m.ShowModal() - version() + self.version() thisPyHocaGUI = None try: diff --git a/pyhoca/wxgui/menus_taskbar.py b/pyhoca/wxgui/menus_taskbar.py index 2a6d3c5..e9a7e96 100644 --- a/pyhoca/wxgui/menus_taskbar.py +++ b/pyhoca/wxgui/menus_taskbar.py @@ -72,18 +72,27 @@ class PyHocaGUI_Menu_TaskbarManageProfile(wx.Menu): self._PyHocaGUI._eventid_profilenames_map[ID_EXPORTPROFILE] = \ self._PyHocaGUI._eventid_profilenames_map[ID_DELETEPROFILE] = profile_name - self.Append(text=_(u"Edit Profile"), id=ID_EDITPROFILE) + if self._PyHocaGUI.session_profiles.is_mutable(profile_name): + self.Append(text=_(u"Edit Profile"), id=ID_EDITPROFILE) + else: + self.Append(text=_(u"View Profile"), id=ID_EDITPROFILE) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileEdit, id=ID_EDITPROFILE) + if not self._PyHocaGUI.args.single_session_profile: + self.AppendSeparator() - self.Append(text=_(u"Use as Template for New Profile"), id=ID_COPYPROFILE) - self.AppendSeparator() + + if self._PyHocaGUI.session_profiles.is_mutable(profile_name): + self.Append(text=_(u"Use as Template for New Profile"), id=ID_COPYPROFILE) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileCopy, id=ID_COPYPROFILE) + self.AppendSeparator() + self.Append(text=_(u"Export Profile"), id=ID_EXPORTPROFILE) - self.Append(text=_(u"Delete Profile"), id=ID_DELETEPROFILE) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileExport, id=ID_EXPORTPROFILE) - self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileEdit, id=ID_EDITPROFILE) - self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileCopy, id=ID_COPYPROFILE) - self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileExport, id=ID_EXPORTPROFILE) - self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileDelete, id=ID_DELETEPROFILE) + if self._PyHocaGUI.session_profiles.is_mutable(profile_name): + self.Append(text=_(u"Delete Profile"), id=ID_DELETEPROFILE) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileDelete, id=ID_DELETEPROFILE) class PyHocaGUI_Menu_TaskbarOptionsManager(wx.Menu): @@ -133,7 +142,9 @@ class PyHocaGUI_Menu_TaskbarOptionsManager(wx.Menu): if self._PyHocaGUI.profilemanager_disabled: _maintain_profiles_item.Enable(False) - else: + self.AppendSeparator() + + elif self._PyHocaGUI.session_profiles.has_profile_name(self._PyHocaGUI.args.session_profile): ID_SINGLEPROFILEMANAGER = wx.NewId() _maintain_profile_item = self.AppendMenu(id=ID_SINGLEPROFILEMANAGER, text=_(u'Manage Session Profile'), @@ -141,8 +152,13 @@ class PyHocaGUI_Menu_TaskbarOptionsManager(wx.Menu): ) if self._PyHocaGUI.args.session_profile in self._PyHocaGUI.client_connected_profiles(return_profile_names=True): _maintain_profile_item.Enable(False) + self.AppendSeparator() - self.AppendSeparator() + if self._PyHocaGUI.with_brokerage and self._PyHocaGUI.session_profiles.is_broker_authenticated(): + ID_BROKER_DISCONNECT = wx.NewId() + self.Append(id=ID_BROKER_DISCONNECT, text=_(u"Disconnect from session broker")) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnBrokerDisconnect, id=ID_BROKER_DISCONNECT) + self.AppendSeparator() ID_PRINTINGPREFS = wx.NewId() _printingprefs_item = self.Append(id=ID_PRINTINGPREFS, text=_(u"Printing Preferences")) @@ -522,6 +538,7 @@ class PyHocaGUI_Menu_TaskbarSessionProfile(wx.Menu): wx.Menu.__init__(self) + ID_AUTHENTICATE_BROKER=wx.NewId() ID_CONNECT=wx.NewId() ID_PUBAPPSESSIONSTART=wx.NewId() ID_SESSIONSTART=wx.NewId() @@ -534,7 +551,12 @@ class PyHocaGUI_Menu_TaskbarSessionProfile(wx.Menu): _foldersharing_disabled = False - if self._PyHocaGUI.args.single_session_profile and not self._PyHocaGUI.is_session_profile(profile_name): + if self._PyHocaGUI.with_brokerage and not self._PyHocaGUI.session_profiles.is_broker_authenticated(): + _auth_menu_text = _(u'Connect to') + self._PyHocaGUI.broker_name + self.Append(id=ID_AUTHENTICATE_BROKER, text=_auth_menu_text) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnBrokerAuthenticate, id=ID_AUTHENTICATE_BROKER) + + elif self._PyHocaGUI.args.single_session_profile and not self._PyHocaGUI.is_session_profile(profile_name): connect = self.Append(id=ID_CONNECT, text=_(u'Connect %s') % profile_name) connect.Enable(False) else: @@ -779,7 +801,10 @@ class PyHocaGUI_Menu_TaskbarSessionProfile(wx.Menu): if not self._PyHocaGUI.restricted_trayicon: self.AppendSeparator() - self.Append(id=ID_EDITPROFILEWHILECONNECTED, text=_(u"Customize &profile")) + if self._PyHocaGUI.session_profiles.is_mutable(profile_name): + self.Append(id=ID_EDITPROFILEWHILECONNECTED, text=_(u"Customize &profile")) + else: + self.Append(id=ID_EDITPROFILEWHILECONNECTED, text=_(u"View &profile")) self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileEditWhileConnected, id=ID_EDITPROFILEWHILECONNECTED) self._PyHocaGUI._eventid_profilenames_map[ID_EDITPROFILEWHILECONNECTED] = \ @@ -876,7 +901,7 @@ class PyHocaGUI_Menu_TaskbarProfileNames(wx.Menu): wx.Menu.__init__(self) - if type(caller) == PyHocaGUI_Menu_TaskbarOptionsManager: + if type(caller) == PyHocaGUI_Menu_TaskbarOptionsManager and self._PyHocaGUI.session_profiles.supports_mutable_profiles(): ID_ADDPROFILE = wx.NewId() self.Append(id=ID_ADDPROFILE, text=_(u"Add Profile")) self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileAdd, id=ID_ADDPROFILE) @@ -954,7 +979,10 @@ class PyHocaGUI_Menu_TaskbarProfileNames(wx.Menu): self._PyHocaGUI.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=_this_id) if not group_name and (not _profile_groups and not _profile_names) and not filter_profiles: - _dummy = self.Append(text=_(u'No session profiles defined'), id=wx.NewId()) + if self._PyHocaGUI.with_brokerage: + _dummy = self.Append(text=_(u'Session broker is not connected'), id=wx.NewId()) + else: + _dummy = self.Append(text=_(u'No session profiles defined'), id=wx.NewId()) _dummy.Enable(False) else: @@ -970,7 +998,7 @@ class PyHocaGUI_Menu_TaskbarProfileNames(wx.Menu): self.Append(text=_(u'Export Profile Group'), id=_export_id) self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnProfileExport, id=_export_id) - if bind_method is None and not group_name: + if bind_method is None and not group_name and self._PyHocaGUI.session_profiles.supports_mutable_profiles(): _import_id = wx.NewId() self.AppendSeparator() self.Append(text=_(u'Import Session Profiles'), id=_import_id) @@ -1006,18 +1034,25 @@ class PyHocaGUI_Menu_TaskbarSessionManager(wx.Menu): wx.Menu.__init__(self) - ID_AUTHENTICATE = wx.NewId() + ID_AUTHENTICATE_SESSION = wx.NewId() + ID_AUTHENTICATE_BROKER = wx.NewId() ID_EXIT = wx.NewId() - _auth_menu_text = _(u'Connect Server') - self.AppendMenu(id=ID_AUTHENTICATE, - text=_auth_menu_text, - submenu=PyHocaGUI_Menu_TaskbarProfileNames(self._PyHocaGUI, - caller=self, - filter_profiles=[], - disabled_profiles=self._PyHocaGUI.client_connected_profiles(return_profile_names=True) + self._PyHocaGUI._temp_disabled_profile_names, - bind_method=self._PyHocaGUI.OnSessionAuthenticate)) - self.AppendSeparator() + if self._PyHocaGUI.with_brokerage and not self._PyHocaGUI.session_profiles.is_broker_authenticated(): + _auth_menu_text = _(u'Connect to') + ' ' + self._PyHocaGUI.broker_name + self.Append(id=ID_AUTHENTICATE_BROKER, text=_auth_menu_text) + self._PyHocaGUI.Bind(wx.EVT_MENU, self._PyHocaGUI.OnBrokerAuthenticate, id=ID_AUTHENTICATE_BROKER) + self.AppendSeparator() + else: + _auth_menu_text = _(u'Connect Server') + self.AppendMenu(id=ID_AUTHENTICATE_SESSION, + text=_auth_menu_text, + submenu=PyHocaGUI_Menu_TaskbarProfileNames(self._PyHocaGUI, + caller=self, + filter_profiles=[], + disabled_profiles=self._PyHocaGUI.client_connected_profiles(return_profile_names=True) + self._PyHocaGUI._temp_disabled_profile_names, + bind_method=self._PyHocaGUI.OnSessionAuthenticate)) + self.AppendSeparator() _profile_names = self._PyHocaGUI.session_profiles.profile_names _profile_names.sort() diff --git a/pyhoca/wxgui/messages.py b/pyhoca/wxgui/messages.py index 721384d..71656eb 100644 --- a/pyhoca/wxgui/messages.py +++ b/pyhoca/wxgui/messages.py @@ -30,8 +30,6 @@ import basepath # X2Go modules from x2go.defaults import CURRENT_LOCAL_USER as _CURRENT_LOCAL_USER -_icons_location = basepath.icons_basepath - class PyHoca_MessageWindow(wx.Dialog): """\ A simple message window for L{PyHocaGUI}. @@ -93,6 +91,7 @@ class PyHoca_MessageWindow(wx.Dialog): wx.Dialog.__init__(self, parent, wx.ID_ANY, ) self.SetTitle('%s' % title) + _icons_location = basepath.icons_basepath if icon: path_to_icon = os.path.normpath('%s/PyHoca/64x64/%s.png' % (_icons_location, icon)) self.icon = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap(path_to_icon, wx.BITMAP_TYPE_ANY)) diff --git a/pyhoca/wxgui/notify.py b/pyhoca/wxgui/notify.py index 197f70f..8d66cc5 100644 --- a/pyhoca/wxgui/notify.py +++ b/pyhoca/wxgui/notify.py @@ -29,8 +29,6 @@ from taskbar import MakeIcon import x2go.utils as utils -_icons_location = basepath.icons_basepath - class NotSupportedException(exceptions.StandardError): pass class PyHocaNotificationException(exceptions.StandardError): pass @@ -126,6 +124,7 @@ class libnotify_NotifierPopup(object): except KeyError: pass + _icons_location = basepath.icons_basepath if icon: icon = 'file://%s/PyHoca/32x32/%s.png' % (_icons_location, icon) diff --git a/pyhoca/wxgui/profilemanager.py b/pyhoca/wxgui/profilemanager.py index 130f5f7..1607d2d 100644 --- a/pyhoca/wxgui/profilemanager.py +++ b/pyhoca/wxgui/profilemanager.py @@ -165,7 +165,7 @@ class PyHocaGUI_ProfileManager(wx.Dialog): if _to_host: self.profile_config['host'] = [_to_host] if _to_port: self.profile_config['sshport'] = int(_to_port) - self.profile_config['sshproxytunnel'] = 'DEPRECATED_CAN_BE_SAFELY_REMOVE' + self.profile_config['sshproxytunnel'] = 'DEPRECATED_CAN_BE_SAFELY_REMOVED' # we create a backup dict of our profile_config immediately (for being able to reset erroneously made changes) self.profile_config_orig = copy.deepcopy(self.profile_config) @@ -185,7 +185,7 @@ class PyHocaGUI_ProfileManager(wx.Dialog): self.tab_MediaResources = wx.Panel(self.X2GoTabs, -1) self.tab_SharedResources = wx.Panel(self.X2GoTabs, -1) - if not self.session_profiles.is_writable(self.profile_id): + if not self.session_profiles.is_mutable(self.profile_id): self.tab_Profile.Enable(False) self.tab_Session.Enable(False) self.tab_Connection.Enable(False) @@ -380,12 +380,14 @@ class PyHocaGUI_ProfileManager(wx.Dialog): else: self.OKButton = wx.Button(self, -1, _(u"Save")) self.DefaultButton = wx.Button(self, -1, _(u'Reset')) - self.OKButton.SetDefault() self.ApplyButton = wx.Button(self, -1, _(u"Apply")) self.CancelButton = wx.Button(self, -1, _(u"Cancel")) - if not self.session_profiles.is_writable(self.profile_id): + if self.session_profiles.is_mutable(self.profile_id): + self.OKButton.SetDefault() + else: self.OKButton.Enable(False) self.ApplyButton.Enable(False) + self.CancelButton.SetDefault() self.__set_properties() self.__do_layout() @@ -446,11 +448,17 @@ class PyHocaGUI_ProfileManager(wx.Dialog): """ if self.action == 'ADD': - self.SetTitle(_(u"PyHoca-GUI Profile Manager - new profile")) + self.SetTitle(_(u"%s Profile Manager - new profile") % self._PyHocaGUI.appname) elif self.action == 'EDIT_CONNECTED': - self.SetTitle(_(u"PyHoca-GUI Profile Manager - %s (connected)") % self.profile_config['name']) + if self._PyHocaGUI.session_profiles.is_mutable(self.profile_config['name']): + self.SetTitle(_(u"%s Profile Manager - %s (connected)") % (self._PyHocaGUI.appname, self.profile_config['name'])) + else: + self.SetTitle(_(u"%s Profile Manager - %s (connected, immutable)") % (self._PyHocaGUI.appname, self.profile_config['name'])) else: - self.SetTitle(_(u"PyHoca-GUI Profile Manager - %s") % self.profile_config['name']) + if self._PyHocaGUI.session_profiles.is_mutable(self.profile_config['name']): + self.SetTitle(_(u"%s Profile Manager - %s") % (self._PyHocaGUI.appname, self.profile_config['name'])) + else: + self.SetTitle(_(u"%s Profile Manager - %s (immutable)") % (self._PyHocaGUI.appname, self.profile_config['name'])) self.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self._textfield_height = 30 @@ -1562,7 +1570,7 @@ class PyHocaGUI_ProfileManager(wx.Dialog): self.SoundPortLabel.Enable(False) self.SoundPort.Enable(False) self.Esd.Enable(False) - if self.session_profiles.is_writable(self.profile_id): + if self.session_profiles.is_mutable(self.profile_id): self.tab_SharedResources.Enable(True) self.RDPServer.Enable(False) _hosts = self.Host.GetValue() @@ -1620,7 +1628,7 @@ class PyHocaGUI_ProfileManager(wx.Dialog): self.DefaultSoundPort.Enable(True) self.DefaultSoundPort.SetValue(True) self.Esd.Enable(True) - if self.session_profiles.is_writable(self.profile_id): + if self.session_profiles.is_mutable(self.profile_id): self.tab_SharedResources.Enable(True) self.RDPServer.SetValue(self.profile_config_bak['rdpserver']) self.RDPOptions.SetValue(self.profile_config_bak['rdpoptions']) -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/pyhoca-gui.git