def request_entity_time(self, jid, resource): if not app.account_is_connected(self._account): return # If we are invisible, do not request if app.is_invisible(self._account): return if resource: jid += '/' + resource iq = nbxmpp.Iq(to=jid, typ='get') iq.addChild('time', namespace=nbxmpp.NS_TIME_REVISED) self._log.info('Requested: %s', jid) self._con.connection.SendAndCallForResponse(iq, self._result_received)
def auto_join_bookmarks(self): if app.is_invisible(self._account): return for jid, bm in self.bookmarks.items(): if bm['autojoin'] in ('1', 'true'): # Only join non-opened groupchats. Opened one are already # auto-joined on re-connection if jid not in app.gc_connected[self._account]: # we are not already connected minimize = bm['minimize'] in ('1', 'true') app.interface.join_gc_room(self._account, jid, bm['nick'], bm['password'], minimize=minimize)
def auto_join_bookmarks(self, bookmarks: Optional[List[Any]] = None) -> None: if app.is_invisible(self._account): return if bookmarks is None: bookmarks = self._bookmarks for bookmark in bookmarks: if bookmark.autojoin: # Only join non-opened groupchats. Opened one are already # auto-joined on re-connection if bookmark.jid not in app.gc_connected[self._account]: # we are not already connected self._log.info('Autojoin Bookmark: %s', bookmark.jid) minimize = app.config.get_per('rooms', bookmark.jid, 'minimize_on_autojoin', True) app.interface.join_gc_room( self._account, str(bookmark.jid), bookmark.nick, bookmark.password, minimize=minimize)
def _avatar_publish_result(self, con, stanza, sha): if stanza.getType() == 'result': current_sha = app.config.get_per('accounts', self._account, 'avatar_sha') if (current_sha != sha and not app.is_invisible(self._account)): if not app.account_is_connected(self._account): return app.config.set_per('accounts', self._account, 'avatar_sha', sha or '') own_jid = self._con.get_own_jid().getStripped() app.contacts.set_avatar(self._account, own_jid, sha) self._con.get_module('VCardAvatars').send_avatar_presence( force=True) log.info('%s: Published: %s', self._account, sha) app.nec.push_incoming_event( VcardPublishedEvent(None, conn=self._con)) elif stanza.getType() == 'error': app.nec.push_incoming_event( VcardNotPublishedEvent(None, conn=self._con))
def _avatar_publish_result(self, _con, stanza, sha): if stanza.getType() == 'result': current_sha = app.config.get_per('accounts', self._account, 'avatar_sha') if (current_sha != sha and not app.is_invisible(self._account)): if not app.account_is_connected(self._account): return app.config.set_per('accounts', self._account, 'avatar_sha', sha or '') own_jid = self._con.get_own_jid().getStripped() app.contacts.set_avatar(self._account, own_jid, sha) app.interface.update_avatar( self._account, self._con.get_own_jid().getStripped()) self._con.get_module('VCardAvatars').send_avatar_presence( after_publish=True) self._log.info('%s: Published: %s', self._account, sha) self._con.get_module('MUC').update_presence() app.nec.push_incoming_event( NetworkEvent('vcard-published', account=self._account)) elif stanza.getType() == 'error': app.nec.push_incoming_event( NetworkEvent('vcard-not-published', account=self._account))
def _on_join_clicked(self, *args): account = self.account_combo.get_active_id() nickname = self.nick_entry.get_text() if app.is_invisible(account): app.interface.raise_dialog('join-while-invisible') return server = self.server_combo.get_active_text() room = self.room_entry.get_text() if room == '': ErrorDialog(_('Invalid Group Chat'), _('Please choose a group chat'), transient_for=self) return self.room_jid = '%s@%s' % (room, server) try: self.room_jid = helpers.parse_jid(self.room_jid) except helpers.InvalidFormat as error: ErrorDialog(_('Invalid XMPP Address'), str(error), transient_for=self) return if app.in_groupchat(account, self.room_jid): # If we already in the groupchat, join_gc_room will bring # it to front app.interface.join_gc_room(account, self.room_jid, nickname, '') self.destroy() return if nickname == '': ErrorDialog(_('Invalid Nickname'), _('Please choose a nickname'), transient_for=self) return try: helpers.parse_resource(nickname) except helpers.InvalidFormat as error: ErrorDialog(_('Invalid Nickname'), str(error), transient_for=self) return if not app.account_is_connected(account): ErrorDialog( _('You are not connected to the server'), _('You can not join a group chat unless you are connected.'), transient_for=self) return password = self.password_entry.get_text() self._add_bookmark(account, nickname, password) app.add_recent_groupchat(account, self.room_jid, nickname) if self.automatic: app.automatic_rooms[self.account][self.room_jid] = self.automatic app.interface.join_gc_room(account, self.room_jid, nickname, password) self.destroy()