Пример #1
0
    def run(self, parent=None, standalone=False):

        ##set edje_file
        self.edje_file = join(dirname(__file__), 'telephony.edj')

        self.window = ElementaryLayoutWindow(self.edje_file, "main", None,
                                             None, True)
        self.edje_obj = self.window.main_layout

        ##connect to tichy's contacts service
        self.contact_service = Service.get('Contacts')

        ##connect to tichy's ussd service
        self.ussd_service = Service.get('Ussd')
        self.edje_obj.add_callback("num_field_pressed", "*",
                                   self.num_field_action)

        self.edje_obj.add_callback("*", "embryo", self.embryo)
        self.edje_obj.add_callback("*", "call", self.call)

        ## close the Tele app, with the back button
        self.edje_obj.add_callback("back", "edje", self.signal)

        parent.emit("unblock")

        ##wait until main object emits back signal or delete is requested
        i, args = yield WaitFirst(Wait(self.window, 'delete_request'),
                                  Wait(self.window, 'back'),
                                  Wait(self.window.window, 'closing'),
                                  Wait(self.edje_obj, 'back'))
        logger.info('Tele closing')

        if i != 2:
            self.window.delete()
Пример #2
0
    def send_sms(self, sms):
        """tasklet that performs the sending process

        connects to SIM service and tries sending the sms, if it fails
        it opens an error dialog, if it succeeds it deletes the edje
        window it it given
        """
        logger.info("send message called")
        message_service = Service.get('Messages')
        message = message_service.create(number=sms.peer,
                                         text=sms.text,
                                         direction='out')
        dialog = Service.get("Dialog")
        try:
            #logger.info("sending message: %s to : %s", sms.text, sms.peer)
            yield message.send()
            yield dialog.dialog(None, "Report", "Message sent to %s",
                                unicode(sms.peer).encode("utf-8"))
        except Exception, e:
            logger.exception("Got error %s", e)
            message.status = 'unsent'
            message_service.add(message)
            yield dialog.dialog(
                None, "MSgs Error",
                "unable to send message, saved as draft Error was %s", e)
Пример #3
0
    def init(self):
        logger.info("connecting to freesmartphone.Preferences dbus interface")
        try:
            yield Service.get('GSM').wait_initialized()
            yield Service.get('Config').wait_initialized()
            yield WaitDBusName('org.freesmartphone.opreferencesd',
                               time_out=120)
            # We create the dbus interfaces to org.freesmarphone
            self.bus = dbus.SystemBus(mainloop=mainloop.dbus_loop)
            self.prefs = self.bus.get_object(
                'org.freesmartphone.opreferencesd',
                '/org/freesmartphone/Preferences')
            self.prefs = dbus.Interface(self.prefs,
                                        'org.freesmartphone.Preferences')

            self.config_service = Service.get("Config")
            self.values = self.config_service.get_items("RingProfile")
            if self.values != None: self.values = dict(self.values)

            profile = Setting('phone',
                              'profile',
                              Text,
                              value=self.get_profile(),
                              setter=self.set_profile,
                              options=self.get_profiles(),
                              listenObject=self.prefs,
                              signal="Notify")

            if self.values != None:
                yield self.set_profile(self.values['profile'])

        except Exception, e:
            logger.exception("can't use freesmartphone Preferences : %s", e)
            self.prefs = None
Пример #4
0
    def run(self, parent, standalone=False):

        ##set edje file to be used
        ##TODO: make one edje file per plugin
        self.edje_file = join(dirname(__file__), 'messages.edj')

        ##get message service and list of all messages
        self.contact_service = Service.get('Contacts')
        self.contacts = self.contact_service.contacts

        ##sort contact by date
        def comp2(m1, m2):
            return cmp(str(m1.name).lower(), str(m2.name).lower())

        self.contacts.sort(comp2)

        ##get message service and list of all messages
        self.msgs_service = Service.get('Messages')

        self.messages = self.msgs_service.messages

        self.window = ElementaryListWindow(self.edje_file, "main", "list",
                                           None, None, True)
        self.edje_obj = self.window.main_layout

        ##sort messages by date
        def comp(m1, m2):
            return cmp(m2.timestamp, m1.timestamp)

        self.list_label = [('label', 'peer'), ('label-number', 'text'),
                           ('status', 'status'), ('direction', 'direction')]

        self.item_list = ElementaryList(self.messages, self.window,
                                        self.edje_file, "item",
                                        self.list_label, comp)

        self.edje_obj.add_callback("*", "messaging", self.create_msg)
        self.item_list.add_callback("*", "messaging", self.adv_msg)
        self.item_list.add_callback("save", "*", self.create_contact)

        ## close the Tele app, with the back button (signal, source, method)
        self.edje_obj.add_callback("back", "edje", self.signal)

        self.oid = self.contacts.connect('inserted',
                                         self.item_list._redraw_view)

        self.item_list.add_callback("details", "*", self.msg_details)

        parent.emit("unblock")

        i, args = yield WaitFirst(Wait(self.window, 'delete_request'),
                                  Wait(self.window, 'back'),
                                  Wait(self.window.window, 'closing'))
        logger.info('Messages closing')

        if i != 2:
            self.contacts.disconnect(self.oid)
            self.window.delete()
            del self.item_list
Пример #5
0
 def call(self, parent, number, name=None):
     self.storage = Service.get('TeleCom2')
     if self.storage.call == None:
         return TeleCaller2('nothing', number, name)
     else:
         self.dialog = Service.get('Dialog')
         return self.dialog.dialog(None, "Error",
                                   "there is already an active call")
Пример #6
0
Файл: wifi.py Проект: vmx/paroli
    def init(self):
        logger.info('wifi service init')
        try:
            self.config_service = Service.get("Config")
            yield self.config_service.wait_initialized()
            self.usage_service = Service.get('Usage')
            yield self.usage_service.wait_initialized()
            yield self.usage_service.request_resource('Wifi')
            bus = dbus.SystemBus(mainloop=mainloop.dbus_loop)

            ## power related
            power_obj = bus.get_object('org.freesmartphone.odeviced', 
                                       '/org/freesmartphone/Device/PowerControl/WiFi')
            self.power_iface = dbus.Interface(power_obj, 
                                              'org.freesmartphone.Device.PowerControl')
            try_num = 0
            obj = None
            ## devicing
            for i in range(5):
                    try:
                        obj = bus.get_object("org.moblin.connman", "/")
                        logger.info("moblin success")
                    except:
                        logger.info("moblin failed")
                        yield WaitFirst(Sleep(1))
                        continue
                    else:
                        break
                        #raise Exception("moblin not starting")
            if obj:
                self.devicing_iface = dbus.Interface(
                                           obj, 
                                           "org.moblin.connman.Manager")
                self.status_setting = tichy.settings.ToggleSetting(
                                            'wifi', 'power', 
                                            Text, value=self.get_power(), 
                                            setter=self.power, 
                                            options=['active','inactive'])
                self.NetworkList = List()
                self.ListLabel = [('title','name'),('subtitle','info')]
                self.scan_setting = tichy.settings.ListSetting('wifi', 
                                                               'scan', 
                                                               Text, 
                                                               value="Networks", 
                                                               setter=self.run_scan, 
                                                               options=['Networks'], 
                                                               model=self.NetworkList, 
                                                               ListLabel=self.ListLabel)
                if self.get_power():
                    self.get_device()
                self.devicing_iface.connect_to_signal('PropertyChanged', 
                                                      self.property_changed)
                self.connect("closing", self.closing)
            else: 
                logger.error("Moblin failed. Is Connman/moblin installed?")
        except Exception, e:
            logger.exception("can't use wifi service : %s", e)
            raise
Пример #7
0
 def run(self):
     # We don't create any window, just run in the background...
     # warning; that would only work with gtk or etk backend...
     gsm_service = Service.get('GSM')
     while True:
         call = yield Wait(gsm_service, 'incoming-call')
         logger.info("got incoming call")
         caller_service = Service.get('TeleCaller2')
         yield caller_service.call("None", call)
Пример #8
0
    def init(self):
        yield Service.get('Config').wait_initialized()
        self.config_service = Service.get("Config")
        self.values = self.config_service.get_items("Messages")

        if self.values != None: self.values = dict(self.values)
        logger.info("init done")
        self.ReportSetting = Setting('Messages', 'Delivery Report', Text, value=self.GetDeliveryReport(), setter=self.SetParam, options=["on","off"])
        yield None
Пример #9
0
 def _on_copy_to(self, action, contact, view, cls):
     try:
         contact = yield cls.import_(self)
         Service.get('Contacts').add(contact)
     except Exception, ex:
         logger.exception("can't import contact : %s", ex)
         yield Dialog(
             view.window,
             "Error",  # TODO where does this "Dialog" come from?!?
             "can't import the contact")
Пример #10
0
    def _ask_pin(self):
        #window = tichy.Service.get("WindowsManager").get_app_parent()
        window = None
        editor = Service.get('TelePIN2')
        sim = Service.get('SIM')

        status = sim.GetAuthStatus()
        logger.info("asking for: %s", status)

        if status in ["SIM PIN", "SIM PIN2"]:
            pin_status = True
            ranger = 3
        else:
            pin_status = False
            ranger = 9

        for i in range(ranger):
            pin = yield editor.edit(window,
                                    name="Enter " + str(status),
                                    input_method='number')
            try:
                if pin_status:
                    yield sim.send_pin(pin)
                    break
                else:
                    new_pin_one = yield editor.edit(window,
                                                    name="Enter new PIN",
                                                    input_method='number')
                    new_pin_two = yield editor.edit(window,
                                                    name="Enter new PIN again",
                                                    input_method='number')
                    if new_pin_one == new_pin_two:
                        sim.Unlock(pin, new_pin_one)
                        break
                    else:
                        text = "The two PINs entered don't match.<br/>Setting PIN to 0000. Please change it later."
                        dialog = Service.get("Dialog")
                        yield dialog.dialog(None, "Error", text)
                        sim.Unlock(pin, "0000")
                        break
            except sim.PINError:
                dialog = Service.get("Dialog")
                if status != "SIM PIN" and status != "SIM PIN2":
                    number = 9 - i
                else:
                    number = 2 - i
                text = "Incorrect " + str(status) + " " + str(
                    number) + " trials left"
                yield dialog.dialog(None, "Error", text)
                if i == ranger:  # after ranger times we give up - depends on PIN/PUK
                    raise
                logger.exception("pin wrong : %s", pin)
Пример #11
0
    def activate(self):
        """Activate the call"""
        logger.info("activate call")
        gsm_service = Service.get('GSM')

        # we need to set the scenario file
        audio_service = Service.get('Audio')
        audio_service.push_scenario('gsmhandset')
        logger.info("gsmhandset .state file pushed!+!!")

        yield gsm_service._activate(self)
        self.status = 'activating'
        self.emit(self.status)
Пример #12
0
 def num_field(self, emission, signal, source):
     logger.info("num field pressed")
     number = emission.part_text_get(source)
     if number == None or len(number) == 0:
         logger.info("no number found")
         createService = Service.get('ContactCreate')
         num = yield createService.contactList(self.window,
                                               self.window.main_layout)
         emission.part_text_set('num_field-text', str(num.tel))
     else:
         logger.info("number found")
         service = Service.get('ContactCreate')
         service.create(self.window, str(number)).start()
         emission.part_text_set('num_field-text', "")
Пример #13
0
    def _ask_pin(self):

        window = None
        editor = Service.get('TelePIN2')
        sim = Service.get('SIM')
        for i in range(4):
            pin = yield editor.edit(window, name="Enter PIN",
                                    input_method='number')
            try:
                yield sim.send_pin(pin)
                break
            except sim.PINError:
                if i == 4: # after 3 times we give up
                    raise
                logger.exception("pin wrong : %s", pin)
Пример #14
0
    def get_contact(self):
        """Return the `Contact` that has this number

        :Returns: `Contact` | None
        """
        contacts_service = Service.get('Contacts')
        return contacts_service.get_by_number(self.value)
Пример #15
0
 def set(self, value):
     """Try to set the Setting value and block until it is done"""
     prefs = Service.get('Prefs')
     # XXX: make this asynchronous
     prefs[self.group][self.name] = value
     self.options.emit('updated')
     yield None
Пример #16
0
 def save(cls):
     """Save all the phone contacts"""
     logger.info("Saving phone contacts")
     contacts = Service.get('Contacts').contacts
     data = [c.to_dict() for c in contacts if isinstance(c, PhoneContact)]
     Persistance('contacts/phone').save(data)
     yield None
Пример #17
0
 def save(cls):
     """Save all the phone messages"""
     logger.info("Saving phone messages")
     messages = Service.get('Messages').messages
     data = [c.to_dict() for c in messages if isinstance(c, PhoneMessage)]
     Persistance('messages/phone').save(data)
     yield None
Пример #18
0
    def send(self, sms):
        #logger.info("Sending message to %s", sms.peer)
        yield Sleep(2)
        logger.info("Store message into messages")
        yield Service.get('Messages').add(sms)

        yield None
Пример #19
0
 def import_(cls, contact):
     """create a new contact from an other contact)
     """
     assert not isinstance(contact, SIMContact)
     sim = Service.get('SIM')
     ret = yield sim.add_contact(contact.name, contact.tel)
     yield ret
Пример #20
0
 def send_dtmf(self, code):
     """Send one or more Dual Tone Multiple Frequency (DTMF)
     signals during an active call"""
     gsm_service = Service.get('GSM')
     if self.status != 'active':
         raise Exception("Can't send DMTF to a call that is not active")
     yield gsm_service._send_dtmf(self, code)
Пример #21
0
 def __init__(self, name, rep_part, val_range, type_arg):
     self.service = Service.get('SysTime')
     self.name = name
     self.value = time.localtime(
         self.service.rtc.GetCurrentTime())[rep_part]
     self.rep_part = rep_part
     self.val_range = val_range
     self.val_type = type_arg
Пример #22
0
 def delete_msg(self, emission, signal, source, item, layout):
     logger.info("delete message called")
     message = item
     try:
         messages_service = Service.get('Messages')
         messages_service.remove(message).start()
     except Exception, ex:
         logger.exception("Got error %s", ex)
Пример #23
0
 def to_dict(self):
     """return the message attributes in a python dict"""
     service = Service.get('SIM')
     return {
         'peer': str(self.peer),
         'text': unicode(self.text),
         'timestamp': str(self.timestamp),
         'direction': self.direction,
         'status': self.status
     }
Пример #24
0
    def unblock_screen(self, *args, **kargs):
        logger.info('unblocking screen')
        for app in self.app_objs:
            if self.app_objs[app][1] != 0:
                service = Service.get(self.app_objs[app][1][0])
                attr = self.app_objs[app][1][1]
                if hasattr(service, attr):
                    connector = getattr(service, attr)
                    connector.connect('modified', self._set_subtext, app)
                    self._set_subtext(connector.value, app)

        self.edje_obj.edje.signal_emit("ready", "*")
Пример #25
0
    def initiate(self):
        """Initiate the call

        This will try to get the 'GSM' service and call its 'initiate'
        method.
        """
        logger.info("initiate call")
        gsm_service = Service.get('GSM')

        if self.direction == 'out':
            # we need to set the scenario file
            audio_service = Service.get('Audio')
            audio_service.push_scenario('gsmhandset')
        else:  # 'in'
            # we need to set the scenario file
            audio_service = Service.get('Audio')
            audio_service.push_scenario('stereoout')

        yield gsm_service._initiate(self)
        self.status = 'initiating'
        self.emit(self.status)
Пример #26
0
 def release(self):
     logger.info("release call")
     if self.status in ['releasing', 'released']:
         return
     gsm_service = Service.get('GSM')
     try:
         yield gsm_service._release(self)
     except Exception, e:
         logger.exception('released')
         #XXX should the call get a
         #logger.debug('call error')
         self.emit("error", e)
         self.status = 'released'
Пример #27
0
    def init(self):
        """register on the network"""
        logger.info("Turn on antenna power")
        logger.info("Register on the network")
        self.emit('provider-modified', "Charlie Telecom")
        self.network_strength = 100
        yield Service.get('Config').wait_initialized()
        self.config_service = Service.get("Config")
        logger.info("got config service")
        self.values = self.config_service.get_items("call_forwarding")
        if self.values != None: self.values = dict(self.values)
        logger.info("realized values is none")
        self.SettingReason = ListSetting('Call Forwarding', 'Reason', Text, value='unconditional', setter=self.ForwardingSetReason, options=["unconditional","mobile busy","no reply","not reachable","all","all conditional"], model=List([ListSettingObject("unconditional", self.action),ListSettingObject("mobile busy", self.action),ListSettingObject("no reply", self.action),ListSettingObject("not reachable", self.action),ListSettingObject("all", self.action),ListSettingObject("all conditional", self.action)]), ListLabel = [('title','name')])
        self.SettingChannels = Setting('Call Forwarding', 'channels', Text, value=self.ForwardingGet('class'), setter=self.ForwardingSetClass, options=["voice","data","voice+data","fax","voice+data+fax"])
        self.SettingTargetNumber = NumberSetting('Call Forwarding', 'Target Number', Text, value=self.ForwardingGet('number'), setter=self.ForwardingSetNumber)
        self.SettingTargetNumber = NumberSetting('Call Forwarding', 'Timeout', Text, value=self.ForwardingGet('timeout'), setter=self.ForwardingSetTimeout)

        if len(self.logs) == 0:
            for i in range(3):
                call = Call('0049110', direction='out')
                self.logs.insert(0, call)
        yield None
Пример #28
0
    def init(self):
        logger.info('init')
        try:
            yield Service.get('GSM').wait_initialized()
            yield Service.get('Config').wait_initialized()
            self.config_service = Service.get('Config')
            self.audio_service = Service.get('Audio')
            self.vibra_service = Service.get('Vibrator')
            self.values = self.config_service.get_items("sounds")
            if self.config_service.get_items("sounds") == None:
                self.config_service.set_item(
                    'sounds', "ringtone_file",
                    "/usr/share/sounds/ringtone_ringnroll.wav")
                self.config_service.set_item('sounds', "smstone_file",
                                             "/usr/share/sounds/alarm.wav")
                self.config_service.set_item('sounds', "callvibra", "1")
                self.config_service.set_item('sounds', "smsvibra", "1")

            self.values = dict(self.config_service.get_items("sounds"))
            logger.info("sounds service active")

        except Exception, e:
            logger.exception("can't use sounds service : %s", e)
Пример #29
0
 def init(self):
     logger.info("audio.py->init()")
     yield Service.get('GSM').wait_initialized()
     yield self._connect_dbus()
     if self.device != None:
         self.mic_state = self.get_mic_status()
         ##XXX: currently not working method in Framework so we assume 40
         #self.speaker_volume = self.get_speaker_volume()
         self.speaker_volume = Int(50)
     Setting('phone', 'ring-volume', Int, options=[0, 25, 50, 75, 100])
     Setting('phone', 'message-volume', Int, options=[0, 25, 50, 75, 100])
     Setting('phone', 'ring-vibration', bool, options=[False, True])
     Setting('phone', 'message-vibration', bool, options=[False, True])
     yield None
Пример #30
0
Файл: gui.py Проект: vmx/paroli
 def __init__(self, edje_file, group, x=1.0, y=1.0, tb=False, onclick=None):
     self.window = ElementaryWindow()
     self.tb_action = onclick or 'back'
     self.topbar = Service.get("TopBar").create(self, self.tb_action, tb)
     self.bg = self.topbar.bg
     self.main_layout = ElementaryLayout(self.window,
                                         edje_file,
                                         group,
                                         x=1.0,
                                         y=1.0)
     self.bg.elm_obj.content_set("content-swallow",
                                 self.main_layout.elm_obj)
     self.window.elm_obj.resize_object_add(self.bg.elm_obj)
     self.window.elm_obj.show()
     self.bg.elm_obj.show()