| 596 | | |
| 597 | | if gajim.config.get('set_xmpp://_handler_everytime'): |
| 598 | | # it's false by default |
| 599 | | we_set = True |
| 600 | | elif client.get_string('/desktop/gnome/url-handlers/xmpp/command') is None: |
| 601 | | # only the first time (GNOME/GCONF) |
| 602 | | we_set = True |
| 603 | | elif path_to_kde_file is not None and not os.path.exists(path_to_kde_file): |
| 604 | | # only the first time (KDE) |
| 605 | | we_set = True |
| 606 | | else: |
| 607 | | we_set = False |
| 608 | | |
| 609 | | if not we_set: |
| 610 | | return |
| 611 | | |
| 612 | | path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True) |
| 613 | | if path_to_gajim_script: |
| 614 | | if typ == 'svn': |
| 615 | | command = path_to_gajim_script + ' open_chat %s' |
| 616 | | else: # 'installed' |
| 617 | | command = 'gajim-remote open_chat %s' |
| 618 | | |
| 619 | | # setting for GNOME/Gconf |
| 620 | | client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True) |
| 621 | | client.set_string('/desktop/gnome/url-handlers/xmpp/command', command) |
| 622 | | client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False) |
| 623 | | |
| 624 | | # setting for KDE |
| 625 | | if path_to_kde_file is not None: # user has run kde at least once |
| 626 | | f = open(path_to_kde_file, 'w') |
| 627 | | f.write('''\ |
| | 586 | |
| | 587 | def set_gajim_as_xmpp_handler(widget = None): |
| | 588 | if widget: |
| | 589 | # come from confirmation dialog |
| | 590 | gajim.config.set('check_if_gajim_is_default', |
| | 591 | dlg.checkbutton.get_active()) |
| | 592 | dlg.destroy() |
| | 593 | path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True) |
| | 594 | if path_to_gajim_script: |
| | 595 | if typ == 'svn': |
| | 596 | command = path_to_gajim_script + ' handle_uri %s' |
| | 597 | else: # 'installed' |
| | 598 | command = 'gajim-remote handle_uri %s' |
| | 599 | |
| | 600 | # setting for GNOME/Gconf |
| | 601 | client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True) |
| | 602 | client.set_string('/desktop/gnome/url-handlers/xmpp/command', command) |
| | 603 | client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False) |
| | 604 | |
| | 605 | # setting for KDE |
| | 606 | if path_to_kde_file is not None: # user has run kde at least once |
| | 607 | try: |
| | 608 | f = open(path_to_kde_file, 'a') |
| | 609 | f.write('''\ |
| 642 | | f.close() |
| | 624 | f.close() |
| | 625 | except: |
| | 626 | pass |
| | 627 | |
| | 628 | try: |
| | 629 | import gconf |
| | 630 | # in try because daemon may not be there |
| | 631 | client = gconf.client_get_default() |
| | 632 | except: |
| | 633 | return |
| | 634 | |
| | 635 | old_command = client.get_string('/desktop/gnome/url-handlers/xmpp/command') |
| | 636 | if not old_command or old_command.endswith(' open_chat %s'): |
| | 637 | # first time (GNOME/GCONF) or old Gajim version |
| | 638 | we_set = True |
| | 639 | elif path_to_kde_file is not None and not os.path.exists(path_to_kde_file): |
| | 640 | # only the first time (KDE) |
| | 641 | we_set = True |
| | 642 | else: |
| | 643 | we_set = False |
| | 644 | |
| | 645 | if we_set: |
| | 646 | set_gajim_as_xmpp_handler() |
| | 647 | elif old_command and not old_command.endswith(' handle_uri %s'): |
| | 648 | # xmpp: is currently handled by another program, so ask the user |
| | 649 | pritext = _('Gajim is not the default Jabber client') |
| | 650 | sectext = _('Would you like to make Gajim the default Jabber client?') |
| | 651 | checktext = _('Always check to see if Gajim is the default Jabber client ' |
| | 652 | 'on startup') |
| | 653 | def on_cancel(widget): |
| | 654 | gajim.config.set('check_if_gajim_is_default', |
| | 655 | dlg.checkbutton.get_active()) |
| | 656 | dlg.destroy() |
| | 657 | dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext, |
| | 658 | set_gajim_as_xmpp_handler, on_cancel) |
| | 659 | if gajim.config.get('check_if_gajim_is_default'): |
| | 660 | dlg.checkbutton.set_active(True) |