Commit 959687c2 authored by Yann Leboulanger's avatar Yann Leboulanger

check at startup if gajim is the default xmp:// handler and prompt user if it's not. fixes #2861

parent 6076bd10
......@@ -3359,6 +3359,26 @@ Custom</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_default_client_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Always check to see if Gajim is the _default Jabber client on startup</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_check_default_client_checkbutton_toggled" last_modification_time="Fri, 05 Jan 2007 17:15:21 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
......
......@@ -188,7 +188,7 @@ 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 trayicon is used.')],
'set_xmpp://_handler_everytime': [opt_bool, False, _('If True, Gajim registers for xmpp:// on each startup.')],
'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],
......
......@@ -492,6 +492,10 @@ class PreferencesWindow:
st = gajim.config.get('send_os_info')
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
# send os info
st = gajim.config.get('check_if_gajim_is_default')
self.xml.get_widget('check_default_client_checkbutton').set_active(st)
# set status msg from currently playing music track
widget = self.xml.get_widget(
'set_status_msg_from_current_music_track_checkbutton')
......@@ -997,13 +1001,16 @@ class PreferencesWindow:
def on_send_os_info_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'send_os_info')
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')
def on_notify_gmail_extra_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email_extra')
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)
model = self.msg_tree.get_model()
......
......@@ -2061,6 +2061,11 @@ class Interface:
# Do not set gajim.verbose to False if -v option was given
if gajim.config.get('verbose'):
gajim.verbose = True
# 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()
#add default status messages if there is not in the config file
if len(gajim.config.get_per('statusmsg')) == 0:
for msg in gajim.config.statusmsg_default:
......@@ -2255,8 +2260,6 @@ if __name__ == '__main__':
except TypeError:
cli.set_restart_command(len(argv), argv)
gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
check_paths.check_and_possibly_create_paths()
Interface()
......
......@@ -630,14 +630,6 @@ def decode_filechooser_file_paths(file_paths):
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,
......@@ -646,38 +638,29 @@ def possibly_set_gajim_as_xmpp_handler():
path_to_kde_file = None
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 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 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 + ' 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
f = open(path_to_kde_file, 'w')
f.write('''\
def set_gajim_as_xmpp_handler(widget = None):
if widget:
# come from confirmation dialog
gajim.config.set('check_if_gajim_is_default',
dlg.checkbutton.get_active())
dlg.destroy()
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
f = open(path_to_kde_file, 'w')
f.write('''\
[Protocol]
exec=%s "%%u"
protocol=xmpp
......@@ -692,7 +675,41 @@ deleting=false
icon=gajim
Description=xmpp
''' % command)
f.close()
f.close()
try:
import gconf
# in try because daemon may not be there
client = gconf.client_get_default()
except:
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(widget):
gajim.config.set('check_if_gajim_is_default',
dlg.checkbutton.get_active())
dlg.destroy()
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment