diff --git a/src/gajim.py b/src/gajim.py index 64cb4abb8c7da22cfbc9bb9be55932ea54c8c41a..76df5db15bef6ffbec39f5d13586f4ad228d41fc 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 95a568f174e75950bb36be53d72b21f6fb7d2d91..89cd77d9853d006d6f4bfb029e0034e5dc4f9379 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()