Exemple #1
0
    def _on_connect(self, initial_data):
        self._user_list = yield from hangups.build_user_list(
            self._client, initial_data)

        self._conv_list = hangups.ConversationList(
            self._client, initial_data.conversation_states, self._user_list,
            initial_data.sync_timestamp)
        self._conv_list.on_event.add_observer(self._on_event)
Exemple #2
0
def on_connect(initial_data):
    """Handle connecting for the first time."""
    global client, disable_notifier, conv_list, user_list
    print("Building user list")
    user_list = yield from hangups.build_user_list(
        client, initial_data
    )

    print("Adding contacts")
    for user in sorted(user_list.get_all(), key=lambda u: u.full_name):
        user_data = {
            "id_": user.id_.chat_id,
            "name": user.full_name,
            "first_name": user.first_name,
            "photo_url": "https:" + user.photo_url if user.photo_url else None,
            "emails": user.emails,
        }
        if not user.is_self:
            pyotherside.send('add-contact', user_data)

    print("Creating conversations list")
    conv_list = hangups.ConversationList(
        client, initial_data.conversation_states, user_list,
        initial_data.sync_timestamp
    )
    print("Added conversations oveserver")
    conv_list.on_event.add_observer(on_event)
    if not disable_notifier:
        notifier = Notifier(conv_list)

    convs = sorted(conv_list.get_all(), reverse=True,
                   key=lambda c: c.last_modified)

    print("Showing conversations")
    for conv in convs:
        conv_data = {
            "title": get_conv_name(conv),
            "status_message": "",
            "icon": get_conv_icon(conv),
            "id_": conv.id_,
            "first_message_loaded": False,
            "unread_count": get_unread_messages_count(conv),
            "is_quiet": conv.is_quiet,
            "users": [{
                          "id_": user.id_[0],
                          "full_name": user.full_name,
                          "first_name": user.first_name,
                          "photo_url": "https:" + user.photo_url if user.photo_url else None,
                          "emails": user.emails,
                          "is_self": user.is_self
                      } for user in conv.users]
        }
        pyotherside.send('add-conversation', conv_data)
        ctrl = ConversationController(conv)
        conv_controllers[conv.id_] = ctrl

    pyotherside.send('show-conversations-page')
    def _on_connect(self, initial_data):
        self._user_list = yield from hangups.build_user_list(
            self._client, initial_data)

        self._conv_list = hangups.ConversationList(
            self._client,
            initial_data.conversation_states,
            self._user_list,
            initial_data.sync_timestamp
        )
        self._conv_list.on_event.add_observer(self._on_event)
Exemple #4
0
    def _on_connect(self, initial_data):
        """Handle connecting for the first time"""
        print(_('Connected!'))
        self._retry = 0
        self._user_list = yield from hangups.build_user_list(
            self._client, initial_data)
        self._conv_list = hangups.ConversationList(
            self._client, initial_data.conversation_states, self._user_list,
            initial_data.sync_timestamp)
        self._conv_list.on_event.add_observer(self._on_event)

        print(_('Conversations:'))
        for c in self.list_conversations():
            print('  {} ({})'.format(get_conv_name(c, truncate=True), c.id_))
        print()
Exemple #5
0
 def _on_connect(self, initial_data):
     """Handle connecting for the first time."""
     self._user_list = yield from hangups.build_user_list(
         self._client, initial_data)
     self._conv_list = hangups.ConversationList(
         self._client, initial_data.conversation_states, self._user_list,
         initial_data.sync_timestamp)
     self._conv_list.on_event.add_observer(self._on_event)
     self._notifier = Notifier(self._conv_list)
     # show the conversation menu
     conv_picker = ConversationPickerWidget(self._conv_list,
                                            self.on_select_conversation)
     self._tabbed_window = TabbedWindowWidget(self._keys)
     self._tabbed_window.set_tab(conv_picker,
                                 switch=True,
                                 title='Conversations')
     self._urwid_loop.widget = self._tabbed_window
Exemple #6
0
 def _on_connect(self, initial_data):
     """Handle connecting for the first time."""
     self._user_list = yield from hangups.build_user_list(
         self._client, initial_data
     )
     self._conv_list = hangups.ConversationList(
         self._client, initial_data.conversation_states, self._user_list,
         initial_data.sync_timestamp
     )
     self._conv_list.on_event.add_observer(self._on_event)
     self._notifier = Notifier(self._conv_list)
     # show the conversation menu
     conv_picker = ConversationPickerWidget(self._conv_list,
                                            self.on_select_conversation)
     self._tabbed_window = TabbedWindowWidget(self._keys, self._on_quit)
     self._tabbed_window.set_tab(conv_picker, switch=True,
                                 title='Conversations')
     self._urwid_loop.widget = self._tabbed_window
Exemple #7
0
    def _on_connect(self, initial_data):
        """Handle connecting for the first time"""
        print(_('Connected!'))
        self._user_list = yield from hangups.build_user_list(
            self._client,
            initial_data
        )
        self._conv_list = hangups.ConversationList(
            self._client,
            initial_data.conversation_states,
            self._user_list,
            initial_data.sync_timestamp
        )
        self._conv_list.on_event.add_observer(self._on_event)

        print(_('Conversations:'))
        for c in self.list_conversations():
            print('  {} ({})'.format(get_conv_name(c, truncate=True), c.id_))
        print()
Exemple #8
0
    def _on_connect(self, initial_data):
        """Handle connecting for the first time"""
        # print('Connected!')
        self._retry = 0
        self._user_list = yield from hangups.build_user_list(
            self._client,
            initial_data
        )
        self._conv_list = hangups.ConversationList(
            self._client,
            initial_data.conversation_states,
            self._user_list,
            initial_data.sync_timestamp
        )
        self._conv_list.on_event.add_observer(self._on_event)

        m = api.members.Members
        m.add_client(self, self._id)
        loop = asyncio.get_event_loop()
        m.add_loop(loop, self._id)
Exemple #9
0
    def on_connect(self, initial_data):
        """Handle connecting for the first time (callback)"""
        print('Connected')
        self.user_list = yield from hangups.build_user_list(
            self.client,
            initial_data
        )
        self.conv_list = hangups.ConversationList(
            self.client,
            initial_data.conversation_states,
            self.user_list,
            initial_data.sync_timestamp
        )
        self.conv_list.on_event.add_observer(self.on_event)

        # Setup notifications
        self.notifier = Notifier(self.conv_list)

        # Setup conversations window
        self.messages_dialog.init_conversations(self.client, self.conv_list)

        # Setup conversations list window and show it
        self.conversations_dialog.init_conversations(self.client, self.conv_list)
        self.conversations_dialog.show()
Exemple #10
0
def on_connect(initial_data):
    """Handle connecting for the first time."""
    global client, disable_notifier, conv_list, user_list
    print("Building user list")
    user_list = yield from hangups.build_user_list(client, initial_data)

    print("Adding contacts")
    for user in sorted(user_list.get_all(), key=lambda u: u.full_name):
        user_data = {
            "id_": user.id_.chat_id,
            "name": user.full_name,
            "first_name": user.first_name,
            "photo_url": "https:" + user.photo_url if user.photo_url else None,
            "emails": user.emails,
        }
        if not user.is_self:
            pyotherside.send('add-contact', user_data)

    print("Creating conversations list")
    conv_list = hangups.ConversationList(client,
                                         initial_data.conversation_states,
                                         user_list,
                                         initial_data.sync_timestamp)
    print("Added conversations oveserver")
    conv_list.on_event.add_observer(on_event)
    if not disable_notifier:
        notifier = Notifier(conv_list)

    convs = sorted(conv_list.get_all(),
                   reverse=True,
                   key=lambda c: c.last_modified)

    print("Showing conversations")
    for conv in convs:
        conv_data = {
            "title":
            get_conv_name(conv),
            "status_message":
            "",
            "icon":
            get_conv_icon(conv),
            "id_":
            conv.id_,
            "first_message_loaded":
            False,
            "unread_count":
            get_unread_messages_count(conv),
            "is_quiet":
            conv.is_quiet,
            "users": [{
                "id_":
                user.id_[0],
                "full_name":
                user.full_name,
                "first_name":
                user.first_name,
                "photo_url":
                "https:" + user.photo_url if user.photo_url else None,
                "emails":
                user.emails,
                "is_self":
                user.is_self
            } for user in conv.users]
        }
        pyotherside.send('add-conversation', conv_data)
        ctrl = ConversationController(conv)
        conv_controllers[conv.id_] = ctrl

    pyotherside.send('show-conversations-page')