Exemple #1
0
    def __GetIMEI_UNI(self):
        IMEI = Config.IMEI
        IMEI2 = Config.IMEI2
        UNI = Config.UNI

        self.imeis = MicroChat.GetIMEI()
        print('-' * 5, self.imeis)
        if len(self.imeis) == 0:
            self.imeis.append(IMEI)
            self.imeis.append(IMEI2)
        self.uni = MicroChat.GetUNI()
        if self.uni == '':
            self.uni = UNI
        # self.hashName = MicroChat.GetHash( self.imeis[0], self.uni )
        self.hashName = MicroChat.GetHash('mm', self.uni)
Exemple #2
0
    def __RefreshVoiceList(self, username):
        userHash = MicroChat.GetHash(username, '')[:7]
        # print( userHash, len(self.voiceDic) )
        self.box_voice.Clear()
        if userHash in self.voiceDic:
            voiceList = self.voiceDic[userHash]
            dataList = []
            for f, r in voiceList:
                p = re.compile(
                    r'msg_([0-9a-f]{6})([0-9a-f]{6})([0-9a-f]{7})([0-9a-f]{7}).amr'
                )
                m = p.match(f)
                if m is not None:
                    # print( f )
                    time_str = m.group(1)
                    date_str = m.group(2)
                    user_str = m.group(3)
                    time_text = '%s:%s:%s' % (time_str[2:4], time_str[0:2],
                                              time_str[4:6])
                    date_text = '20%s-%s-%s' % (date_str[4:6], date_str[0:2],
                                                date_str[2:4])
                    dataList.append(['%s %s' % (date_text, time_text), (f, r)])

            def SelFirst(element):
                return element[0]

            dataList.sort(key=SelFirst, reverse=True)
            for text, data in dataList:
                self.box_voice.Append(text, data)
Exemple #3
0
 def __GetPWD(self):
     pwds = []
     imeis, uni = (self.imeis, self.uni)
     for imei in imeis:
         pwd = MicroChat.GetDBPwd(imei, uni)
         pwds.append(pwd)
     return pwds
Exemple #4
0
 def __SetFriends(self, friends):
     self.box_friend.Clear()
     for friend in friends:
         username, alias, nickname, usertype = friend
         userHash = MicroChat.GetHash(username, '')[:7]
         if userHash in self.voiceDic:
             self.box_friend.Append(nickname, friend)
Exemple #5
0
    def __GetContactPath(self, force):
        imeis, uni = (self.imeis, self.uni)

        pwds = self.__GetPWD()
        print('DEBUG:', uni, pwds[0])
        # print( pwds )
        friends = MicroChat.GetContact(pwds[0], uni, force)
        return friends
Exemple #6
0
 def OnToMP3(self, event):
     print('To MP3')
     selist = self.box_voice.GetSelections()
     if len(selist) == 0:
         return
     for amr in selist:
         f, r = self.box_voice.GetClientData(amr)
         amrPath = '%s/%s' % (r, f)
         mp3Path = os.path.splitext(amrPath)[0] + '.mp3'
         if not os.path.exists(mp3Path):
             MicroChat.ConvMP3(amrPath)
Exemple #7
0
    def OnJoinMP3(self, event):
        print('Join MP3')
        selist = self.box_voice.GetSelections()
        if len(selist) < 2:
            return

        files = []
        for amr in selist:
            f, r = self.box_voice.GetClientData(amr)
            amrPath = '%s/%s' % (r, f)
            mp3Path = os.path.splitext(amrPath)[0] + '.mp3'
            if not os.path.exists(mp3Path):
                MicroChat.ConvMP3(amrPath)
            files.append(mp3Path)

        ifriend = self.box_friend.GetSelection()
        friend = self.box_friend.GetClientData(ifriend)
        username, alias, nickname, usertype = friend

        b, r = self.box_voice.GetClientData(selist[0])
        e, r = self.box_voice.GetClientData(selist[-1])
        out_name = 'join_%s_%s%s%s_%s%s%s-%s%s%s_%s%s%s' % (
            nickname,
            b[14:16],
            b[10:12],
            b[12:14],
            b[6:8],
            b[4:6],
            b[8:12],
            e[14:16],
            e[10:12],
            e[12:14],
            e[6:8],
            e[4:6],
            e[8:12],
        )

        MicroChat.JoinMP3(files, out_name)
Exemple #8
0
 def OnSyncVoice(self, event):
     MicroChat.PullVoice(self.hashName)
     self.__RefreshVoiceDic()
     friends = self.__GetContactPath(False)
     if friends != None:
         self.__SetFriends(friends)
Exemple #9
0
 def OnSyncAvatar(self, event):
     MicroChat.PullAvatar(self.hashName)