diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade index 62e7c260a..c8433d6a4 100644 --- a/data/glade/preferences_window.glade +++ b/data/glade/preferences_window.glade @@ -147,17 +147,109 @@ - + True - True - Enable link-local messaging (Zeroconf) - True - GTK_RELIEF_NORMAL - True - False - False - True - + False + 0 + + + + True + True + Enable _link-local messaging (Zeroconf) + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-properties + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Pr_operties + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + True + False + + 0 diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index a5c79a210..ffad96579 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -471,6 +471,7 @@ class ClientZeroconf: BindPortError(port) return None + def getRoster(self): return self.roster.getRoster() diff --git a/src/common/zeroconf/connection_handlers_zeroconf.py b/src/common/zeroconf/connection_handlers_zeroconf.py index 804ad7432..eab7fe3a4 100644 --- a/src/common/zeroconf/connection_handlers_zeroconf.py +++ b/src/common/zeroconf/connection_handlers_zeroconf.py @@ -227,6 +227,7 @@ class ConnectionHandlersZeroconf(ConnectionVcard): idle.init() except: HAS_IDLE = False + def _messageCB(self, ip, con, msg): '''Called when we receive a message''' msgtxt = msg.getBody() diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index c0afab1b9..92d2f0e7a 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -37,6 +37,7 @@ if os.name != 'nt': signal.signal(signal.SIGPIPE, signal.SIG_DFL) import getpass import gobject +import notify from common import helpers from common import gajim @@ -69,7 +70,11 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): #we don't need a password, but must be non-empty self.password = 'zeroconf' - self.privacy_rules_supported = False + #XXX use that somewhere + self.autoconnect = False + self.sync_with_global_status = True + self.no_log_for = False + # Do we continue connection when we get roster (send presence,get vcard...) self.continue_connect_info = None if USE_GPG: @@ -93,6 +98,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): print 'Creating zeroconf account' gajim.config.add_per('accounts', 'zeroconf') gajim.config.set_per('accounts', 'zeroconf', 'autoconnect', True) + gajim.config.set_per('accounts', 'zeroconf', 'no_log_for', False) gajim.config.set_per('accounts', 'zeroconf', 'password', 'zeroconf') gajim.config.set_per('accounts', 'zeroconf', 'sync_with_global_status', True) username = unicode(getpass.getuser()) @@ -106,6 +112,10 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): username = gajim.config.get_per('accounts', 'zeroconf', 'name') host = gajim.config.get_per('accounts', 'zeroconf', 'hostname') port = gajim.config.get_per('accounts', 'zeroconf', 'custom_port') + self.autoconnect = gajim.config.get_per('accounts', 'zeroconf', 'autoconnect') + self.sync_with_global_status = gajim.config.get_per('accounts', 'zeroconf', 'sync_with_global_status') + self.no_log_for = gajim.config.get_per('accounts', 'zeroconf', 'no_log_for') + self.zeroconf = zeroconf.Zeroconf(self._on_new_service, self._on_remove_service, username, host, port) # END __init__ @@ -258,6 +268,10 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): if check: self.dispatch('STATUS', show) else: +# self.dispatch('ERROR', 'Could not change status. Please check if avahi-daemon is running.') + notify.popup(_('Connection problem:'), 'zeroconf', None, + title=_('Could not change status'), + text=_('Please check if avahi-daemon is running.') ) self.dispatch('STATUS', 'offline') def get_status(self): diff --git a/src/common/zeroconf/zeroconf.py b/src/common/zeroconf/zeroconf.py index 8d8a4c2f8..63b4f864a 100755 --- a/src/common/zeroconf/zeroconf.py +++ b/src/common/zeroconf/zeroconf.py @@ -106,8 +106,8 @@ class Zeroconf: return items def service_resolved_callback(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags): - print "Service data for service '%s' in domain '%s' on %i.%i:" % (name, domain, interface, protocol) - print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, avahi.txt_array_to_string_array(txt)) + #print "Service data for service '%s' in domain '%s' on %i.%i:" % (name, domain, interface, protocol) + #print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, avahi.txt_array_to_string_array(txt)) bare_name = name if name.find('@') == -1: name = name + '@' + name @@ -293,7 +293,7 @@ class Zeroconf: self.txt['status'] = self.replace_show(txt['status']) txt = avahi.dict_to_txt_array(self.txt) - if self.entrygroup: + if self.connected and self.entrygroup: self.entrygroup.UpdateServiceTxt(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, dbus.UInt32(0), self.name, self.stype,'', txt, reply_handler=self.service_updated_callback, error_handler=self.print_error_callback) return True else: diff --git a/src/config.py b/src/config.py index eb34cba95..634990584 100644 --- a/src/config.py +++ b/src/config.py @@ -557,8 +557,7 @@ class PreferencesWindow: if gajim.interface.instances.has_key('accounts'): gajim.interface.instances['accounts'].init_accounts() else: - #enable - #gajim.config.add_per('accounts', 'zeroconf') # if not already there (how?) + #enable (will create new account if not present) gajim.connections['zeroconf'] = common.zeroconf.connection_zeroconf.ConnectionZeroconf('zeroconf') # update variables gajim.interface.instances['zeroconf'] = {'infos': {}, 'disco': {}, @@ -590,6 +589,12 @@ class PreferencesWindow: self.on_checkbutton_toggled(widget, 'enable_zeroconf') + def on_zeroconf_properties_button_clicked(self, widget): + if gajim.interface.instances.has_key('zeroconf_properties'): + gajim.interface.instances['zeroconf_properties'].window.present() + else: + gajim.interface.instances['zeroconf_properties'] = \ + ZeroconfPropertiesWindow() def on_show_status_msgs_in_roster_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'show_status_msgs_in_roster') @@ -1168,8 +1173,7 @@ class AccountModificationWindow: def init_account_gpg(self): keyid = gajim.config.get_per('accounts', self.account, 'keyid') keyname = gajim.config.get_per('accounts', self.account, 'keyname') - savegpgpass = gajim.config.get_per('accounts', self.account, - 'savegpgpass') + savegpgpass = gajim.config.get_per('accounts', self.account,'savegpgpass') if not keyid or not gajim.config.get('usegpg'): return @@ -3029,3 +3033,102 @@ _('You can set advanced account options by pressing Advanced button, or later by gajim.interface.roster.draw_roster() gajim.interface.roster.actions_menu_needs_rebuild = True gajim.interface.save_config() + +#---------- ZeroconfPropertiesWindow class -------------# +class ZeroconfPropertiesWindow: + def __init__(self): + self.xml = gtkgui_helpers.get_glade('zeroconf_properties_window.glade') + self.window = self.xml.get_widget('zeroconf_properties_window') + self.window.set_transient_for(gajim.interface.roster.window) + self.xml.signal_autoconnect(self) + + st = gajim.config.get_per('accounts', 'zeroconf', 'autoconnect') + if st: + self.xml.get_widget('autoconnect_checkbutton').set_active(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'no_log_for') + if st: + self.xml.get_widget('log_history_checkbutton').set_active(bool(st)) + + st = gajim.config.get_per('accounts', 'zeroconf', 'sync_with_global_status') + if st: + self.xml.get_widget('sync_with_global_status_checkbutton').set_active(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'first_name') + if st: + self.xml.get_widget('first_name_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'last_name') + if st: + self.xml.get_widget('last_name_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'jabber_id') + if st: + self.xml.get_widget('jabber_id_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'email') + if st: + self.xml.get_widget('email_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'use_tls') + if st: + self.xml.get_widget('use_tls_checkbutton').set_active(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'custom_port') + if st: + self.xml.get_widget('custom_port_entry').set_text(str(st)) + + self.xml.get_widget('custom_port_entry').set_sensitive(True) + + self.xml.get_widget('save_button').grab_focus() + self.window.show_all() + + def on_zeroconf_properties_window_destroy(self, widget): + #close window + if gajim.interface.instances.has_key('zeroconf_properties'): + del gajim.interface.instances['zeroconf_properties'] + + def on_cancel_button_clicked(self, widget): + self.window.destroy() + + def on_save_button_clicked(self, widget): + st = self.xml.get_widget('autoconnect_checkbutton').get_active() + gajim.config.set_per('accounts', 'zeroconf', 'autoconnect', st) + + st = self.xml.get_widget('log_history_checkbutton').get_active() + gajim.config.set_per('accounts', 'zeroconf', 'no_log_for', st) + + st = self.xml.get_widget('sync_with_global_status_checkbutton').get_active() + gajim.config.set_per('accounts', 'zeroconf', 'sync_with_global_status', st) + + st = self.xml.get_widget('custom_port_entry').get_text() + gajim.config.set_per('accounts', 'zeroconf', 'custom_port', st) + + ''' + st = gajim.config.get_per('accounts', 'zeroconf', 'first_name') + if st: + self.xml.get_widget('first_name_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'last_name') + if st: + self.xml.get_widget('last_name_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'jabber_id') + if st: + self.xml.get_widget('jabber_id_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'email') + if st: + self.xml.get_widget('email_entry').set_text(st) + + st = gajim.config.get_per('accounts', 'zeroconf', 'use_tls') + if st: + self.xml.get_widget('use_tls_checkbutton').set_active(st) + + ''' + + self.window.destroy() + + def on_custom_port_checkbutton(self, widget): + pass +