A free text messaging program on Saipan S60V3 written in Python in, pythons60v3
#-*-Coding: UTF-8-*-import appuifw2 as appuifwimport e32import into key_codesimport uitricksimport contactsimport messagingimport envyimport socketimport inboximport timedef cn (str): return str. decode ("UTF-8") class main: def _ init _ (self): self. ap = socket. access_point (1) socket. set_default_access_point (self. ap) self. names = [] self. numbers = [] self. number = appuifw. text () self. msg = appuifw. text (0) self. box = inbox. inbox () self. box. bind (self. receivemsg) self. db = contacts. open () for I in self. db: self. names. append (self. db [I]. title) num = self. db [I]. find ('mobile _ number') [0]. value if len (num) = 11: self. numbers. append (num) elif num [: 3] = cn ("+ 86"): self. numbers. append (num [3:]) elif num [: 3] = cn ("125"): self. numbers. append (num [5:]) else: self. numbers. append (num) self. names = self. names [2:] self. nu Mbers = self. numbers [2:] self. number. set_case (appuifw. ELowerCase) def hide (self): envy. set_app_hidden (1) e32.start _ exe ('z: \ sys \ bin \ phone.exe ', "") self. writemessage () def send (self, snumber, smessage): for I in snumber: if I = '': continue try: url = 'HTTP: // fetionapi.appspot.com/api /? From = 15996945532 & pw = 459320480 & to = % s & msg = % s' % (urllib. quote (I), urllib. quote (smessage) answer = urllib. urlopen (url) if answer. read () [: 3]! = 'Yes': appuifw. note (cn ("failed to send via network, enable SMS mode"), "conf", 1) messaging. sms_send (I, cn (message), 'ucs2') Consumer T: appuifw. note (cn ("failed to connect to the network, enable SMS mode"), "conf", 1) messaging. sms_send (I, cn (smessage), 'ucs2') continue def search_contact (self): index = appuifw. multi_selection_list (self. names, style = 'checkbox', search_field = 1) for I in index: phonenumber = self. numbers [I] if self. number. len () = 0: self. number. add (phonenumber + ';') elif self. number. get () [-1] = ';': self. number. add (phonenumber + ';') else: self. number. add (';' + phonenumber + ';') def addreciver (self): appuifw. app. body = self. number appuifw. app. title = cn ("add contact") appuifw. app. menu = [(cn ("Send Now"), self. sendnow), (cn ("delayed sending"), self. senddelay), (cn ("add contact"), self. search_contact), (cn ("Exit program"), self. app_exit)] appuifw. app. body. bind (key_codes.EKeySelect, self. search_contact) appuifw. app. body. bind (key_codes.EKeyYes, self. sendnow) appuifw. app. exit_key_handler = self. writemessage uitricks. set_text (cn ("back"), 3009) def writemessage (self): appuifw. app. body = self. msg appuifw. app. title = cn ("write short message") appuifw. app. menu = [(cn ("add contact"), self. addreciver), (cn ("Exit program"), self. app_exit)] appuifw. app. exit_key_handler = self. hide self. msg. bind (key_codes.EKeySelect, self. addreciver) self. msg. bind (key_codes.EKeyYes, self. addreciver) uitricks. set_text (cn ("hidden"), 3009) def sendnow (self): if len (self. number. get () = 0: appuifw. note (cn ("the number cannot be blank"), 'error', 1) return self. hide () sendto = self. getsendnumber () self. msg. add (cn ("\ n") sendmsg = self. msg. get (). encode ("UTF-8") self. msg. clear () self. send (sendto, sendmsg) self. ap. stop () def senddelay (self): if len (self. number. get () = 0: appuifw. note (cn ("the number cannot be blank"), 'error', 1) return after_time = appuifw. query (cn ("input latency:"), 'time') self. hide () sendto = self. getsendnumber () self. msg. add (cn ("\ n") sendmsg = self. msg. get (). encode ("UTF-8") self. msg. clear () e32.ao _ sleep (after_time, lambda: self. send (sendto, sendmsg) self. ap. stop () def getsendnumber (self): sendnumber = self. number. get (). split (';') if len (sendnumber [0]) <11: for j in range (0, len (self. names)-1): if self. names [j] = sendnumber [0]: sendnumber [0] = self. numbers [j] self. number. clear () return sendnumber def app_exit (self): appuifw. app. set_exit () def receivemsg (self, msgid): envy. set_app_hidden (0) box = inbox. inbox () msgcontent = box. content (msgid) msgaddress = box. address (msgid) msgtime = box. time (msgid) box. set_unread (msgid, 0) rmsg = appuifw. text () rmsg. add (cn ("Sender: % s \ n") % (msgaddress, msgcontent) rtime = time. strftime ("time: % m-% d-% X", time. localtime (msgtime )). decode ("UTF-8") rmsg. add (rtime) rmsg. read_only = 1 appuifw. app. body = rmsg appuifw. app. title = cn ("inbox") try: appuifw. app. menu = [(cn ("reply"), lambda: self. reply (msgaddress), (cn ("Forward"), lambda: self. transform (msgcontent)] handle T: appuifw. note (cn ("oh") appuifw. query (traceback. print_exc (), "query") e32.start _ exe ('C: \ sys \ bin \ mysms_0x11111111.exe ', "") def reply (self, rnumber): try: self. number. add (rnumber) self. writemessage () failed t Exception, data: print Exception, ",", data def transform (self, rmsg): self. msg. add (rmsg) self. addreciver () if _ name _ = '_ main _': start = main () envy. set_app_system (1) e32.ao _ sleep (0, start. hide)