Correctly register gajim-remote with xmpp: URIs

This commit is contained in:
Yann Leboulanger 2015-07-17 22:19:16 +02:00
parent d69fcc9e1e
commit c9eb479fe3
11 changed files with 18 additions and 121 deletions

View File

@ -0,0 +1,11 @@
[Desktop Entry]
Categories=Network;InstantMessaging;RemoteAccess;ConsoleOnly;
_Name=Gajim Remote
_Keywords=chat;messaging;im;jabber;xmpp;bonjour;voip
Version=1.0
Exec=gajim-remote handle_uri %u
TryExec=gajim-remote
StartupNotify=false
Terminal=false
Type=Application
MimeType=x-scheme-handler/xmpp

View File

@ -3049,23 +3049,6 @@ to discover one from server.</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_default_client_checkbutton">
<property name="label" translatable="yes">Check on startup if Gajim is the _default Jabber client</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_check_default_client_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -8859,7 +8859,7 @@ msgstr ""
#: ../src/gajim-remote-plugin.py:252 ../src/gajim-remote.py:277
#, fuzzy
msgid "Handle a xmpp:/ uri"
msgid "Handle a xmpp: uri"
msgstr "Το URI \"%s\" δεν είναι έγκυρο."
#: ../src/gajim-remote-plugin.py:254 ../src/gajim-remote.py:279

View File

@ -9628,7 +9628,7 @@ msgstr "cli"
#: ../src/gajim-remote.py:277
#, fuzzy
msgid "Handle a xmpp:/ uri"
msgid "Handle a xmpp: uri"
msgstr "cli"
#: ../src/gajim-remote.py:279

View File

@ -8979,7 +8979,7 @@ msgid "Account in which the avatar will be set; if not specified, the avatar wil
msgstr "Konto, dla którego ma być ustawiony awatar; jeżeli nie jest określone, awatar zostanie ustawiony dla wszystkich kont"
#: ../src/gajim-remote.py:278
msgid "Handle a xmpp:/ uri"
msgid "Handle a xmpp: uri"
msgstr "Obsługuj URI xmpp:/"
#: ../src/gajim-remote.py:280

View File

@ -7786,7 +7786,7 @@ msgstr ""
#: ../src/gajim-remote.py:277
#, fuzzy
msgid "Handle a xmpp:/ uri"
msgid "Handle a xmpp: uri"
msgstr "Adres verilmedi"
#: ../src/gajim-remote.py:279

View File

@ -245,7 +245,6 @@ class Config:
'notification_avatar_height': [opt_int, 48],
'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in group chats.')],
'quit_on_roster_x_button': [opt_bool, False, _('If True, quits Gajim when X button of Window Manager is clicked. This setting is taken into account only if notification icon is used.')],
'check_if_gajim_is_default': [opt_bool, True, _('If True, Gajim will check if it\'s the default jabber client on each startup.')],
'show_unread_tab_icon': [opt_bool, False, _('If True, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')],
'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window.'), True],
'show_avatars_in_roster': [opt_bool, True, '', True],

View File

@ -608,6 +608,7 @@ class Sign(TextHandler):
__bool__ = __nonzero__
def handle_status(self, key, value):
self.status = ''
if key in ("USERID_HINT", "NEED_PASSPHRASE", "BAD_PASSPHRASE",
"GOOD_PASSPHRASE", "BEGIN_SIGNING", "CARDCTRL", "INV_SGNR",
"NO_SGNR", "MISSING_PASSPHRASE", "NEED_PASSPHRASE_PIN",

View File

@ -557,10 +557,6 @@ class PreferencesWindow:
self.update_proxy_list()
# check if gajm is default
st = gajim.config.get('check_if_gajim_is_default')
self.xml.get_object('check_default_client_checkbutton').set_active(st)
# Ignore messages from unknown contacts
w = self.xml.get_object('ignore_events_from_unknown_contacts_checkbutton')
st = self.get_per_account_option('ignore_unknown_contacts')
@ -1179,9 +1175,6 @@ class PreferencesWindow:
widget.set_inconsistent(False)
self.on_per_account_checkbutton_toggled(widget, 'send_idle_time')
def on_check_default_client_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'check_if_gajim_is_default')
def on_notify_gmail_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email')

View File

@ -677,94 +677,6 @@ def decode_filechooser_file_paths(file_paths):
return file_paths_list
def possibly_set_gajim_as_xmpp_handler():
"""
Register (by default only the first time) 'xmmp:' to Gajim
"""
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
def set_gajim_as_xmpp_handler(is_checked=None):
if is_checked is not None:
# come from confirmation dialog
gajim.config.set('check_if_gajim_is_default', is_checked)
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 + ' handle_uri %s'
else: # 'installed'
command = 'gajim-remote handle_uri %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
try:
f = open(path_to_kde_file, 'a')
f.write('''\
[Protocol]
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()
except IOError:
log.debug("I/O Error writing settings to %s",
repr(path_to_kde_file), exc_info=True)
else: # no gajim remote, stop ask user everytime
gajim.config.set('check_if_gajim_is_default', False)
try:
gi.require_version('GConf', '2.0')
GConf = importlib.import_module('gi.repository.GConf')
# in try because daemon may not be there
client = GConf.Client.get_default()
except Exception:
return
old_command = client.get_string('/desktop/gnome/url-handlers/xmpp/command')
if not old_command or old_command.endswith(' open_chat %s'):
# first time (GNOME/GCONF) or old Gajim version
we_set = True
elif path_to_kde_file is not None and not os.path.exists(path_to_kde_file):
# only the first time (KDE)
we_set = True
else:
we_set = False
if we_set:
set_gajim_as_xmpp_handler()
elif old_command and not old_command.endswith(' handle_uri %s'):
# xmpp: is currently handled by another program, so ask the user
pritext = _('Gajim is not the default Jabber client')
sectext = _('Would you like to make Gajim the default Jabber client?')
checktext = _('Always check to see if Gajim is the default Jabber '
'client on startup')
def on_cancel(checked):
gajim.config.set('check_if_gajim_is_default', checked)
dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext,
set_gajim_as_xmpp_handler, on_cancel)
if gajim.config.get('check_if_gajim_is_default'):
dlg.checkbutton.set_active(True)
def escape_underscore(s):
"""
Escape underlines to prevent them from being interpreted as keyboard

View File

@ -1213,6 +1213,8 @@ class Interface:
file_props = None
# get the file_props of our session
file_props = FilesProp.getFileProp(obj.conn.name, obj.sid)
if not file_props:
return
ft.set_status(file_props, 'stop')
file_props.error = -4 # is it the right error code?
ft.show_stopped(obj.jid, file_props, 'Peer cancelled ' +
@ -2772,10 +2774,6 @@ class Interface:
if gajim.config.get('verbose'):
logging_helpers.set_verbose()
# Is Gajim default app?
if os.name != 'nt' and gajim.config.get('check_if_gajim_is_default'):
gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
for account in gajim.config.get_per('accounts'):
if gajim.config.get_per('accounts', account, 'is_zeroconf'):
gajim.ZEROCONF_ACC_NAME = account