Beispiel #1
0
 def delete_contact(self, emission, source, param, contact, details_window,
                    contacts_edje_obj, graphic_objects):
     print "delete contact called"
     graphic_objects[0].remove_all()
     details_window.edj.delete()
     contacts_service = Service('Contacts')
     contacts_service.remove(contact)
Beispiel #2
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()
Beispiel #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
Beispiel #4
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)
Beispiel #5
0
 def delete_message(self,emission, source, param, message, details_window, messages_edje_obj, canvas_obj):
     print "delete message called"
     canvas_obj.remove_all()
     details_window.edj.delete()
     messages_service = Service('Messages')
     #if message.direction == 'in':
     messages_service.delete_message(message)
Beispiel #6
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
Beispiel #7
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")
Beispiel #8
0
    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
Beispiel #9
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
Beispiel #10
0
 def edit(self, window, **kargs):
     """return a `Tasklet` that can be used to edit the widget"""
     # first we get the appropriate TextEdit Service
     text_edit = Service('TextEdit')
     # Then we call the service with our text
     return text_edit.edit(window,
                           self,
                           input_method=self.input_method(),
                           **kargs)
Beispiel #11
0
 def call_contact(self, emission, source, param, contact):
     print "call contact called"
     number = contact.number.value
     name = unicode(contact)
     #self.extra_child.edj.part_swallow_get('contacts-items').visible_set(0)
     #self.extra_child.edj.part_swallow_get('contacts-items').delete()
     caller_service = Service('Caller')
     my_call = caller_service.call(emission, number, name)
     my_call.start()
Beispiel #12
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)
Beispiel #13
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
     contacts_service = Service('Contacts')
     
     try:
         contact = contacts_service.create(name=str(name),tel=str(number))
     except Exception,e:
         print e
Beispiel #14
0
    def click(self):
        if self.auto_keyboard:
            # first we get the appropriate TextEdit Service
            text_edit = Service('TextEdit')
            # Then we call the service with our text

            def on_done(text):
                self.text = text
                self.item.value = text
            text_edit.edit(self.window, self.text).start(on_done)
Beispiel #15
0
 def call_contact(self, emission, source, param):
     number = emission.part_text_get('number-text')
     name = emission.part_text_get('name-text')
     caller_service = Service('Caller')
     my_call = caller_service.call(emission, number, name)
     my_call.start()
     try:
         emission.delete()
     except Exception,e:
         print e
Beispiel #16
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")
Beispiel #17
0
def main(*args):
    options = parse_options()

    setup_logging()
    tichy.mainloop = EventsLoop()
    config.parse(cfg_file=options.cfg_file)

    if config.getboolean('dbus', 'activated', False):
        logger.info("connect to dbus")
        if options.bus == 'system':
            bus = dbus.SystemBus(mainloop=tichy.mainloop.dbus_loop)
        else:
            bus = dbus.SessionBus(mainloop=tichy.mainloop.dbus_loop)

        if bus.list_activatable_names().count('org.tichy.launcher') != 0:
            logger.info("paroli already running")
            if options.launch:
                logger.info("running launch")
                launch(options.launch, options)
                sys.exit(0)

        bus_name = dbus.service.BusName('org.tichy.launcher', bus)

        logger.info("start launcher service")
        launcher = Launcher(bus, '/Launcher')

    # We set the default service before importing the plugins
    set_default_services()

    # We import all the modules into the plugin directory
    default_plugins_path = '/usr/share/paroli/plugins'
    plugins_dirs = config.get('plugins', 'path', default_plugins_path)
    for plugins_dir in [d.strip() for d in plugins_dirs.split(',')]:
        logger.debug('plugins_dir: %s', plugins_dir)
        try:
            logger.info("try to load plugins in %s", plugins_dir)
            import_all(plugins_dir)
        except IOError:
            logger.info("failed to load plugins in %s", plugins_dir)

    logger.info("start InitAll")
    InitAll().start()

    app_name = config.get('autolaunch', 'application', None)
    if app_name:
        standalone = config.getboolean('standalone', 'activated', False)
        for app in Application.subclasses:
            if app.name == app_name:
                app("None", standalone=standalone).start()

    logger.info("starting mainloop")
    tichy.mainloop.run()
    Service.end_all()

    logger.info("quit")
Beispiel #18
0
    def view(self, parent, **kargs):
        """Create a view of a frame for the application in the parent widget

        :Parameters:

            parent : gui.Widget
                The parent widget we create the view in
        """
        # The 'Design' service is in charge of creating the frame
        design = Service('Design')
        return design.view_application(parent, self, **kargs)
Beispiel #19
0
def set_default_services():
    """Set default services"""
    defaults = config.get('services', 'defaults', None)
    if not defaults:
        return {}
    defaults = defaults.split(',')

    for default in defaults:
        if not default:
            continue
        service, name = default.strip().split(':')
        Service.set_default(service, name)
Beispiel #20
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)
Beispiel #21
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)
Beispiel #22
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', "")
Beispiel #23
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)
Beispiel #24
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
Beispiel #25
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)
Beispiel #26
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)
Beispiel #27
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
Beispiel #28
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
Beispiel #29
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
Beispiel #30
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