Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
 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
Пример #8
0
 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
Пример #9
0
	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
Пример #10
0
    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
Пример #11
0
    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
Пример #12
0
 def _ft_get_streamhost_jid_attr(self, streamhost):
     return helpers.parse_jid(streamhost.getAttr('jid'))
Пример #13
0
 def _ft_get_streamhost_jid_attr(self, streamhost):
     return helpers.parse_jid(streamhost.getAttr('jid'))