From 818d2471fc80b94819810ab35abd3cf018f41fa0 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Fri, 20 Jan 2006 17:36:22 +0000 Subject: [PATCH] Gajim is now xmpp handler in KDE too --- src/gajim.py | 26 +----------------- src/gtkgui_helpers.py | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/gajim.py b/src/gajim.py index 64cb4abb8..76df5db15 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1548,32 +1548,8 @@ if __name__ == '__main__': cli.set_restart_command(argv) except TypeError: cli.set_restart_command(len(argv), argv) - - # register (by default only the first time) xmmpi: to Gajim - try: - import gconf - # in try because daemon may not be there - client = gconf.client_get_default() - we_set = False - if gajim.config.get('set_xmpp://_handler_everytime'): - we_set = True - elif client.get_string('/desktop/gnome/url-handlers/xmpp/command') is None: - we_set = True - - if we_set: - path_to_gajim_script, type = gtkgui_helpers.get_abspath_for_script( - 'gajim-remote', True) - if path_to_gajim_script: - if type == 'svn': - command = path_to_gajim_script + ' open_chat %s' - else: # 'installed' - command = 'gajim-remote open_chat %s' - client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True) - client.set_string('/desktop/gnome/url-handlers/xmpp/command', command) - client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False) - except: - pass + gtkgui_helpers.possibly_set_gajim_as_xmpp_handler() # Migrate old logs if we have such olds logs from common import logger diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 95a568f17..89cd77d98 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -491,3 +491,65 @@ def decode_filechooser_file_paths(file_paths): file_paths_list.append(file_path) return file_paths_list + +def possibly_set_gajim_as_xmpp_handler(): + '''registers (by default only the first time) xmmp: to Gajim.''' + try: + import gconf + # in try because daemon may not be there + client = gconf.client_get_default() + except: + return + + + path_to_dot_kde = os.path.expanduser('~/.kde') + if os.path.exists(path_to_dot_kde): + path_to_kde_file = os.path.join(path_to_dot_kde, + 'share/services/xmpp.protocol') + else: + path_to_kde_file = None + + if gajim.config.get('set_xmpp://_handler_everytime'): + # it's false by default + we_set = True + elif client.get_string('/desktop/gnome/url-handlers/xmpp/command') is None: + # only the first time (GNOME/GCONF) + we_set = True + elif not os.path.exists(path_to_kde_file): # only the first time (KDE) + we_set = True + else: + we_set = False + + if not we_set: + return + + path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True) + if path_to_gajim_script: + if typ == 'svn': + command = path_to_gajim_script + ' open_chat %s' + else: # 'installed' + command = 'gajim-remote open_chat %s' + + # setting for GNOME/Gconf + client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True) + client.set_string('/desktop/gnome/url-handlers/xmpp/command', command) + client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False) + + # setting for KDE + if path_to_kde_file is not None: # user has run kde at least once + f = open(path_to_kde_file, 'w') + f.write('''\ +exec=%s "%%u" +protocol=xmpp +input=none +output=none +helper=true +listing=false +reading=false +writing=false +makedir=false +deleting=false +icon=gajim +Description=xmpp +''' % command) + f.close()