def _get_current_status_data(self): ''' Gathers status/pep data for a given account or checks if all accounts are synchronized. If not, no status message/pep data will be displayed. ''' if self.account: client = app.get_client(self.account) self._status_message = client.status_message activity_data = client.get_module( 'UserActivity').get_current_activity() mood_data = client.get_module('UserMood').get_current_mood() if activity_data: self._pep_dict['activity'] = activity_data.activity self._pep_dict['subactivity'] = activity_data.subactivity if mood_data: self._pep_dict['mood'] = mood_data.mood else: status_messages = [] activities = [] subactivities = [] moods = [] for account in app.connections: client = app.get_client(account) if not app.settings.get_account_setting( client.account, 'sync_with_global_status'): continue status_messages.append(client.status_message) activity_data = client.get_module( 'UserActivity').get_current_activity() mood_data = client.get_module('UserMood').get_current_mood() if activity_data: activities.append(activity_data.activity) subactivities.append(activity_data.subactivity) if mood_data: moods.append(mood_data.mood) equal_messages = all(x == status_messages[0] for x in status_messages) equal_activities = all(x == activities[0] for x in activities) equal_subactivities = all(x == subactivities[0] for x in subactivities) equal_moods = all(x == moods[0] for x in moods) if status_messages and equal_messages: self._status_message = status_messages[0] if activities and equal_activities: self._pep_dict['activity'] = activities[0] if subactivities and equal_subactivities: self._pep_dict['subactivity'] = subactivities[0] if moods and equal_moods: self._pep_dict['mood'] = moods[0]
def __init__(self, account): Assistant.__init__(self) self.account = account self._client = app.get_client(account) self._destroyed = False self.add_button('apply', _('Change'), 'suggested-action', complete=True) self.add_button('close', _('Close')) self.add_button('back', _('Back')) self.add_pages({'password': EnterPassword(), 'next_stage': NextStage(), 'error': Error(), 'success': Success()}) progress = self.add_default_page('progress') progress.set_title(_('Changing Password...')) progress.set_text(_('Trying to change password...')) self.connect('button-clicked', self._on_button_clicked) self.connect('destroy', self._on_destroy) self.show_all()
def get_group_chat_nick(account, room_jid): nick = app.nicks[account] client = app.get_client(account) bookmark = client.get_module('Bookmarks').get_bookmark(room_jid) if bookmark is not None: if bookmark.nick is not None: nick = bookmark.nick return nick
def preconditions_met(self): try: client = app.get_client(self._account) except Exception: return False if self._from_muc: muc = client.get_module('MUC').get_manager().get( self.entity.jid.bare) if muc is None or not muc.state.is_joined: self.set_obsolete() return False return client.state.is_available
def _send_user_mood(self): mood = None if self._ui.mood_switch.get_active(): mood = self._pep_dict['mood'] if self.account is None: for client in app.get_available_clients(): if not app.settings.get_account_setting( client.account, 'sync_with_global_status'): continue client.set_user_mood(mood) else: client = app.get_client(self.account) client.set_user_mood(mood)
def _send_user_activity(self): activity = None if self._ui.activity_switch.get_active(): activity = (self._pep_dict['activity'], self._pep_dict['subactivity']) if self.account is None: for client in app.get_available_clients(): if not app.settings.get_account_setting( client.account, 'sync_with_global_status'): continue client.set_user_activity(activity) else: client = app.get_client(self.account) client.set_user_activity(activity)
def __init__(self, account, jid=None): Assistant.__init__(self, width=600, height=500) self._destroyed = False self._client = app.get_client(account) self._account = account self._jid = jid self.add_button('complete', _('Complete'), complete=True, css_class='suggested-action') self.add_button('next', _('Next'), complete=True, css_class='suggested-action') self.add_button('prev', _('Previous')) self.add_button('cancel', _('Cancel'), css_class='destructive-action') self.add_button('commands', _('Commands'), css_class='suggested-action') self.add_button('execute', _('Execute'), css_class='suggested-action') self.add_pages({ 'request': RequestCommandList(), 'commands': Commands(), 'stage': Stage(), 'completed': Completed(), 'error': Error(), 'executing': Executing(), }) self.get_page('commands').connect('execute', self._on_execute) self.connect('button-clicked', self._on_button_clicked) self.connect('destroy', self._on_destroy) self._client.get_module('AdHocCommands').request_command_list( jid, callback=self._received_command_list) self.show_all()
def __init__(self, account): Assistant.__init__(self) self.account = account try: self._client = app.get_client(account) except KeyError: self._client = None self._destroyed = False self._account_removed = False self.add_button('remove', _('Remove'), 'destructive-action') self.add_button('close', _('Close')) self.add_button('back', _('Back')) self.add_pages({ 'remove_choice': RemoveChoice(account), 'error': Error(), 'success': Success() }) progress = self.add_default_page('progress') progress.set_title(_('Removing Account...')) progress.set_text(_('Trying to remove account...')) self.connect('button-clicked', self._on_button_clicked) self.connect('destroy', self._on_destroy) self.register_events([ ('account-connected', ged.GUI1, self._on_account_connected), ('account-disconnected', ged.GUI1, self._on_account_disconnected), ]) self._set_remove_from_server_checkbox() self.show_all()
def disco(self): client = app.get_client(self.account) if not client.state.is_available: return client.get_module('Discovery').disco_contact(self.contact)
def __init__(self, account, *args): Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) self.set_show_menubar(False) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.set_resizable(True) self.set_default_size(700, 600) self.set_name('ProfileWindow') self.set_title(_('Profile')) self.account = account self._jid = app.get_jid_from_account(account) self._ui = get_builder('profile.ui') menu = Gio.Menu() for action, label in MENU_DICT.items(): menu.append(label, 'win.add-' + action.lower()) self._ui.add_entry_button.set_menu_model(menu) self._add_actions() self._avatar_selector = None self._current_avatar = None self._current_vcard = None self._avatar_nick_public = None # False - no change to avatar # None - we want to delete the avatar # Avatar - upload new avatar self._new_avatar = False self._ui.nickname_entry.set_text(app.nicks[account]) self._vcard_grid = VCardGrid(self.account) self._ui.profile_box.add(self._vcard_grid) self.add(self._ui.profile_stack) self.show_all() self._load_avatar() client = app.get_client(account) client.get_module('VCard4').request_vcard( callback=self._on_vcard_received) client.get_module('PubSub').get_access_model( Namespace.VCARD4_PUBSUB, callback=self._on_access_model_received, user_data=Namespace.VCARD4_PUBSUB) client.get_module('PubSub').get_access_model( Namespace.AVATAR_METADATA, callback=self._on_access_model_received, user_data=Namespace.AVATAR_METADATA) client.get_module('PubSub').get_access_model( Namespace.AVATAR_DATA, callback=self._on_access_model_received, user_data=Namespace.AVATAR_DATA) client.get_module('PubSub').get_access_model( Namespace.NICK, callback=self._on_access_model_received, user_data=Namespace.NICK) self._ui.connect_signals(self) self.connect('key-press-event', self._on_key_press_event)
def get_account_location_icon_name(account): client = app.get_client(account) location = client.get_module('UserLocation').get_current_location() return None if location is None else 'applications-internet'
def get_account_tune_icon_name(account): client = app.get_client(account) tune = client.get_module('UserTune').get_current_tune() return None if tune is None else 'audio-x-generic'
def get_account_activity_icon_name(account): client = app.get_client(account) activity = client.get_module('UserActivity').get_current_activity() if activity is None: return None return get_activity_icon_name(activity.activity, activity.subactivity)
def get_account_mood_icon_name(account): client = app.get_client(account) mood = client.get_module('UserMood').get_current_mood() return f'mood-{mood.mood}' if mood is not None else mood
def _on_account_connected(self, _event): self._client = app.get_client(self.account) self._set_remove_from_server_checkbox()