#!/usr/bin/python import inbox, os, appuifw, sys from codecs import open from time import * from string import * ################################# # # Versione 0.5 # By Neon (neon@kerneler.org) # # Released under GPL2 # # http://www.kerneler.org # ################################# appuifw.app.title = u"SmsBackuper" appuifw.app.screen='full' if not os.path.isdir("e:\sms"): appuifw.note(u"Benvenuto!\nEcco alcuni consigli per usare al meglio smsBackuper!","info") appuifw.note(u"1) Non accumulare troppi sms ma usare periodicamente il programma. In questo modo sara' molto veloce!","info") appuifw.note(u"2) Aumentare il numero degli sms archiviati nel menu symbian dei messaggi (se non l'hai gia' fatto)","info") appuifw.note(u"3) Non usarlo quando la batteria e' scarica perche' essendo un processo che usa molto sia cpu che memoria puo' consumarne molta","info") appuifw.note(u"4) Gli sms salvati saranno disponibili sulla \\memoria di massa\sms\ ","info") #menu di scelta Lista=[u"Archivia e Cancella",u"Archivia",u"Cancella",u"Esci"] scelta = None while not scelta == 0 and not scelta == 1 and not scelta == 2 and not scelta == 3: scelta=appuifw.selection_list(Lista,search_field=1) if scelta == 3: sys.exit() print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nsmsBackuper\n\nBy Neon\n\nhttp://www.kerneler.org\n\n\n\n\n\n\n\n\n\n\n\n" #salvo il giorno e l'ora correnti nowd = ctime()[8] + ctime()[9] nowm = ctime()[4] + ctime()[5] + ctime()[6] numsaved = float(0) numdeleted = float(0) counter = 0 ########## # BLOCCO DI ARCHIVIAZIONE ### ########## if scelta==0 or scelta==1: #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") if not os.path.isdir("e:\sms\sent"): os.mkdir("e:\sms\sent") if not os.path.isdir("e:\sms\sent\people"): os.mkdir("e:\sms\sent\people") #domande per gli sms e schermata durante utilizzo appuifw.note(u"Attendere...\nSalvataggio in corso!\nwww.kerneler.org","info") appuifw.note(u"Attendere...\nSalvati 0% ricevuti","info") #inizializzo lista di sms inb = inbox.Inbox() msgs = inb.sms_messages() no = float(len(msgs)) #rivolto la lista degli sms per far si che l'ordine cronologico abbia senso msgs.reverse() 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 numsaved = numsaved + 1 counter = counter + 1 #ogni 20 sms mostra l'avviso di che percentuale si è raggiunta if counter == 10: percentuale = (numsaved/no)*100 appuifw.note(u"Attendere...\nSalvati " + repr(int(percentuale))+"% ricevuti","info") counter = 0 appuifw.note(u"Attendere...\nSalvati 0% inviati","info") #inizializzo lista di sms inb = inbox.Inbox(inbox.ESent) msgs = inb.sms_messages() no = float(len(msgs)) #riazzero variabili numsaved = float(0) numdeleted = float(0) counter = 0 #rivolto la lista degli sms per far si che l'ordine cronologico abbia senso msgs.reverse() 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\sent\\" + smsmo + " " + smsye): os.mkdir("e:\sms\sent\\" + smsmo + " " + smsye) #salvo per giorno f = open("e:\sms\sent\\" + 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\sent\people\\" + address + ".txt","a","utf-8") g.write("" + ctime(inb.time(msg)) + "\n\n" + body + "\n\n\n") g.close() #aggiorno count numsaved = numsaved + 1 counter = counter + 1 #ogni 20 sms mostra l'avviso di che percentuale si è raggiunta if counter == 10: percentuale = (numsaved/no)*100 appuifw.note(u"Attendere...\nSalvati " + repr(int(percentuale))+"% inviati","info") counter = 0 ########## # BLOCCO DI CANCELLAZIONE ### ########## if scelta == 0 or scelta == 2: #inizializzo lista di sms inb = inbox.Inbox() msgs = inb.sms_messages() no = float(len(msgs)) #riazzero variabili numsaved = float(0) numdeleted = float(0) counter = 0 #cancellazione sms appuifw.note(u"Attendere...\nCancellati 0% ricevuti","info") for msg in msgs: inb.delete(msg) numdeleted = numdeleted + 1 counter = counter + 1 if counter == 20: percentuale = (numdeleted/no)*100 appuifw.note(u"Attendere...\nCancellati " + repr(int(percentuale))+"% ricevuti","info") counter = 0 #inizializzo lista di sms inb = inbox.Inbox(inbox.ESent) msgs = inb.sms_messages() no = float(len(msgs)) #riazzero variabili numsaved = float(0) numdeleted = float(0) counter = 0 #cancellazione sms appuifw.note(u"Attendere...\nCancellati 0% inviati","info") for msg in msgs: inb.delete(msg) numdeleted = numdeleted + 1 counter = counter + 1 if counter == 20: percentuale = (numdeleted/no)*100 appuifw.note(u"Attendere...\nCancellati " + repr(int(percentuale))+"% inviati","info") counter = 0 appuifw.note(u"Fatto! I file salvati sono presenti in e:\sms\ !","conf")