Ejemplo n.º 1
0
 def _ask_pin(self):
     #window = tichy.Service("WindowsManager").get_app_parent()
     window = None
     editor = tichy.Service('TextEdit')
     pin = yield editor.edit(window,
                             name="Enter PIN",
                             input_method='number')
     yield tichy.Service('SIM').send_pin(pin)
Ejemplo n.º 2
0
 def delete_message(self, msg):
     current_imsi = tichy.Service('SIM').sim_info['imsi']
     if msg.sim_imsi == current_imsi:
         print 'deleting message: ', msg.sim_index
         try:
             tichy.Service('SIM').remove_message(msg)
         except Exception, e:
             print e
Ejemplo n.º 3
0
    def run(self, window, category='main'):
        self.category = category
        main = self.category == 'main'
        frame = self.view(window, title=self.category,
                          back_button=not main)
        # We populate the frame with all the applications
        self.list_view = None
        self._populate(frame)

        def run_lock(action, app, view):
            tichy.Service('ScreenLock').run(view.window)

        lock_item = frame.actor.new_action('Screen Lock')
        # the item does not really toggle back.
        # we will need a one that does 'launched' probably
        lock_item.connect('activated', run_lock)

        # If the design change we repopulate the frame This is a
        # little bit tricky. We use the 'changed' signal from the
        # Service('Design') base object...

        def on_design_changed(s, design):
            self._populate(frame)
        tichy.Service('Design').base.connect('changed', on_design_changed)

        quit_item = frame.actor.new_action('Quit')
        yield tichy.WaitFirst(tichy.Wait(quit_item, 'activated'),
                              tichy.Wait(frame, 'back'))
Ejemplo n.º 4
0
 def run(self, window):
     """Create a new box for the notifications"""
     self.box = gui.Box(window, axis=0)
     notifications_service = tichy.Service('Notifications')
     notifications_service.connect('new-notification',
                                   self.on_new_notification)
     yield None
Ejemplo n.º 5
0
 def save(cls):
     """Save all the phone contacts"""
     logger.info("Saving phone messages")
     messages = tichy.Service('Messages').messages
     data = [c.to_dict() for c in messages if isinstance(c, PhoneMessage)]
     tichy.Persistance('messages/Phone').save(data)
     yield None
Ejemplo n.º 6
0
 def save(cls):
     """Save all the phone contacts"""
     LOGGER.info("Saving phone contacts")
     contacts = tichy.Service('Contacts').contacts
     data = [c.to_dict() for c in contacts if isinstance(c, PhoneContact)]
     tichy.Persistance('contacts/phone').save(data)
     yield None
Ejemplo n.º 7
0
 def edit(self, window, name='number', **kargs):
     text_edit = tichy.Service('TextEdit')
     return text_edit.edit(window,
                           self,
                           input_method='number',
                           name=name,
                           **kargs)
Ejemplo n.º 8
0
 def run(self, window):
     frame = self.view(window, title="Outbox", back_button=True)
     vbox = gui.Box(frame, axis=1, expand=True)
     messages_service = tichy.Service('Messages')
     # We create a view on actors of every items in the outbox
     messages_service.outbox.actors_view(vbox)
     yield tichy.Wait(frame, 'back')
Ejemplo n.º 9
0
 def import_(cls, contact):
     """create a new contact from an other contact)
     """
     assert not isinstance(contact, SIMContact)
     sim = tichy.Service('SIM')
     ret = yield sim.add_contact(contact.name, contact.tel)
     yield ret
Ejemplo n.º 10
0
 def release(self):
     if self.status in ['releasing', 'released']:
         return
     gsm_service = tichy.Service('GSM')
     gsm_service._release(self)
     self.status = 'releasing'
     self.emit(self.status)
Ejemplo n.º 11
0
    def run(self, window, text="", name=None, input_method=None):
        """Edit a text object

        The actual value of the text object will be modifed only when
        we quit the app.
        """
        text = tichy.Text.as_type(text)

        title = "Edit %s" % name if name else "Edit Text"
        frame = self.view(window, title=title, back_button="OK")
        vbox = gui.Box(frame, axis=1, border=0, spacing=0)

        self.text = tichy.Text(text)
        self.text.view(vbox, editable=True, auto_keyboard=False, expand=True)

        self.keyboard = tichy.Service('Keyboard').get()
        if input_method:
            self.keyboard.set_input_method(input_method)

        self.keyboard.view(vbox)

        yield tichy.Wait(frame, 'back')

        text.value = self.text.value
        yield self.text.value
Ejemplo n.º 12
0
    def get_contact(self):
        """Return the `Contact` that has this number

        :Returns: `Contact` | None
        """
        contacts_service = tichy.Service('Contacts')
        contacts = contacts_service.find_by_number(self.value)
        return contacts[0] if contacts else None
Ejemplo n.º 13
0
 def on_save(self, action, item, w):
     service = tichy.Service('FileBrowser')
     path = yield service.get_save_path(self.window, 'untitled')
     logger.info("saving drawing to %s", path)
     try:
         pygame.image.save(self.draw_widget.surface, path)
     except Exception, e:
         logger.error("%s", e)
Ejemplo n.º 14
0
 def on_open(self, b):
     # Unfortunately The XWindow won't hide by itself
     self.x_window.hide()
     service = tichy.Service('FileBrowser')
     path = yield service.get_load_path(b.window)
     self.x_window.show()
     logger.info("opening %s", path)
     self.play(path)
Ejemplo n.º 15
0
 def _on_copy_to(self, action, contact, view, cls):
     try:
         contact = yield cls.import_(self)
         tichy.Service('Contacts').add(contact)
     except Exception, ex:
         LOGGER.error("can't import contact : %s", ex)
         yield tichy.Dialog(view.window, "Error",
                            "can't import the contact")
Ejemplo n.º 16
0
 def _on_delete(self, item, contact, view):
     try:
         yield contact.delete()
         yield tichy.Service('Contacts').remove(contact)
     except Exception, ex:
         LOGGER.error("can't delete contact : %s", ex)
         yield tichy.Dialog(view.window, "Error",
                            "can't delete the contact")
Ejemplo n.º 17
0
 def on_load(self, action, item, w):
     service = tichy.Service('FileBrowser')
     path = yield service.get_load_path(self.window)
     logger.info("loading %s", path)
     try:
         self.draw_widget.surface = pygame.image.load(path)
     except Exception, e:
         logger.error("%s", e)
Ejemplo n.º 18
0
 def on_incoming_message(self, index):
     logger.info("Incoming message %d", index)
     message = self.sim_iface.RetrieveMessage(index)
     status = str(message[0])
     peer = str(message[1])
     text = unicode(message[2])
     sms = SMS(peer, text, 'in')
     tichy.Service('Messages').add_to_messages(sms)
Ejemplo n.º 19
0
 def save_new_contact(self,emission, source, param,name_object=None,number=None,first_window=None):
     print "save new contact called"
     name = name_object.text_field.text_get()
     number = number
     
     try:
         contact = tichy.Service('Contacts').create(name=str(name), number=str(number))
     except Exception,e:
         print e
Ejemplo n.º 20
0
    def __init__(self,
                 peer,
                 text,
                 direction,
                 status=None,
                 timestamp=None,
                 sim_index=None,
                 sim_imsi=None,
                 msg_hash=None):
        """Create a new message

        :Parameters:

            peer : `TelNumber` | str
                the number / contact of the peer of the message. Its
                __repr__ method will be used as the item's name.

            text : `Text` | unicode
                The text of the message

            direction : str
                the direction of the message. Can be 'in' or 'out'

            status : str
                the status of the message. Can be 'read' or
                'unread'. If set to None, incoming message will have
                'unread' status and outgoing message will have 'read'
                status

            timestamp
                the time at which we received the message. If set to
                None we use the current time
        """

        storage = None

        if sim_imsi == None:
            sim_imsi = tichy.Service('SIM').sim_info['imsi']

        self.peer = TelNumber.as_type(peer)
        self.text = tichy.Text.as_type(text)
        self.sim_index = sim_index
        self.sim_imsi = sim_imsi
        #TODO: fix timestamp to recognize timezones
        import time
        if timestamp == None:
            my_time = time.localtime()
        else:
            my_time = timestamp[:24]
        #print time
        self.timestamp = tichy.Time.as_time(my_time)
        assert direction in ['in', 'out'], direction
        self.direction = direction
        self.status = status or direction == 'out' and 'read' or 'unread'
        assert self.status in ['read', 'unread'], status
        self.msg_hash = str(self.sim_imsi) + str(self.sim_index) + str(
            self.timestamp)
Ejemplo n.º 21
0
    def run(self, window):
        frame = self.view(window, back_button=True)

        vbox = gui.Box(frame, axis=1, expand=True)

        gsm_service = tichy.Service('GSM')
        gsm_service.logs.actors_view(vbox)

        yield tichy.Wait(frame, 'back')
Ejemplo n.º 22
0
 def on_open(self, action, item, view):
     service = tichy.Service('FileBrowser')
     path = yield service.get_load_path(view.window)
     logger.info("open file %s", path)
     try:
         # XXX: add checks that the file is a text file !
         file = open(path)
         self.open(file)
     except Exception, e:
         logger.error("%s", e)
Ejemplo n.º 23
0
    def initiate(self):
        """Initiate the call

        This will try to get the 'GSM' service and call its 'initiate'
        method.
        """
        gsm_service = tichy.Service('GSM')
        gsm_service._initiate(self)
        self.status = 'initiating'
        self.emit(self.status)
Ejemplo n.º 24
0
    def edit(self, window):
        """Return a `tasklet` that can be used to edit the message

        :Parameters:

            window : gui.Widget
               The window where we start the edit application
        """
        editor = tichy.Service('EditMessage')
        yield editor.edit(self, window)
Ejemplo n.º 25
0
    def view_details(self, window):
        """return a `Tasklet` that can be used to view the message details

        :Parameters:

            window : gui.Widget
               The window where we start the application
        """
        editor = tichy.Service('EditMessage')
        yield editor.view_details(self, window)
Ejemplo n.º 26
0
 def save_number(self, emission, source, param):
     print "save number in dialer"
     name = self.extra_child.text_field.text_get()
     print name
     number = emission.part_text_get('number')
     print number
     contacts_service = tichy.Service('Contacts')
     try:
         contact = contacts_service.create(str(name), tel=str(number))
     except Exception, e:
         print e
Ejemplo n.º 27
0
 def send(self, sms):
     logger.info("Storing message to %s", sms.peer)
     message_id = yield WaitDBus(self.sim_iface.StoreMessage, str(sms.peer),
                                 unicode(sms.text), {})
     logger.info("Done, id : %s", message_id)
     logger.info("Sending message")
     yield WaitDBus(self.sim_iface.SendStoredMessage, message_id)
     logger.info("Done")
     # We store a copy cause we don't want to modify the stored sms.
     logger.info("Store message into messages")
     #sms = SMS(sms.peer, sms.text, 'out')
     tichy.Service('Messages').add_to_messages(sms)
Ejemplo n.º 28
0
    def update(self):
        logger.info("update sms inbox")
        status = yield WaitDBus(self.sim_iface.GetSimReady)
        status = yield WaitDBus(self.sim_iface.GetAuthStatus)
        messages = yield WaitDBus(self.sim_iface.RetrieveMessagebook, "all")
        logger.info("found %s messages into sim", len(messages))

        messages_service = tichy.Service('Messages')
        for msg in messages:
            id, status, number, text = msg
            sms = self.create(str(number), unicode(text), 'in')
            messages_service.add_to_messages(sms)
Ejemplo n.º 29
0
    def run(self, window):
        # We register into gsm
        gsm_status = tichy.Text('...')
        gsm_status.view(window)

        def on_step(msg):
            gsm_status.value = msg

        def on_provider_modified(service, provider):
            on_step(provider)

        gsm_service = tichy.Service('GSM')
        sim_service = tichy.Service('SIM')
        sms_service = tichy.Service('SMS')
        gsm_service.connect('provider-modified', on_provider_modified)
        try:
            # start the registration process
            yield gsm_service.register(on_step)
        # Note : That is a little hackish, I should only filter GSM errors
        except Exception, e:
            logger.error("Error: %s", e)
            gsm_status.value = 'GSM Error'
Ejemplo n.º 30
0
 def do_run(self, parent, *args, **kargs):
     """You shouldn't change this, redefine the run method instead"""
     # Before trunning the app we set the default design the the
     # one specified by the application
     if self.design:
         old_design = tichy.Service('Design')
         tichy.Service.set_default('Design', self.design)
     window = tichy.gui.Window(parent, modal=True, expand=True)
     ret = yield super(Application, self).do_run(window, *args, **kargs)
     window.destroy()
     if self.design:
         tichy.Service.set_default('Design', old_design)
     yield ret