Beispiel #1
0
    def _send_message(self, message, auto=False, callback=None, **options):
        '''
        Sends an instant message to the buddy this conversation is chatting
        with.
        '''
        network_msg = message.format_as('yahoo')
        network_msg = network_msg.encode('utf-8')

        d = {
            ykeys['message']: network_msg,
            ykeys['msg_encoding']: '1',  #1==utf-8, which we just encoded it as
        }

        import YahooProtocol
        servicekey = YahooProtocol.PROTOCOL_CODES.get(self.buddy.service, None)
        if servicekey is not None:  #if this follows the rest of the api, this is the right thing to do
            d[ykeys['buddy_service']] = servicekey

        log.info('Sending message to %r. buddy_service=%r', self.buddy,
                 self.buddy.service == 'msn')

        try:
            self.protocol.send('message', 'offline', dictadd(self.to_from, d))
        except Exception, e:
            callback.error(e)
Beispiel #2
0
 def _send_message(self, message):
     log.info_s('send_message for %r: %s', self, message)
     self.protocol.send('comment', 'available', dictadd(dict(
         frombuddy = self.myname,
         room_name = self.name,
         chat_message = message.format_as('yahoo')),
         {'124':'1'})
     )
Beispiel #3
0
 def _send_message(self, message):
     log.info_s('send_message for %r: %s', self, message)
     self.protocol.send(
         'comment', 'available',
         dictadd(
             dict(frombuddy=self.myname,
                  room_name=self.name,
                  chat_message=message.format_as('yahoo')), {'124': '1'}))
Beispiel #4
0
    def update_view(self):

        #from common.notifications import set_active
        #set_active(get_notifications())

        notifications, contact = self.notifications, self.for_contact
        if contact is not None:
            contact = contact.idstr()
            contactobj = contact

        showing_contacts = True
        already_added, root = [], []

        gnots = {} if None not in notifications else notifications[None]

        for topic, notif in get_notification_info().iteritems():
            events, desc = [], notif['description']

            if contact is None:
                if topic in gnots:
                    p = deepcopy(gnots[topic])
                    events.extend(p)

                # Grab events for contacts (maybe)
                if showing_contacts:
                    for subcontact in (set(notifications.keys()) - set([None])):
                        if subcontact in self.notifications:
                            if topic in self.notifications[subcontact]:
                                c_events = deepcopy(notifications[subcontact][topic])
                                if c_events:
                                    events.extend([(dictadd({'contact': subcontact}, e))
                                                   for e in c_events])

                if events:
                    already_added += [topic]
                    root.append(ActionEntry(topic, events,
                                            description = desc,
                                            icon_skinpath = notif.get('notification_icon', None)))
            else:
                if contact in notifications:
                    if topic in notifications[contact]:
                        events = deepcopy(notifications[contact][topic])
                        if events:
                            already_added += [topic]
                            root.append(ActionEntry(topic, events,
                                                    description = desc,
                                                    icon_skinpath = notif.get('notification_icon', None)))



        # Add event categories with no events set
        for topic, notif in get_notification_info().iteritems():
            if not topic in already_added:
                root.append(ActionEntry(topic,
                                        description = notif['description'],
                                        icon_skinpath = notif.get('notification_icon', None)))
        self.set_root(root)
Beispiel #5
0
    def filtered_prefs(self, substr=""):
        sum = dictadd(self.defaults, self.prefs)

        # find all keys not containing substr
        substr = substr.lower()
        remove_these_keys = [key for key in sum if key.lower().find(substr) == -1]

        # remove them
        for key in remove_these_keys:
            sum.pop(key)

        return sum
Beispiel #6
0
    def update_blob(self, name, useful_data):
        if name == 'prefs':

            log.critical('prefs updated from the network')

            with self.prefs.flagged('network'):
                if 'defaultprefs' not in self.blob_manager.waiting_blobs:
                    new_prefs = dictadd(self.defaultprefs, useful_data)
                    self.prefs.update(new_prefs)
                else:
                    self.prefs.update(useful_data)
                    new_prefs = useful_data
                if hasattr(self, 'defaultprefs'):
                    for key in set(self.prefs.keys()) - (set(new_prefs.keys()) | set(self.defaultprefs.keys())):
                        self.prefs.pop(key, None)

            self.prefs_loaded = True
            hooks.notify('blobs.update.prefs', self.prefs)

        elif name == 'defaultprefs':
            if 'prefs' not in self.blob_manager.waiting_blobs:
                new_prefs = dictadd(useful_data, self.prefs)
                self.prefs.update(new_prefs)
                if hasattr(self, 'defaultprefs'):
                    for key in set(self.defaultprefs.keys()) - set(useful_data.keys()):
                        self.prefs.pop(key, None)
            self.defaultprefs.update(useful_data)

        elif name == 'buddylist':
            self.blist.update_data(useful_data)

        elif callable(getattr(self, '_incoming_blob_' + name, None)):
            getattr(self, '_incoming_blob_' + name)(useful_data)

        else:
            log.critical('replacing profile attribute %s', name)
            if name == 'statuses':
                assert False
            setattr(self, name, observable_type(useful_data))
Beispiel #7
0
    def filtered_prefs(self, substr=""):
        sum = dictadd(self.defaults, self.prefs)

        # find all keys not containing substr
        substr = substr.lower()
        remove_these_keys = [
            key for key in sum if key.lower().find(substr) == -1
        ]

        # remove them
        for key in remove_these_keys:
            sum.pop(key)

        return sum
Beispiel #8
0
    def _send_message(self, message, auto = False, callback=None, **options):
        '''
        Sends an instant message to the buddy this conversation is chatting
        with.
        '''
        network_msg = message.format_as('yahoo')
        network_msg = network_msg.encode('utf-8')

        d = {
             ykeys['message']: network_msg,
             ykeys['msg_encoding']: '1', #1==utf-8, which we just encoded it as
             }

        import YahooProtocol
        servicekey = YahooProtocol.PROTOCOL_CODES.get(self.buddy.service, None)
        if servicekey is not None: #if this follows the rest of the api, this is the right thing to do
            d[ykeys['buddy_service']] = servicekey

        log.info('Sending message to %r. buddy_service=%r', self.buddy, self.buddy.service=='msn')

        try:
            self.protocol.send('message', 'offline', dictadd(self.to_from, d))
        except Exception, e:
            callback.error(e)
Beispiel #9
0
    def update_view(self):

        #from common.notifications import set_active
        #set_active(get_notifications())

        notifications, contact = self.notifications, self.for_contact
        if contact is not None:
            contact = contact.idstr()
            contactobj = contact

        showing_contacts = True
        already_added, root = [], []

        gnots = {} if None not in notifications else notifications[None]

        for topic, notif in get_notification_info().iteritems():
            events, desc = [], notif['description']

            if contact is None:
                if topic in gnots:
                    p = deepcopy(gnots[topic])
                    events.extend(p)

                # Grab events for contacts (maybe)
                if showing_contacts:
                    for subcontact in (set(notifications.keys()) -
                                       set([None])):
                        if subcontact in self.notifications:
                            if topic in self.notifications[subcontact]:
                                c_events = deepcopy(
                                    notifications[subcontact][topic])
                                if c_events:
                                    events.extend([
                                        (dictadd({'contact': subcontact}, e))
                                        for e in c_events
                                    ])

                if events:
                    already_added += [topic]
                    root.append(
                        ActionEntry(topic,
                                    events,
                                    description=desc,
                                    icon_skinpath=notif.get(
                                        'notification_icon', None)))
            else:
                if contact in notifications:
                    if topic in notifications[contact]:
                        events = deepcopy(notifications[contact][topic])
                        if events:
                            already_added += [topic]
                            root.append(
                                ActionEntry(topic,
                                            events,
                                            description=desc,
                                            icon_skinpath=notif.get(
                                                'notification_icon', None)))

        # Add event categories with no events set
        for topic, notif in get_notification_info().iteritems():
            if not topic in already_added:
                root.append(
                    ActionEntry(topic,
                                description=notif['description'],
                                icon_skinpath=notif.get(
                                    'notification_icon', None)))
        self.set_root(root)