Beispiel #1
0
 def SetCatIcons(name): # This version gives us a KErrLocked
   db   = OpenDb()
   cm   = db.CreateCategoryManager()
   cid  = cm.GetCategory(unicode(name))
   if cid != landmarks.KPosLmNullItemId:
     cat = cm.ReadCategory(cid)
     if cat.GlobalCategory() != landmarks.KPosLmNullItemId:
       return # ignore Global categories
     icon = cat.GetIcon()
     cat.Close()
     if icon != None:
       ids  = SearchLm(lmsearch.Category(cid), db=db)
       done = [] # dupes possible, then db is locked (though lm is closed :-( )
       for id in ids:
         if id in done: continue
         RETRY = 10
         for i in range(RETRY):
           try:
             lm = ReadLm(db, id)
             lm.SetIcon(*icon); db.UpdateLandmark(lm); lm.Close()
             done += [id]
             break
           except SymbianError, exc:
             if exc[0] != -22 or i >= RETRY-1: raise # KErrLocked
             e32.ao_sleep(0.2)
Beispiel #2
0
def setting():
    global trs, sett, menu_s
    trs = 0
    sett = 1
    canvas.bind(EKeyUpArrow, lambda: move("setup"))
    canvas.bind(EKeyDownArrow, lambda: move("setdown"))
    canvas.bind(EKeySelect, lambda: move("setselect"))
    appuifw.app.exit_key_handler = menu
    while 1:
        trs += 1
        img.clear(0)
        for i in range(5):
            img.line((60 + 10 * i, 20, 60 + 10 * i, 60), 0x333333, width=2)
        for i in range(5):
            img.line((60, 20 + 10 * i, 100, 20 + 10 * i), 0x333333, width=2)
        img.rectangle((0, 0, 176, 208), 0x99ccff)
        for i in range(4):
            for j in range(4):
                if All_shape[trs % 27][0][j][i] == 1:
                    img.rectangle(
                        (10 * i + 62, 22 + 10 * j, 10 * i + 70, 30 + 10 * j),
                        color_box[i][j], color_box[i][j])
                    e32.ao_sleep(0.1)
        img.rectangle((50, menu_s * 20 + 68, 120, 68 + 20 * (menu_s + 0.8)),
                      0x99ccff,
                      fill=(103, 154, 201))
        img.text((60, 80), chn("初级速度"), 0x99ccff, font=ziti)
        img.text((60, 100), chn("中级速度"), 0x99ccff, font=ziti)
        img.text((60, 120), chn("高级速度"), 0x99ccff, font=ziti)
        img.text((60, 140), chn("保存设置"), 0x99ccff, font=ziti)
        img.text((30, 160), chn('QQ 522765228'), 0x00ff00, font=ziti)
        img.text((30, 180), u'(c)', 0xffff00)
        img.text((60, 180), chn('手机网 iniwap.cn'), 0xff0000, font=ziti)
        handle_redraw(())
        e32.ao_sleep(0.08)
Beispiel #3
0
 def ConnectToLogger(self):
     Log("viewer","Application::ConnectToLogger()")
     e32.ao_sleep(3)
     appswitch.switch_to_fg(u"MapViewer")
     self.position = LoggerProperty(EKeyPosition,self.OnPosition)
     self.trackpoint = LoggerProperty(EKeyTrackPoint,self.OnTrackPoint)
     self.course = LoggerProperty(EKeyCourse,self.OnCourse)
Beispiel #4
0
def _image_displacement(aa, angle, vert, bgcolor, callback):
    img, msk = aa
    imgw = img.size[0]
    imgh = img.size[1]
    ang = ((angle / 180.0) * pi)
    if vert == 0:
        image = new_image((imgw + (imgh * tan(ang)), imgh))
    else:
        image = new_image((imgw, imgh + (imgw * tan(ang))))
    image.clear(bgcolor)
    mask = new_image(image.size, 'L')
    if vert == 0:
        for y in xrange(imgh):
            linepix = img.getpixel([(x, y) for x in xrange(imgw)])
            val = ((imgh - y) * tan(ang))
            for x in xrange(imgw):
                image.point((x + val, y), outline=linepix[x])
            callback(y, imgh)
            if keyboard.is_down(key_codes.EScancodeRightSoftkey):
                return False
            ao_sleep(0.001)
        pass
    else:
        for x in xrange(imgw):
            linepix = img.getpixel([(x, y) for y in xrange(imgh)])
            val = (x * tan(ang))
            for y in xrange(imgh):
                image.point((x, y + val), outline=linepix[y])
            callback(x, imgw)
            if keyboard.is_down(key_codes.EScancodeRightSoftkey):
                return False
            ao_sleep(0.001)
        pass
    return (image, mask)
Beispiel #5
0
 def ConnectToLogger(self):
     Log("viewer", "Application::ConnectToLogger()")
     e32.ao_sleep(3)
     appswitch.switch_to_fg(u"MapViewer")
     self.position = LoggerProperty(EKeyPosition, self.OnPosition)
     self.trackpoint = LoggerProperty(EKeyTrackPoint, self.OnTrackPoint)
     self.course = LoggerProperty(EKeyCourse, self.OnCourse)
Beispiel #6
0
    def main(self, game_obj):
        self.game_obj = game_obj

        # Run the game initializer and
        # pass in a reference to to the game world here.
        game_obj.initialize(self)

        # Start the game loop
        assert hasattr(game_obj, 'run'), "Game object needs a run method."
        if not self.is_running:
            self.is_running = 1

        if not hasattr(game_obj, 'handle_timers'):
            game_obj.handle_timers = 0

        handle_timers = game_obj.handle_timers
        run_fn = game_obj.run

        while self.is_running:
            ao_yield()
            run_fn()
            if handle_timers:
                continue
            else:
                ao_sleep(self.fps)

        # Run any termination/cleanup sequence here if any.
        if hasattr(game_obj, 'terminate'):
            game_obj.terminate()
Beispiel #7
0
    def check_num(self, user_num):
        """ Calls when player press key
        
        Args:
            user_num (int): 
        """

        self.draw_gamefield()
        self.graphics.redraw()
        e32.ao_sleep(0.15)

        if user_num == self.numbers[self.digits_counter]:
            self.digits_counter += 1
            self.draw_gamefield()
            self.graphics.draw_num(user_num, correct=True)
            self.graphics.redraw()

            # if user pass all numbers
            if self.digits_counter == self.digits_num:
                self.next_level()
        else:
            self.lifes -= 1
            self.draw_gamefield()
            self.graphics.draw_num(user_num, correct=False)
            self.graphics.redraw()
Beispiel #8
0
    def setRead(self,  id,  state):
        state = int(not state)

        #FIXME: I shouldn't need this
        e32.ao_sleep(1)

        self.inbox.set_unread(id,  state)
Beispiel #9
0
    def test_start_record(self):
        def video_cb(err, code):
            self.failIf(err, "Error while recording")
            if self.counter:
                self.failUnlessEqual(code, camera.EPrepareComplete,
                                     "State is not proper")
            else:
                self.failUnlessEqual(code, camera.EOpenComplete,
                                     "State is not proper")
            self.counter += 1

        def finder_cb(im):
            appuifw.app.body.blit(im)

        self.counter = 0
        video_filename = 'test_video.3gp'
        appuifw.app.body = appuifw.Canvas()
        self.delete_files_if_exist([video_filename], save_path)

        try:
            camera.start_finder(finder_cb)
            camera.start_record(save_path + video_filename, video_cb)
            e32.ao_sleep(5)
            camera.stop_record()
            camera.stop_finder()
        except RuntimeError, e:
            print >> sys.stderr, "Error recording a video :", e
            raise
Beispiel #10
0
    def __init__(self,sid):
        try:
            if sid == None:
                sid = GetSid()
            self.sid = sid

            Property.Define(sid,EKeyCommand,Property.EInt)
            Property.Define(sid,EKeyArguments,Property.EText)
            Property.Define(sid,EKeyResult,Property.EInt)
            self.pCommand = Property()
            self.pArgs = Property()
            self.pResult = Property()
            self.pCommand.Attach(sid,EKeyCommand,Property.EInt)
            self.pArgs.Attach(sid,EKeyArguments,Property.EText)
            self.pResult.Attach(sid,EKeyResult,Property.EInt)
            self.events = {}
            self.commands = {
                EKeyCmdServerPing:  ( self.OnPing, "" ),
                EKeyCmdServerExit:  ( self.OnExit, "" ),
                }
            self.exit = False
            self.plugins = {}
            self.pluginnames = []
        except:
            DumpExceptionInfo()
            ao_sleep(30)
Beispiel #11
0
 def save(self, confirm=1, save_as=0):
  try:
   if self.wait or ((save_as or self.is_open!=1) and not self.get_path('Save as:')): return
   should_continue=1; self.wait=1
   if confirm or self.save_confirm:
    try:
     if os.path.exists(self.path): prompt="File exists.\nSave (replace)?"
     else: prompt="File doesn't exist.\nSave (make new)?"
    except UnicodeError: prompt="File may exist.\nSave?"
    should_continue=appuifw.query(unicode(prompt),'query')
  except: self.refresh(); return note_error()
  if should_continue:
   appuifw.app.title=u'Saving...'
   e32.ao_sleep(0); old_file=None; return1=None
   try:
    self.cache=self.body.get()
    self.backup(self.cache)
    if os.path.isfile(self.path): old_file=open(self.path).read()
    open(self.path,'w').write(self.convert(self.cache))
   except:
    return1=self.traceback()#.note_error()
    self.cache=None
    try:
     if old_file and appuifw.query(u'Error.\u2029Restore backup to file?','query'): open(self.path,'w').write(old_file)
    except : return1=self.traceback#.note_error()
   else:
    if appuifw.app.screen in ['large', 'full']: appuifw.note(u'Document saved','conf')
    self.is_open=1; self.cache=self.body.get()
    self.save_confirm=0
   self.refresh()
   return return1
  self.refresh()
Beispiel #12
0
 def do_replace(cur_pos, text):
  e32.ao_sleep(0.2)
  self.body.set(text[:cur_pos]+text[cur_pos:cur_pos+len(self.search_str)].replace(self.search_str, self.replace_str)+text[cur_pos+len(self.search_str):])
  cur_pos=cur_pos+len(self.replace_str)-1
  self.body.set_pos(cur_pos)
  text=self.body.get()
  return cur_pos, text
Beispiel #13
0
def draw_welcome():
    wel_col = 1
    while not start:
        img.text((fitx(cn(TITLE), (0, W)), H / 4 + 1),
                 cn(TITLE),
                 fill=SHADOW,
                 font=FONT)
        img.text((fitx(cn(TITLE), (0, W)) + 1, H / 4),
                 cn(TITLE),
                 fill=MAINFONT_CLR,
                 font=FONT)
        fsym = img.measure_text(cn(TIP), font='symbol')
        fsym2 = img.measure_text(cn(COPYRIGHT))
        img.text(((W / 2 - fsym[1] / 2), H * 4 / 5),
                 cn(TIP),
                 fill=(0, 100 * wel_col, 0),
                 font='symbol')
        img.text(((W / 2 - fsym2[1] / 2), H * 19 / 20),
                 cn(COPYRIGHT),
                 fill=SHADOW)
        paint(())
        wel_col += 1
        if wel_col == 3:
            wel_col = 1
        e32.ao_yield()
        e32.ao_sleep(0.1)
    while 1:
        e32.ao_yield()
Beispiel #14
0
 def run(self):
     appuifw.app.exit_key_handler = self.set_exit
     while not self.exitflag:
         self.draw_square(self.loc, self.color)
         if (
             tuple(self.loc) in self.fillarray
             or self.loc[0] >= self.fieldsize[0]
             or self.loc[0] < 0
             or self.loc[1] >= self.fieldsize[1]
             or self.loc[1] < 0
         ):
             break
         if tuple(self.loc) == self.foodloc:
             self.score += 10
             self.draw_score()
             self.place_food()
             self.draw_food()
             self.wormlength += 10
         if len(self.wormlocs) > self.wormlength:
             loc = self.wormlocs[0]
             del self.wormlocs[0]
             del self.fillarray[loc]
             self.draw_square(loc, self.fieldcolor)
         self.fillarray[tuple(self.loc)] = 1
         self.wormlocs.append(tuple(self.loc))
         e32.ao_sleep(0.08)
         self.loc[0] += self.deltas[self.direction][0]
         self.loc[1] += self.deltas[self.direction][1]
     self.close_canvas()
Beispiel #15
0
def help():
    global w, img1
    explain = [
        cn("欢迎使用短信签名测试版"), u"================",
        cn("功能说明:"),
        cn("1.可设置自动回复"),
        cn("2.可设置定时回复"),
        cn("3.可发送闪信"),
        cn("4.签名功能可选"),
        cn("5.具有短信转E功能"), u"================",
        cn("@小布开发版权所有@")
    ]
    w = TopWindow.TopWindow()
    img1 = Image.new((176, 208))
    img1.clear(0)
    for i in range(10):
        img1.text((10, 15 + i * 12), explain[i], fill=0x0000ff)
    w.add_image(img1, (0, 0))
    w.size = (160, 135)
    w.position = (5, 45)
    w.shadow = 5
    w.corner_type = "corner5"
    w.show()
    e32.ao_sleep(10)
    w.hide()
Beispiel #16
0
def tsend():
    appuifw.note(cn("请选择联系人"), "info")
    secl = time.time()
    secl -= 8 * 3600
    t = tim + dat - secl
    e32.ao_sleep(t)
    send(3)
Beispiel #17
0
 def app(self):
     appuifw.app.title = ru(title)
     appuifw.app.exit_key_handler = self.exit
     self.i = 1
     self.console = Console.Console(True)
     self.text = self.console.text
     appuifw.app.body = self.console.text
     self.text.color = 255, 0, 0
     self.text.font = "title", 20
     self.write("%s by %s" % (title, self.developer))
     self.text.color = 0, 0, 0
     self.text.font = "title", 18
     if not len(socket.access_points()):
         self.write(
             "No Access Point is defined.Please add new APN.App will exit")
         e32.ao_sleep(2)
         os.abort()
     else:
         pass
     self.write("Access Point: %s" %
                self.ap_list[self.apid_list.index(self.sets.APN)])
     self.write("Find IP:%s" % self.insta(self.sets.IPHUNT))
     self.write("Run Simple Server: %s" % self.yesno[self.sets.RUNSS])
     appuifw.app.menu = [(ru("Start"), self.start),
                         (ru("Settings"), self.settings),
                         (ru("About"), self.about), (ru("Exit"), self.exit)]
def backup():
    qu=ui.popup_menu([u'Phone', u'Memory Card'], u'Select Location')
    loc=['c:\\', 'e:\\']
    try:
        dir=loc[qu]+'ADIKStools\\mySMSbackup\\'+time.strftime('%Y%m%d')+'\\'
    except:
        return
    if not os.path.exists(dir):
        os.makedirs(dir)
        ui.note(u'Folder Successfully Created', 'conf')
    n=dir+time.strftime('%H.%M.%S')+'.txt'
    gui.global_note(u'backing up\nplease wait', 'info')
    fl=open(n, 'a')
    fl.write(u'ADIKSonline SMS Backup\n\n%s\n' %q)
    b=t.sms_messages()
    if len(b)==0:
        ui.note(u'you have no message in your inbox'.upper())
        fl.write(u'No message in Inbox ! ! !\n\n%s\n' %u)
        fl.close()
        return
    y=0
    for i in b:
        try:
            fl.write(u'MESSAGE ID: %d\nSENDER: %s\nTIME: %s\nCONTENTS: %s\n\n%s\n\n' %(i, str(t.address(i)), time.ctime(t.time(i)), t.content(i), u))
            e32.ao_yield()
        except:
            y+=1
            gui.global_note(u'an error occured', 'error')
    fl.write(u'get more, contact:\[email protected]\n+2347035536245')
    fl.close()
    gui.global_note(str(len(b)-y)+u' successful'+u'\n'+str(y)+u' errors', 'confirm')
    e32.ao_sleep(1.5)
    if len(b)-y and msgquery.infopopup(u'View Backup Now?', u'View Backup', msgquery.OKRBack):
        view(n)
Beispiel #19
0
 def rotate(self):
  def rem():
   try:self.gif.remove_image(self.img, (0,0))
   except:pass
  e32.ao_sleep(self.wait,rem)
  self.img=self.img.transpose(graphics.ROTATE_90)
  self.gif.add_image(self.img, (0,0))
Beispiel #20
0
def menu():
    global sett
    sett = 0
    trs = 0
    canvas.bind(EKeyUpArrow, lambda: move("up"))
    canvas.bind(EKeyDownArrow, lambda: move("down"))
    canvas.bind(EKeySelect, lambda: move("select"))
    while 1:
        trs += 1
        img.clear(0)
        for i in range(5):
            img.line((60 + 10 * i, 20, 60 + 10 * i, 60), 0x333333, width=2)
        for i in range(5):
            img.line((60, 20 + 10 * i, 100, 20 + 10 * i), 0x333333, width=2)
        img.rectangle((0, 0, 176, 208), 0x99ccff)
        for i in range(4):
            for j in range(4):
                if All_shape[trs % 27][0][j][i] == 1:
                    img.rectangle(
                        (10 * i + 62, 22 + 10 * j, 10 * i + 70, 30 + 10 * j),
                        color_box[i][j], color_box[i][j])
                    e32.ao_sleep(0.1)
        img.text((30, 200), u'(c)', 0xffff00)
        img.text((50, 200), chn('手机网 iniwap.cn'), 0xff0000, font=ziti)
        img.rectangle((50, menu_y * 20 + 68, 120, 68 + 20 * (menu_y + 0.8)),
                      0x99ccff,
                      fill=(103, 154, 201))
        img.text((60, 80), chn("开始游戏"), 0x99ccff, font=ziti)
        img.text((60, 100), chn("继续游戏"), 0x99ccff, font=ziti)
        img.text((60, 120), chn("难度设置"), 0x99ccff, font=ziti)
        img.text((60, 140), chn("游戏帮助"), 0x99ccff, font=ziti)
        img.text((60, 160), chn("玩家排行"), 0x99ccff, font=ziti)
        img.text((60, 180), chn("退出游戏"), 0x99ccff, font=ziti)
        handle_redraw(())
        e32.ao_sleep(0.08)
Beispiel #21
0
    def player_turn(self):
        """ Player turn loop. Wait for players key pressing. """

        self.keyboard.flush()

        while self.player_wait:
            if self.lifes == 0:
                self.draw_gamefield()
                self.graphics.draw_gameover()
                self.graphics.redraw()
                # check record
                self.check_bestscore(self.digits_num-1)
                #e32.ao_sleep(self.READY_INTERVAL)
                self.init_new_game()
                break

            # process numeric keys, in this keys index is key number 0...9
            # shorter but maybe not quite pythonic, reafactoring recommend
            for index, key in enumerate(self.KEYS):
                if self.keyboard.pressed(key):
                    self.check_num(index)

            e32.ao_sleep(0.1)

        self.player_wait = True
Beispiel #22
0
    def get_file(self,file,distdir,ask):
        fname = file[ file.rfind('/') +1: ]
        if ask and not query(u'Download file %s?' % fname,'query'):
            return 
        try:
            self.s.send(Commands.getfile)
            e32.ao_sleep(0.2)
            self.s.send(file)
                
            fsize = int(self.s.recv(10))
            getsize = 0
            iter = 0

            if distdir[-1:] != '\\':        # append '\' if it is not present.
                distdir += '\\'
            f = open(distdir+fname,"w")

            while getsize != fsize:
                data = self.s.recv(fsize)
                getsize += len(data)
                iter += 1
                f.write(data)

            
            f.close()
            note(u'File %s%s saved![%iiter]' % (distdir,fname,iter),'info')
        except IOError:
            self.err_connection()
Beispiel #23
0
def select(in_objs, out_objs, exc_objs, timeout=None):
    if len(out_objs) > 0 or len(exc_objs) > 0:
        raise NotImplementedError('selecting for output ' \
                                  'and exception not supported')
    for k in in_objs:
        if not isinstance(k, _socketobject):
            raise NotImplementedError('select supports only socket objects')
    lock = e32.Ao_lock()
    if timeout is not None and timeout > 0:
        e32.ao_sleep(timeout, lock.signal)
    (ready_in, ready_out, ready_exc) = ([], [], [])
    for sock in in_objs:
        if sock._recv_will_return_data_immediately():
            ready_in.append(sock)
    # If we have readable sockets or we just want to poll, return now.
    if len(ready_in) > 0 or timeout == 0:
        return (ready_in, ready_out, ready_exc)

    # Ok, so we want to wait for it...

    def callback(sock):
        ready_in.append(sock)
        lock.signal()

    for sock in in_objs:
        sock._set_recv_listener(lambda sock=sock: callback(sock))
    lock.wait()
    return (ready_in, ready_out, ready_exc)
def run():
    global debug_buf

    death_point = time.time() + 10

    test_thread = time.time() + 2
    while time.time() < death_point:
        print "Pending"
        e32.ao_sleep(2)

        while len(debug_buf) > 0:
            msg = debug_buf[0]
            debug_buf = debug_buf[1:]
            if len(debug_buf) == 1:
                break
            print "Buffer %d Message: %s" % (len(debug_buf), msg)

        if time.time() > test_thread:
            thread.start_new_thread(go_thread, ())

    # This row is never reached
    # The Python Interpreter shell is totally frozen
    # and it refuses to be terminated via Python task manager
    # -> phone must be restarted
    print "Done"
Beispiel #25
0
 def run(self):
     appuifw.app.exit_key_handler = self.set_exit
     while not self.exitflag:
         self.draw_square(self.loc, self.color)
         if (tuple(self.loc) in self.fillarray
                 or self.loc[0] >= self.fieldsize[0] or self.loc[0] < 0
                 or self.loc[1] >= self.fieldsize[1] or self.loc[1] < 0):
             break
         if tuple(self.loc) == self.foodloc:
             self.score += 10
             self.draw_score()
             self.place_food()
             self.draw_food()
             self.wormlength += 10
         if len(self.wormlocs) > self.wormlength:
             loc = self.wormlocs[0]
             del self.wormlocs[0]
             del self.fillarray[loc]
             self.draw_square(loc, self.fieldcolor)
         self.fillarray[tuple(self.loc)] = 1
         self.wormlocs.append(tuple(self.loc))
         e32.ao_sleep(0.08)
         self.loc[0] += self.deltas[self.direction][0]
         self.loc[1] += self.deltas[self.direction][1]
     self.close_canvas()
Beispiel #26
0
 def Run(self):
     self.running = True
     count = 60
     while self.running:
         if not self.screensaver:
             e32.reset_inactivity()
         e32.ao_sleep(0.5)
Beispiel #27
0
    def sendAllMessages(self,  lastId):
        messages = list()
        inbox = list()
        sent = list()
        for box in ("inbox",  "sent"):
            #FIXME: I shouldn't need this
            e32.ao_sleep(1)

            if box == "inbox":
                inbox = self.inbox.sms_messages()
            else:
                sent = self.sent.sms_messages()

        messages = inbox + sent
        messages.sort()
        for sms in messages:
            if (int(sms) > int(lastId)):
                id = sms
                time = self.inbox.time(sms)
                address = self.inbox.address(sms)
                content = self.inbox.content(sms)
                content = content.replace(u'\u2029',  u'\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)

                if sms in inbox:
                    box = "inbox"
                else:
                    box = "sent"

                self.send(NUM_MESSAGE_REPLY_LINE,  box,  id,  time,  address,  content)

        self.send(NUM_MESSAGE_REPLY_END)
Beispiel #28
0
    def note2(s,
              content,
              title=None,
              waitTime=1,
              maskColor=0x999999,
              backColor=0x0,
              textColor=0xffffff,
              type=1):
        s.__imgBlack.clear(backColor)
        if not title: title = s.TitleName
        s.super = 1
        X, Y = 5, s.screenSize[1] - 40
        textL = s.splitLines(content, s.screenSize[0] - 2 * X - 10)
        if len(textL) <= 1: textL += (u'', )
        elif len(textL) > s.maxLines: textL = textL[:s.maxLines]
        height = len(textL) * 25 + 30
        s.__imgOld.blit(s.__img)

        for i in range(Y, Y - height, -15):
            s.__drawNote2(title, X, height, i, textL, maskColor, textColor)
        e32.ao_sleep(waitTime)
        for i in range(Y - height, 321, 20):
            s.__drawNote2(title, X, height, i, textL, maskColor, textColor)
        s.super = 0
        if type:
            s.__img.blit(s.__imgOld)
            s.__redraw()
        #恢复初始的s.mask
        s.__mask.clear(0x888888)
Beispiel #29
0
    def note(s, content, title=None, waitTime=1):
        if not title: title = s.TitleName
        s.super = 1
        s.__imgOld.blit(s.__img)
        s.__img.clear(0)
        s.__img.blit(s.__imgOld, mask=s.__mask)

        list = akntextutils.wrap_text_to_array(content, "dense", 200)
        if len(list) <= 1: list += (u'', )
        elif len(list) > 6: list = list[:6]
        s.__img.polygon(s.rim((13, 130, 227, 160 + len(list) * 25)),
                        fill=0xa6f9f8)
        s.__img.polygon(s.rim((13, 130, 227, 160)), fill=0x2ad8ea)
        s.__img.line((14, 158, 225, 158), 0xffffff, width=2)
        s.__img.text(
            (120 - s.__img.measure_text(title,
                                        ("dense", 20))[0][2] / 2.0, 155),
            title, 0x0, ("dense", 20, FONT_BOLD | FONT_ANTIALIAS))
        for i in range(len(list)):
            s.__img.text((20, 180 + i * 25), list[i], 0x0,
                         ("dense", 18, FONT_ANTIALIAS))
        s.__redraw()
        e32.ao_sleep(waitTime)
        s.__img.blit(s.__imgOld)
        s.__redraw()
        s.super = 0
Beispiel #30
0
def btselect(in_objs, out_objs, exp_objs, timeout=None):
    ready_in = []

    for sock in in_objs:
        if sock._recv_will_return_data_immediately():
            ready_in.append(sock)

    import e32socket, e32
    lock = e32.Ao_lock()
    if timeout is not None and timeout > 0:
        e32.ao_sleep(timeout, lock.signal)

    if len(ready_in) > 0 or timeout == 0:
        return (ready_in, [], [])

    def callback(sock):
        ready_in.append(sock)
        lock.signal()

    for sock in in_objs:
        sock._set_recv_listener(lambda sock=sock: callback(sock))
    lock.wait()
    for sock in in_objs:
        sock._set_recv_listener(None)
    return (ready_in, [], [])
Beispiel #31
0
def rank():
    appuifw.app.exit_key_handler = menu
    try:
        db = e32dbm.open("c:\\ranklist.e32dbm", "r")
        tdb = db.items()
        db.close()
    except:
        appuifw.note(chn("暂无排行榜"), "error")
    for i in range(len(tdb) - 1):
        for j in range(len(tdb) - i - 1):
            if int(tdb[j][1]) < int(tdb[j + 1][1]):
                t = tdb[j]
                tdb[j] = tdb[j + 1]
                tdb[j + 1] = t
    while 1:
        img.clear(0)
        img.rectangle(
            (0, 0, 176, 208),
            outline=color_box[random.randint(0, 3)][random.randint(0, 3)])
        img.text((20, 20), chn("排---------行-------榜"), 0xff0000, font=ziti)
        img.text((20, 190), chn("排--------行---------榜"), 0xff0000, font=ziti)
        for i in range(8):
            img.text((30, 30 + i * 20), chn(tdb[i][0]), 0x0000ff)
            img.text((140, 30 + i * 20), chn(tdb[i][1]), 0x00ff00)
        handle_redraw(())
        e32.ao_sleep(0.2)
        e32.ao_yield()
Beispiel #32
0
def dymz():
    appuifw.app.screen='full'
    img=Image.new((240,320))
    img=Image.open("c:\\Data\\X-SMS\\3.jpg")

    img.line((00,5,640,5),0xff0000)
    img.text((25,70), u'To check for updates, visit...',0xff0000)
    img.text((05,85), u'http://www.sirajsoft.com',0xff0000)
    img.line((00,7,640,7),0xff0000)
    img.text((45,20), u'SIRAJ X-SMS',0xff0000)
    img.line((00,34,640,34),0xff0000)
    img.line((00,36,640,36),0xff0000)
    img.text((65,30), u'v1.5',65280)
    img.text((00,160), u'Developed by:',0xff0000)
    img.text((05,178), u'Siraj',65280)
    img.text((10,198), u'www.sirajsoft.com',65280)
    globalui.global_msg_query(u"New version have  Restore And Backup sms options too. Till then have fun with presently functional features \n Thanx for keeping patience.", u"Help")
    def quit():
        global running
        running=0
        appuifw.app.set_exit()


    def handle_redraw(rect):
        canvas.blit(img)

    running=1

    canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
    appuifw.app.body=canvas
    e32.ao_sleep(10)
    img.clear()
    draw()
Beispiel #33
0
    def get_file(self, file, distdir, ask):
        fname = file[file.rfind('/') + 1:]
        if ask and not query(u'Download file %s?' % fname, 'query'):
            return
        try:
            self.s.send(Commands.getfile)
            e32.ao_sleep(0.2)
            self.s.send(file)

            fsize = int(self.s.recv(10))
            getsize = 0
            iter = 0

            if distdir[-1:] != '\\':  # append '\' if it is not present.
                distdir += '\\'
            f = open(distdir + fname, "w")

            while getsize != fsize:
                data = self.s.recv(fsize)
                getsize += len(data)
                iter += 1
                f.write(data)

            f.close()
            note(u'File %s%s saved![%iiter]' % (distdir, fname, iter), 'info')
        except IOError:
            self.err_connection()
Beispiel #34
0
>>> def showtime():
...     print time.clock()
...     e32.ao_sleep(1,showtime)
...     
>>> showtime()
263523.390625
>>> 
Beispiel #35
0
def create():

    #login()

    formatl = ['python', 'pys60', 'text', 'html4strict']
    expiryl = ['N', '10M', '1H', '1D', '1M']

    if pastebin.api_user_key != '':
        file = manager.AskUser()
        if file:
            bodi.add(u'File:    %s\n' % file)
            ptitle = appuifw.query(u'Paste Title:', 'text',
                                   u'%s' % (os.path.split(file)[1]))
            if ptitle is None:
                ptitle = os.path.split(file)[1]
            bodi.add(u'Paste Title:    %s\n' % ptitle)
            e32.ao_sleep(0.5)
            bodi.add(u'>>Trying to create the Paste\n')
            try:
                pasteurl = pastebin.createPasteFromFile(
                    file, ptitle, formatl[sets.PFORMAT], sets.PPRIVACY,
                    expiryl[sets.PEXPIRY])
                bodi.add(u'>>Paste Created\n')
                bodi.add(u'>>Paste URL: \n%s\n' % pasteurl)
            except:
                try:
                    fd = str(open(file).read())
                    pasteurl = pastebin.createPaste(fd, ptitle,
                                                    formatl[sets.PFORMAT],
                                                    sets.PPRIVACY,
                                                    expiryl[sets.PEXPIRY])
                    bodi.add(u'>>Paste Created\n')
                    bodi.add(u'>>Paste URL: \n%s\n' % pasteurl)
                except:
                    bodi.add(u">>Failed to create paste.Try again.\n")
Beispiel #36
0
 def test_send_sms(self):
     # Test sending of a sms
     messaging.sms_send(contacts_info['phone_number'][s60_version],
                        self.message, '7bit', None, self.sender_name)
     e32.ao_sleep(5)
     ids = self.inbox_obj.sms_messages()
     self.failUnlessEqual(self.inbox_obj.content(ids[0]), self.message)
Beispiel #37
0
def rematch():
    updateHighscoreList()
    saveHighscoresToDisk()
    hs = []
    readHighscoresFromDisk()
    is_move = 0
    won = 0
    end = 0
    sumscore = 0
    dat = [([0] * 4) for i in range(4)]
    hs.sort()
    hs.insert(0, [sumscore, today()])
    sumscore_flag = 0
    dat_bak = []
    sumscore_bak = []
    Xcode = '0000'
    max_undo_chances = UndoOptionList[undo_option_flag]
    undo_chances = max_undo_chances
    for t in ts:
        t.visible = 0
    longimgInit()
    drawBg2()
    drawNum(sumscore)
    t01.appear()
    t02.appear()
    t01.draw()
    t02.draw()
    backupLoading()
    paint_all()
    backupRecentData()
    e32.ao_sleep(0.05)
    global hs, is_move, won, end, sumscore, dat, sumscore_flag, dat_bak, sumscore_bak, Xcode, max_undo_chances, undo_chances
def help():
    body.color = (0,0,255)
    body.set(u"1. This program is used to pause the screensaver that currently active. That mean,after this program is run, the screensaver will automatically turn off.\n2. The screensaver will be off until this program is close. This mean this program need to be run in background so it will continue working.\n3. The 'Close Me' is use to close this program because the 'Exit' did'nt work.\n4. This program tested on N95-1 and maybe will work on other S60v3 or FP1 phone.\n5. This program is used with other python application that need the screensaver off.")
    body.color = (255,0,0)
    body.add(u"\n\nAuto Return to Menu after 20seconds")
    e32.ao_sleep(20)
    main()
    def run(self):
        while self.running:
            self.img.clear((209,228,244))
            self.img.rectangle((0, self.field_bottom,
                            self.canvas.size[0], self.canvas.size[1]),
                            outline=None, fill=(206,177,113))
            self.draw_pipes()
            # draw playes block
            self.img.rectangle(self.block.coords(), outline=None, fill=(237,186,0))

            if self.playing:
                self.block.move()
                self.move_pipes()
                # pass pipes
                self.check_intersection()
            else:
                self.draw_startmenu()

            # draw player score
            self.img.text((5, 25),
                            unicode(self.score)+u"/"+unicode(self.best_score),
                            0x000000,
                            font=(u'Series 60 ZDigi', 24))
            self.handle_redraw(())
            e32.ao_sleep(pyFlappyBlock.SLEEP)
Beispiel #40
0
 def __init__(s,path=None,waitTime=0):
   s.screenSize=appuifw.app.layout(appuifw.EScreen)[0]
   s.maxLines=[5,8][s.screenSize[1]>240]
   s.__doc__=__doc__
   s.__canvas=appuifw.Canvas(s.__redraw,s.__events)
   appuifw.app.body=s.__canvas
   try:
     s.blit(Image.open(path))
     e32.ao_sleep(waitTime)
   except:pass
   del path,waitTime
   appuifw.app.exit_key_handler=s.__exit
   s.__imgOld=Image.new(s.screenSize)
   s.__img=s.__imgOld
   s.__mask=Image.new(s.screenSize,"L")
   s.__mask.clear(0x888888)
   s.__imgBlack=Image.new(s.screenSize)
   s.index=0
   s.super=0
   s.selectType=0
   s.keyType=0
   s.keyList=[[16,50,63497],[17,56,63498],[14,52,63495],[15,54,63496],[167,53,63557],[196,63586]]
   s.TitleName="BingyiApp模块".decode("u8")
   s.__lock=e32.Ao_lock()
   s.__timer=e32.Ao_timer()
Beispiel #41
0
    def sendAllMessages(self, lastId):
        messages = list()
        inbox = list()
        sent = list()
        for box in ("inbox", "sent"):
            #FIXME: I shouldn't need this
            e32.ao_sleep(1)

            if box == "inbox":
                inbox = self.inbox.sms_messages()
            else:
                sent = self.sent.sms_messages()

        messages = inbox + sent
        messages.sort()
        for sms in messages:
            if (int(sms) > int(lastId)):
                id = sms
                time = self.inbox.time(sms)
                address = self.inbox.address(sms)
                content = self.inbox.content(sms)
                content = content.replace(
                    u'\u2029', u'\n'
                )  # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)

                if sms in inbox:
                    box = "inbox"
                else:
                    box = "sent"

                self.send(NUM_MESSAGE_REPLY_LINE, box, id, time, address,
                          content)

        self.send(NUM_MESSAGE_REPLY_END)
Beispiel #42
0
 def show(self, goto, full, text=u'Loading...', shadow=1, stop=1):
     if goto > full or \
     not self.focusflag or \
     not full or \
     goto < 0:
         return
     if isinstance(text, (tuple, list)):
         text, text2 = text
     else: text2 = None
     text, xx = self.x_text(text, 'annotation', self.scr[0] - 26)
     xx -=5
     try:
         self.window.remove_image(self.img)
     except ValueError: pass
     self.img.rectangle((0, 0, self.img.size[0], self.__sizeY), 0xcccccc, self.color_background)
     x = abs((self.img.size[0] - 12) * goto / full)
     self.img1.clear(self.color_background2)
     a, b = self.img1.size
     self.img2.blit(self.img_gradient)
     if text2:
         text2, xx2 = self.x_text(text2, 'dense', self.scr[0] - 37)
         xx2 -= 11
         self.img1.text((xx2, b - 3 - self.__dislocation_text2), text2, self.color_text2, 'dense')
         self.img2.text((xx2, b - 4 - self.__dislocation_text2), text2, 0, 'dense')
     self.img1.blit(self.img2, source = (0, 0, x, self.__sizeW), target = (0, 1))
     self.img1.rectangle((0, 0, a, b), 0xcccccc)
     self.img.blit(self.img1, target = (6, self.__sizeY - self.__sizeW - 6))
     self.img.text((xx, self.__sizeY - self.__sizeW - 6 - self.__h_text / 2 - self.__dislocation_text), text, self.color_text, 'annotation')
     self.window.add_image(self.img, (0, 0))
     if shadow and not self.top_shadow.visible:
         self.top_shadow.show()
     self.window.show()
     e32.ao_yield()
     if goto == full and stop:
         e32.ao_sleep(0.1, self.stop)
Beispiel #43
0
    def setRead(self, id, state):
        state = int(not state)

        #FIXME: I shouldn't need this
        e32.ao_sleep(1)

        self.inbox.set_unread(id, state)
Beispiel #44
0
 def test_reset_inactivity(self):
     """Check for inactivity and reset_inactivity"""
     e32.ao_sleep(sleep_time)
     sec_inactive = e32.inactivity()
     e32.reset_inactivity()
     sec_after_active = e32.inactivity()
     self.failUnless(sec_inactive > sec_after_active)
def text_procent_bar(i, l, name=None):
    procent = l * 0.01
    obw = i / procent
    if name == None: pass
    else:
        r.set(u'' + str(name) + '\n' + str(obw)[:5] + '%')
    e32.ao_sleep(0.001)
Beispiel #46
0
    def mainloop(self):
        """ The infinite main loop of the game """
        lastupdate = time.clock()

        while self.gamestate.running:
            loop_started = time.clock()  # get the current time and...
            # ...decide how many steps happened since the last update
            steps, _ = divmod(loop_started - lastupdate,
                              self.gamestate.TICKLENGTH)

            # update the world according to the steps
            if steps > 0:
                self.gamestate.update_world(steps)
                lastupdate = time.clock()

            if not self.gamestate.running:
                break

            # draw the updated world
            self.redraw()

            # if the whole loop took less time than one step supposed to
            # then sleep until the next step
            remaining_time = self.gamestate.TICKLENGTH - (time.clock() - loop_started)
            if remaining_time > 0:
                e32.ao_sleep(remaining_time)
        self.close_canvas()
Beispiel #47
0
def docy():
    app_lock = e32.Ao_lock()
    appuifw.app.screen='full'
    img=Image.new((240,320))
    img=Image.open("c:\\Data\\X-SMS\\1.jpg")

    def quit():
        global running
        running=0
        appuifw.app.set_exit()


    def handle_redraw(rect):
        canvas.blit(img)

    running=1

    canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
    appuifw.app.body=canvas
    appuifw.note(u"Please wait...Backups are being created!", "info")
    f = codecs.open('e:\\Siraj\SMS-backup.doc', 'w', 'utf8')
    box = inbox.Inbox()
    msg = box.sms_messages()

    for i in msg:
       f.write('From: ' +box.address(i))
       f.write('\n')
       f.write('Time:  ' +ctime(box.time(i))) 
       f.write('\n')
       f.write('Message: ' +box.content(i))
       f.write('\n')
       f.write('\n')
       f.write('! ! ! ! ! !')
       f.write('\n')
       f.write('\n')
       f.write('\n')
    f.close()
    appuifw.note(u"Backups have  been  created successfully!", "info")
    print ""
    img.clear()
    appuifw.app.screen='full'
    img=Image.new((240,320))
    img=Image.open("c:\\Data\\X-SMS\\1.jpg")

    def quit():
        global running
        running=0
        appuifw.app.set_exit()


    def handle_redraw(rect):
        canvas.blit(img)

    running=1

    canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
    appuifw.app.body=canvas
    e32.ao_sleep(3)
    img.clear()
Beispiel #48
0
def handle_hang_up(status):
    #test if the call was complete

    if status[0] == telephone.EStatusConnecting:
        e32.ao_sleep(float(duration), telephone.hang_up)

    elif status[0] == telephone.EStatusDisconnecting:
	e32.ao_sleep(1, loop)
Beispiel #49
0
 def blit_image(self, canvas, img, data):
     self.canvas.clear()
     self.update()
     self.canvas.blit(img, target=(5, 30))
     self.canvas.text((100, 10), u"%.1f kB" % (data["filesize"]/1024), font=(u"Series 60 Sans", 10), fill=0x333333)
     if data.has_key("caption"):
         canvas.text((5, 100), data["caption"], font=(u"Series 60 Sans", 10), fill=0x000066)
     e32.ao_sleep(0.01) # Wait until the canvas has been drawn
Beispiel #50
0
def draw_screen(text):
    canvas.clear()
    line_height = y = 15
    text = text.split("\n")
    for line in text:
      canvas.text((3, y), u""+line, font=(u"Series 60 Sans", 12), fill=0x333333)
      y += line_height
    e32.ao_sleep(0.01)
def exit():
    if ui.query(u'Sure to Quit', 'query'):
        sys.setdefaultencoding(old)
        fi=audio.Sound.open(os.path.dirname(sys.argv[0])+'\\sounds\\2.mp3')
        fi.play()
        e32.ao_sleep(1)
        lock.signal()
        ui.app.set_exit()
Beispiel #52
0
 def run(self):
     appuifw.app.exit_key_handler=self.set_exit
     while not self.exitflag:
         self.DrawPosition()
         e32.ao_sleep(1)
         if time.time() - self.lastSavedbookmark > self.settings.autoBookmarkSaveInterval:
             self.SaveAutoBookmark()
     self.close_canvas()
Beispiel #53
0
 def doKey(self, key):
   if not (not tasksRunning or self.enterKey):
     return 0
   
   forwarding = 0
   pos = text.get_pos()
   autoCompleteCount = self.autoCompleteCount
   
   if key in (key_codes.EKeySelect, 13):
     if self.history:
       self.history.add(self.getInput())
     if self.enterKey:
       self.enterKey(self.getInput())
     else:
       e32.ao_sleep(0, execute)
   elif key in (key_codes.EKeyUpArrow, key_codes.EKeyDownArrow, key_codes.EKeyLeftArrow, key_codes.EKeyRightArrow):
     if self.navigation:
       if key in (key_codes.EKeyUpArrow, key_codes.EKeyDownArrow):
         delta = (key == key_codes.EKeyDownArrow)
         end = delta * (text.len() - 1)
         lines = 0
         for i in range(pos - 1 * (1 - delta), end - 1 + 2*delta, 2*delta - 1):
           if text.get(i, 1) in ("\n", u"\u2029"):
             lines += 1
           if lines == NAVIGATION_LINESPEED or i == end:
             text.set_pos(i)
             break
       else:
         forwarding = 1
     else:
       if key in (key_codes.EKeyUpArrow, key_codes.EKeyDownArrow):
         if self.history:
           self.history.browse(1 - 2 * (key == key_codes.EKeyUpArrow))
       elif pos > self.pos and key == key_codes.EKeyLeftArrow:
         forwarding = 1
       elif key == key_codes.EKeyRightArrow:
         if pos == text.len():
           self.autoCompleteCount += 1
           if self.autoCompleteCount >= MIN_TAP_TO_AUTOCOMPLETE and self.autoComplete:
             sys.stdout.hasWritten = False
             toReplaceWith = self.autoComplete(self.getInput())
             if sys.stdout.hasWritten:
               inputHandler.update()
             self.setPos()
             self.add(toReplaceWith)
         else:
           forwarding = 1
   else:
     if pos < self.pos:
       prompt.toEnd()
     if not (pos <= self.pos and key == key_codes.EKeyBackspace):
       forwarding = 1
   
   if self.autoCompleteCount == autoCompleteCount and key in (key_codes.EKeyBackspace, key_codes.EKeyLeftArrow, key_codes.EKeySelect, 13):
     self.autoCompleteCount = 0
   elif self.autoCompleteCount > MIN_TAP_TO_AUTOCOMPLETE:
     self.autoCompleteCount = MIN_TAP_TO_AUTOCOMPLETE
   return forwarding
def exit():
    if ui.query(u'Sure to Quit', 'query'):
        try:
            fi = audio.Sound.open((os.path.dirname(sys.argv[0]) + '\\sounds\\2.mp3'))
            fi.play()
        except:
            pass
        e32.ao_sleep(1.1)
        ui.app.set_exit()
Beispiel #55
0
 def Stop(self):
     if not self.changingState:
         self.changingState = True
         self.isPlaying = False
         self.GetCurrentMediaPosition()
         self.audioPlayer.stop()
         while self.audioPlayer.state() != audio.EOpen:
             e32.ao_sleep(.001)
         self.changingState = False
Beispiel #56
0
 def press(self,key,info):
  after=[]
  def onafter():
    for f in after:f()
  lines=self.getText().split('\r\n')
  line=lines[-1]
  if self.promptMode:
   if key==13:
    self.lock.signal()
    self.promptMode=False
    return
   if info[0]=='backspace':
    if self.promptLine:
     pl=self.promptLine
     cpos=self.t.get_pos()
     if self.t.get(cpos-len(pl),len(pl))==pl:
      self.t.add(u' ')
      return
    self.promptText=self.promptText[:-1]
   else:
    self.promptText+=str(info[1])
   if self.promptMode==2:
    def hide():
     self.t.delete(self.t.len()-1,1)#remove typed letter
     self.t.add(u'*')# add * in place
    after.append(hide)
  elif key==13: #enter pressed
   self.t.set_pos(self.t.len())
   lfl=len(self.lf())+1 # +1 for added space
   if line[-1:]=='\\':
    after.append(lambda:self.t.add(u' '*lfl))
   else:
    if lines[-2][-1:]=='\\' and line[:lfl]==' '*lfl:
     rev=[l for l in lines]
     rev.reverse()
     prev=[]
     for l in rev[1:]:
      if not l[-1:]=='\\':break
      pre=l[lfl:-1]
      prev.append(pre)
     prev.reverse()
     line=self.lf()+' '.join(prev)+line[lfl-1:]
    cmd=line[lfl:]
    if cmd:
     if cmd in self.history:
      del self.history[self.history.index(cmd)]
     self.history.insert(0,cmd)
     after.append(lambda:self.on('exec_cmd',cmd))
    after.append(self.newline)
  elif info[0]=='backspace':
   cpos=self.t.get_pos()
   if self.t.get(cpos-len(self.lf()),len(self.lf()))==self.lf():
    self.t.add(u' ')
  if after is not []:e32.ao_sleep(0,onafter)
  if info[0]=='tab':
    l=self.t.getText().split('\r\n')
    self.on('tab_press',l[-1])
Beispiel #57
0
def handle_hang_up(status):
    #test if the call was complete

    if status[0] == telephone.EStatusConnecting:
	print "Transferring Data ....\n\n"
        e32.ao_sleep(float(duration), telephone.hang_up)

    elif status[0] == telephone.EStatusDisconnecting:
	print "Data Sent"
Beispiel #58
0
 def onclick(code,prop):
  if prop[1]=='+':
    pass #zoom in
  elif prop[1]=='-':
   pass #zoom out
  pos=t.t.get_pos()
  if prop[0]=='backspace':t.add(' ')
  elif prop[0]=='ctrl':pass
  else:e32.ao_sleep(0,lambda:delete(pos))
 def __initgps(self):
     try:
         import positioning as gps
         gps.select_module(gps.default_module())
         gps.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
         gps.position(course=1,satellites=0,callback=self.__gps_cb, interval=5000000,partial=0)#intervall at 5 seconds atm
         e32.ao_sleep(3)
     except ImportError:
         self.gps_result="Error"
Beispiel #60
0
 def delete_current(self):
     """Delete current image permanently."""
     if (self.current_img >= 0 and 
        appuifw.query(u'Delete current image %d/%d permanently?' % (self.current_img+1, len(self.IMG_LIST)), 'query') is True):
         os.remove(self.IMG_LIST[self.current_img]["path"])
         self.IMG_LIST.pop(self.current_img)
         self.current_img = self.current_img - 1
         e32.ao_sleep(0.05) # let the query popup disappear before update
         self.update()