Gajim is now xmpp handler in KDE too
This commit is contained in:
parent
20be4777a5
commit
818d2471fc
26
src/gajim.py
26
src/gajim.py
|
@ -1549,31 +1549,7 @@ if __name__ == '__main__':
|
||||||
except TypeError:
|
except TypeError:
|
||||||
cli.set_restart_command(len(argv), argv)
|
cli.set_restart_command(len(argv), argv)
|
||||||
|
|
||||||
# register (by default only the first time) xmmpi: to Gajim
|
gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
|
||||||
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
|
|
||||||
|
|
||||||
# Migrate old logs if we have such olds logs
|
# Migrate old logs if we have such olds logs
|
||||||
from common import logger
|
from common import logger
|
||||||
|
|
|
@ -491,3 +491,65 @@ def decode_filechooser_file_paths(file_paths):
|
||||||
file_paths_list.append(file_path)
|
file_paths_list.append(file_path)
|
||||||
|
|
||||||
return file_paths_list
|
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()
|
||||||
|
|
Loading…
Reference in New Issue