示例#1
0
文件: imhub.py 项目: sgricci/digsby
def search_for_buddy(metas, convo, sms):
    for win in ImWinPanel.all():
        with traceguard:
            c = win.Conversation

            # already talking to this buddy?
            if c is convo:
                LOG('direct conversation object match: win: %r, convo: %r', win, convo)
                return win

            # is this an SMS message?
            if validate_sms(convo.buddy.name):
                for num in win.SMS:
                    if validate_sms(num):
                        if smsize(num) == smsize(convo.buddy.name):
                            return win

            # chat messages will go only to windows with matching conversation objects.
            if convo.ischat != win.convo.ischat:
                continue

            # is there a window already open talking to another contact in this
            # contact's metacontact?
            winbud = win.Buddy
            if winbud is None:
                continue

            for meta in metas:
                for contact in meta:
                    if winbud == contact:
                        LOG('matched %r with %r', winbud, contact)
                        return win

                # a looser match--one that might not match "From:" but only "To:"
                for contact in meta:
                    if winbud.name == contact.name and winbud.protocol.name == contact.protocol.name:
                        LOG('loosely matched %r with %r', winbud, contact)
                        return win

            if winbud.info_key == convo.buddy.info_key:
                return win
示例#2
0
    def _set_contactsoap(self, val):

        self._contactsoap = val

        if self.contactsoap is not None:
            phs = self.contactsoap.ContactInfo.Phones
            if phs is not None and phs.ContactPhone is not None:
                for phone in phs.ContactPhone:
                    if phone.ContactPhoneType == 'ContactPhoneMobile':
                        try:
                            num = normalize_sms(phone.Number)
                        except:
                            continue
                        else:
                            if not validate_sms(num):
                                continue

                        self.phone_mobile = num
示例#3
0
 def sms(self):
     if validate_sms(self.phone_mobile):
         return self.phone_mobile
     else:
         return False