#!/usr/bin/python import inbox, os, appuifw from codecs import open from time import * from string import * ################################# # # # Versione 0.4 # # By Neon (neon@kerneler.org) # # # # Released under GPL2 # # # # http://www.kerneler.org # # # ################################# appuifw.app.title = u"SmsBackuper" print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" #inizializzo lista di sms inb = inbox.Inbox() msgs = inb.sms_messages() #rivolto la lista degli sms per far si che l'ordine cronologico abbia senso msgs.reverse() #salvo il giorno e l'ora correnti nowd = ctime()[8] + ctime()[9] nowm = ctime()[4] + ctime()[5] + ctime()[6] no = len(msgs) #domande per gli sms e schermata durante utilizzo appuifw.note(u"Attendere...\nSalvataggio in corso!\nwww.kerneler.org","info") #eseguo il controllo che le cartelle necessarie siano tutte presenti if not os.path.isdir("e:\sms"): os.mkdir("e:\sms") if not os.path.isdir("e:\sms\people"): os.mkdir("e:\sms\people") for msg in msgs: #vars smsda = ctime(inb.time(msg))[8] + ctime(inb.time(msg))[9] smsmo = ctime(inb.time(msg))[4] + ctime(inb.time(msg))[5] + ctime(inb.time(msg))[6] smsye = ctime(inb.time(msg))[20] + ctime(inb.time(msg))[21] + ctime(inb.time(msg))[22] + ctime(inb.time(msg))[23] body=inb.content(msg) address=inb.address(msg) #levo le accentate address = replace(address,u"à","a") address = replace(address,u"è","e") address = replace(address,u"ì","i") address = replace(address,u"ò","o") address = replace(address,u"ù","u") #controllo cartelle if not os.path.isdir("e:\sms\\" + smsmo + " " + smsye): os.mkdir("e:\sms\\" + smsmo + " " + smsye) #salvo per giorno f = open("e:\sms\\" + smsmo + " " + smsye + "\\" + smsda + ".txt","a","utf-8") f.write("From: " + address + "\n" + ctime(inb.time(msg)) + "\n\n" + body + "\n\n\n") f.close() #salvo per mittente g = open("e:\sms\people\\" + address + ".txt","a","utf-8") g.write("" + ctime(inb.time(msg)) + "\n\n" + body + "\n\n\n") g.close() #aggiorno count #cancellazione sms cancellasms=appuifw.query(u"Vuoi cancellare tutti i messaggi salvati?","query") if cancellasms==1: appuifw.note(u"Attendere...\nCancellazione in corso!\nwww.kerneler.org","info") for msg in msgs: inb.delete(msg) #schermata finale appuifw.note(u"Fatto! Archiviati " + repr(no) + " messaggi.","conf")