一个字节的错误七十二小时的徒劳………… 需要的友友请联系 wenwu500@qq.com 支持塞班第三版手机使用,附上你的msg.info文件。 #Encoding:UTF-8 #FileName:InsertMobileQQ2008MsgIntoMobileQQ2009.py #Date:2009_10_19 #假如有错误,请联系我:wenwu500@qq.com from time import mktime from appuifw import query,note from os import makedirs def de16(s): return s.decode("UTF-16") def de8(s): return s.decode("UTF-8") def buildtime(s): s=de16(s) x="%x" %long(mktime((int("20"+s[:2]),int(s[3:5]),int(s[6:8]),int(s[9:11]),int(s[12:14]),int(s[15:17]),5,290,-1))) t=chr(eval("0x"+x[0:2]))+chr(eval("0x"+x[2:4]))+chr(eval("0x"+x[4:6]))+chr(eval("0x"+x[6:8])) del x return t def insert(fin,fout): f=file(fin) try : T=file(fout,"a") except : makedirs(fout[:-8]) T=file(fout,"a") ni,re=getName(f) f.seek(0) mark2008=f.read(2) mark="/xa8" blank="/x00"*6 while 1: c=f.read(8) if not c : del c break del c time=f.read(34) f.read(2) name=f.read(32).replace("/x00/x00","") if (ni and re)==name : flag="/x80" else : flag="/x00" data="" i=-2 while 1 : c=f.read(2) i+=2 if not c : T.write(mark+chr(i)+buildtime(time)+blank+flag+data+mark+chr(i)) print de16(name),de16(time) print de16(data) del c break elif mark2008!=c : data+=c elif mark2008==c : T.write(mark+chr(i)+buildtime(time)+blank+flag+data+mark+chr(i)) print de16(name),de16(time) print de16(data) del c,name,data,time,i,flag break T.close() f.close() del f,T,ni,re,mark2008,mark,blank def getName(f): f.read(46) re=f.read(32).replace("/x00/x00","") return query(de16(re)+de8(" 是你的昵称吗?"),"query"),re def begin(): path=manager().AskUser("c:/data/",ext=[".db"]) temp=path.split("//") o=str(temp[3]) t=str(temp[-1][:-6]) del temp if (-1==path.find("QQ")) : note(de8("选择错误/n⊙﹏⊙"),"error") else : pathto="c:/system/data/tencent/QQ/"+o+"/"+t+"/msg.info" insert(path,pathto) del t,path,pathto,o if query(de8("继续导入与其他好友的聊天记录?"),"query") : begin() else : print "-"*30 class manager: #copy the powlite_fm __module__ = __name__ def __s2d(s, x): res = '' x = x.lower() for i in range(len(x)): ind = s.alphabet.find(x[i]) if (ind == -1): res += '1' else: res += s.numaplhabet[ind] return res def ru(s, x): return x.decode('utf-8') def ur(s, x): return x.encode('utf-8') def __init__(s): import appuifw import os import e32 (s.appuifw, s.os, s.e32,) = (appuifw, os, e32) s.lock = s.e32.Ao_lock() s.curdir = None s.marknum = 0 s.selectfile = [] s.txt = '' s.alphabet = s.ru('abcdefghijklmnopqrstuvwxyz/xd0/xb0/xd0/xb1/xd0/xb2/xd0/xb3/xd0/xb4/xd0/xb5/xd1/x91/xd0/xb6/xd0/xb7/xd0/xb8/xd0/xb9/xd0/xba/xd0/xbb/xd0/xbc/xd0/xbd/xd0/xbe/xd0/xbf/xd1/x80/xd1/x81/xd1/x82/xd1/x83/xd1/x84/xd1/x85/xd1/x86/xd1/x87/xd1/x88/xd1/x89/xd1/x8c/xd1/x8b/xd1/x8a/xd1/x8d/xd1/x8e/xd1/x8f1234567890 ') s.numaplhabet = u'2223334445556667777888999922223333344445555666677778888999912345678900' def AskUser(s, path = None, find = 'file', ext = [], soundmod = False, markmod = False): s.soundmod = soundmod s.markmod = markmod if s.soundmod: import audio import keycapture (s.audio, s.keycapture,) = (audio, keycapture) s.capturer = s.keycapture.KeyCapturer(s.keycap) s.capturer.forwarding = 0 s.capturer.keys = s.keycapture.all_keys s.workitem = s.ru('/xe8/xaf/xb7/xe7/xa8/x8d/xe5/x80/x99...') s.backitem = u'<<<' if ((path == None) and ((s.curdir != None) and (s.curdir != u'root'))): path = s.os.path.split(s.curdir)[0] if (path[-1] != '//'): path += '//' s.oldscreen = s.appuifw.app.screen s.oldbody = s.appuifw.app.body s.oldexitkeyhandler = s.appuifw.app.exit_key_handler s.oldmenu = s.appuifw.app.menu s.oldtitle = s.appuifw.app.title try: s.oldfocus = s.appuifw.app.body.focus s.appuifw.app.body.focus = False except: pass if (find == 'dir'): s.appuifw.app.title = s.title = s.ru('/xe9/x80/x89/xe6/x8b/xa9/xe7/x9b/xae/xe5/xbd/x95') else: s.appuifw.app.title = s.title = s.ru('/xe9/x80/x89/xe6/x8b/xa9/xe6/x96/x87/xe4/xbb/xb6') (s.find, s.ext,) = (find, ext) s.appuifw.app.screen = 'normal' s.appuifw.app.bo