def is_valid(self): if self.value: try: helpers.parse_jid(self.value) return True except: return False if self.required: return False return True
def is_valid(self): if len(self.values): for value in self.values: try: helpers.parse_jid(value) except: return False return True if self.required: return False return True
def open_chat(self, jid, account, message): """ Shows the tabbed window for new message to 'jid', using account (optional) 'account' """ if not jid: raise dbus_support.MissingArgument() jid = self._get_real_jid(jid, account) try: jid = helpers.parse_jid(jid) except Exception: # Jid is not conform, ignore it return DBUS_BOOLEAN(False) minimized_control = None if account: accounts = [account] else: accounts = gajim.connections.keys() if len(accounts) == 1: account = accounts[0] connected_account = None first_connected_acct = None for acct in accounts: if gajim.connections[acct].connected > 1: # account is online contact = gajim.contacts.get_first_contact_from_jid(acct, jid) if gajim.interface.msg_win_mgr.has_window(jid, acct): connected_account = acct break # jid is in roster elif contact: minimized_control = \ jid in gajim.interface.minimized_controls[acct] connected_account = acct break # we send the message to jid not in roster, because account is # specified, or there is only one account elif account: connected_account = acct elif first_connected_acct is None: first_connected_acct = acct # if jid is not a conntact, open-chat with first connected account if connected_account is None and first_connected_acct: connected_account = first_connected_acct if minimized_control: gajim.interface.roster.on_groupchat_maximized( None, jid, connected_account) if connected_account: gajim.interface.new_chat_from_jid(connected_account, jid, message) # preserve the 'steal focus preservation' win = gajim.interface.msg_win_mgr.get_window( jid, connected_account).window if win.get_property('visible'): win.window.focus(Gtk.get_current_event_time()) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False)
def open_chat(self, jid, account, message): """ Shows the tabbed window for new message to 'jid', using account (optional) 'account' """ if not jid: raise dbus_support.MissingArgument() jid = self._get_real_jid(jid, account) try: jid = helpers.parse_jid(jid) except Exception: # Jid is not conform, ignore it return DBUS_BOOLEAN(False) minimized_control = None if account: accounts = [account] else: accounts = gajim.connections.keys() if len(accounts) == 1: account = accounts[0] connected_account = None first_connected_acct = None for acct in accounts: if gajim.connections[acct].connected > 1: # account is online contact = gajim.contacts.get_first_contact_from_jid(acct, jid) if gajim.interface.msg_win_mgr.has_window(jid, acct): connected_account = acct break # jid is in roster elif contact: minimized_control = \ jid in gajim.interface.minimized_controls[acct] connected_account = acct break # we send the message to jid not in roster, because account is # specified, or there is only one account elif account: connected_account = acct elif first_connected_acct is None: first_connected_acct = acct # if jid is not a conntact, open-chat with first connected account if connected_account is None and first_connected_acct: connected_account = first_connected_acct if minimized_control: gajim.interface.roster.on_groupchat_maximized(None, jid, connected_account) if connected_account: gajim.interface.new_chat_from_jid(connected_account, jid, message) # preserve the 'steal focus preservation' win = gajim.interface.msg_win_mgr.get_window(jid, connected_account).window if win.get_property('visible'): win.window.focus(Gtk.get_current_event_time()) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False)
def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, treeview, model, field): old = model[path][0] if old == newtext: return try: newtext = helpers.parse_jid(newtext) except helpers.InvalidFormat, s: dialogs.ErrorDialog(_('Invalid Jabber ID'), str(s)) return
def on_subscribe_button_clicked(self, widget): '''When Subscribe button is clicked''' jid = self.jid_entry.get_text().decode('utf-8') nickname = self.nickname_entry.get_text().decode('utf-8') if not jid: return # check if jid is conform to RFC and stringprep it try: jid = helpers.parse_jid(jid) except helpers.InvalidFormat, s: pritext = _('Invalid User ID') ErrorDialog(pritext, str(s)).get_response() return
def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, treeview, model, field): old = model[path][0] if old == newtext: return try: newtext = helpers.parse_jid(newtext) except helpers.InvalidFormat as s: dialogs.ErrorDialog(_('Invalid Jabber ID'), str(s)) return if newtext in field.values: dialogs.ErrorDialog( _('Jabber ID already in list'), _('The Jabber ID you entered is already in the list. Choose another one.')) GLib.idle_add(treeview.set_cursor, path) return model[path][0]=newtext values = field.values values[values.index(old)]=newtext field.values = values
def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, treeview, model, field): old = model[path][0] if old == newtext: return try: newtext = helpers.parse_jid(newtext) except helpers.InvalidFormat as s: dialogs.ErrorDialog(_('Invalid JID'), str(s)) return if newtext in field.values: dialogs.ErrorDialog( _('JID already in list'), _('The JID you entered is already in the list. Choose another one.' )) GLib.idle_add(treeview.set_cursor, path) return model[path][0] = newtext values = field.values values[values.index(old)] = newtext field.values = values
def _ft_get_streamhost_jid_attr(self, streamhost): return helpers.parse_jid(streamhost.getAttr('jid'))