def on_transfer_started(self, session, filename, local_path, total_bytes): session.transfer["progress_dialog"] = BluetoothProgressDialog() session.transfer["progress_dialog"].set_keep_above(True) info = session.server.GetServerSessionInfo(session.object_path) try: dev = Device( Adapter(Manager().get_default_adapter()).create_device( info["BluetoothAddress"])) name = dev.get_alias() except Exception, e: print e name = info["BluetoothAddress"]
def message_receiver(self, *message): (message_type, message_content) = message if message_type == "send_plug_id": (module_id, plug_id) = message_content content_page = content_page_info.get_content_page(module_id) content_page.add_plug_id(plug_id) elif message_type == "send_module_info": (crumb_index, (module_id, crumb_name), argv) = message_content if argv == "": action_bar.bread.remove_node_after_index(0) action_bar.bread.add(Crumb(crumb_name, None)) else: menu_items = [ThemeItem(x) for x in argv.split(';') if x.strip()] action_bar.bread.add(Crumb(crumb_name, menu_items)) backward_module_id, forward_module_id = record_module_history(module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "send_submodule_info": (crumb_index, crumb_name, module_id) = message_content action_bar.bread.remove_node_after_index(1) action_bar.bread.add(Crumb(crumb_name, None)) backward_module_id, forward_module_id = record_module_history(module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "change_crumb": crumb_index = message_content action_bar.bread.remove_node_after_index(crumb_index) elif message_type == "goto": print "goto" (module_id, module_uid) = message_content action_bar.bread.remove_node_after_index(0) call_module_by_name(module_id, module_dict, slider, content_page_info, "right", module_uid) backward_module_id, forward_module_id = record_module_history(module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "back": index = message_content action_bar.bread.remove_node_after_index(index) elif message_type == "status": (module_id, status) = message_content if foot_box: foot_box.show(module_id) if status == "hide_reset": foot_box.hide_reset() elif status == "show_reset": foot_box.show_reset() else: foot_box.set_status(status) elif message_type == "dialog": (module_id, dialog_type, message, argv) = message_content if module_id == "bluetooth": if dialog_type == "progress": if argv == "": self.bluetooth_progress_dialog = BluetoothProgressDialog( cancel_cb = self.__on_bluetooth_cancel) self.bluetooth_progress_dialog.set_message(message) self.bluetooth_progress_dialog.show_all() elif argv == "-1": self.bluetooth_progress_dialog.destroy() else: self.bluetooth_progress_dialog.set_progress(int(argv)) elif dialog_type == "reply": is_succeed = True if argv == "False": is_succeed = False reply_dlg = BluetoothReplyDialog(message, is_succeed = is_succeed) # reply_dlg.place_center(application.window) reply_dlg.show_all() else: print message
class DBusService(dbus.service.Object): def __init__(self, action_bar, content_page_info, application=None, module_dict=None, slider=None, foot_box=None ): # Init dbus object. bus_name = dbus.service.BusName(APP_DBUS_NAME, bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, APP_OBJECT_NAME) self.bluetooth_progress_dialog = None # Define DBus method. def unique(self, module_name): global previous_module_id if application: if module_name != "" and (previous_module_id != module_name or content_page_info.get_active_module_id() == "main"): action_bar.bread.remove_node_after_index(0) call_module_by_name(module_name, module_dict, slider, content_page_info, "right", "") application.raise_to_top() def message_receiver(self, *message): (message_type, message_content) = message if message_type == "send_plug_id": (module_id, plug_id) = message_content content_page = content_page_info.get_content_page(module_id) content_page.add_plug_id(plug_id) elif message_type == "send_module_info": (crumb_index, (module_id, crumb_name), argv) = message_content if argv == "": action_bar.bread.remove_node_after_index(0) action_bar.bread.add(Crumb(crumb_name, None)) else: menu_items = [ThemeItem(x) for x in argv.split(';') if x.strip()] action_bar.bread.add(Crumb(crumb_name, menu_items)) backward_module_id, forward_module_id = record_module_history(module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "send_submodule_info": (crumb_index, crumb_name, module_id) = message_content action_bar.bread.remove_node_after_index(1) action_bar.bread.add(Crumb(crumb_name, None)) backward_module_id, forward_module_id = record_module_history(module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "change_crumb": crumb_index = message_content action_bar.bread.remove_node_after_index(crumb_index) elif message_type == "goto": print "goto" (module_id, module_uid) = message_content action_bar.bread.remove_node_after_index(0) call_module_by_name(module_id, module_dict, slider, content_page_info, "right", module_uid) backward_module_id, forward_module_id = record_module_history(module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "back": index = message_content action_bar.bread.remove_node_after_index(index) elif message_type == "status": (module_id, status) = message_content if foot_box: foot_box.show(module_id) if status == "hide_reset": foot_box.hide_reset() elif status == "show_reset": foot_box.show_reset() else: foot_box.set_status(status) elif message_type == "dialog": (module_id, dialog_type, message, argv) = message_content if module_id == "bluetooth": if dialog_type == "progress": if argv == "": self.bluetooth_progress_dialog = BluetoothProgressDialog( cancel_cb = self.__on_bluetooth_cancel) self.bluetooth_progress_dialog.set_message(message) self.bluetooth_progress_dialog.show_all() elif argv == "-1": self.bluetooth_progress_dialog.destroy() else: self.bluetooth_progress_dialog.set_progress(int(argv)) elif dialog_type == "reply": is_succeed = True if argv == "False": is_succeed = False reply_dlg = BluetoothReplyDialog(message, is_succeed = is_succeed) # reply_dlg.place_center(application.window) reply_dlg.show_all() else: print message # Below code export dbus method dyanmically. # Don't use @dbus.service.method ! setattr(DBusService, 'message_receiver', dbus.service.method(APP_DBUS_NAME)(message_receiver)) setattr(DBusService, 'unique', dbus.service.method(APP_DBUS_NAME)(unique)) def __set_ward(self, backward_module_count=None, forward_module_count=None): if backward_module_count: action_bar.forward_button.set_sensitive(True) action_bar.forward_button.set_active(True) else: action_bar.forward_button.set_sensitive(False) action_bar.forward_button.set_active(False) if forward_module_count: action_bar.backward_button.set_sensitive(True) action_bar.backward_button.set_active(True) else: action_bar.backward_button.set_sensitive(False) action_bar.backward_button.set_active(False) def __on_bluetooth_cancel(self): send_message("bluetooth", "cancel", "progress cancel")
def message_receiver(self, *message): (message_type, message_content) = message if message_type == "send_plug_id": (module_id, plug_id) = message_content content_page = content_page_info.get_content_page(module_id) content_page.add_plug_id(plug_id) elif message_type == "send_module_info": (crumb_index, (module_id, crumb_name), argv) = message_content if argv == "": action_bar.bread.remove_node_after_index(0) action_bar.bread.add(Crumb(crumb_name, None)) else: menu_items = [ ThemeItem(x) for x in argv.split(';') if x.strip() ] action_bar.bread.add(Crumb(crumb_name, menu_items)) backward_module_id, forward_module_id = record_module_history( module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "send_submodule_info": (crumb_index, crumb_name, module_id) = message_content action_bar.bread.remove_node_after_index(1) action_bar.bread.add(Crumb(crumb_name, None)) backward_module_id, forward_module_id = record_module_history( module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "change_crumb": crumb_index = message_content action_bar.bread.remove_node_after_index(crumb_index) elif message_type == "goto": print "goto" (module_id, module_uid) = message_content action_bar.bread.remove_node_after_index(0) call_module_by_name(module_id, module_dict, slider, content_page_info, "right", module_uid) backward_module_id, forward_module_id = record_module_history( module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "back": index = message_content action_bar.bread.remove_node_after_index(index) elif message_type == "status": (module_id, status) = message_content if foot_box: foot_box.show(module_id) if status == "hide_reset": foot_box.hide_reset() elif status == "show_reset": foot_box.show_reset() else: foot_box.set_status(status) elif message_type == "dialog": (module_id, dialog_type, message, argv) = message_content if module_id == "bluetooth": if dialog_type == "progress": if argv == "": self.bluetooth_progress_dialog = BluetoothProgressDialog( cancel_cb=self.__on_bluetooth_cancel) self.bluetooth_progress_dialog.set_message(message) self.bluetooth_progress_dialog.show_all() elif argv == "-1": self.bluetooth_progress_dialog.destroy() else: self.bluetooth_progress_dialog.set_progress( int(argv)) elif dialog_type == "reply": is_succeed = True if argv == "False": is_succeed = False reply_dlg = BluetoothReplyDialog(message, is_succeed=is_succeed) # reply_dlg.place_center(application.window) reply_dlg.show_all() else: print message
class DBusService(dbus.service.Object): def __init__(self, action_bar, content_page_info, application=None, module_dict=None, slider=None, foot_box=None): # Init dbus object. bus_name = dbus.service.BusName(APP_DBUS_NAME, bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, APP_OBJECT_NAME) self.bluetooth_progress_dialog = None # Define DBus method. def unique(self, module_name): global previous_module_id if application: if module_name != "" and ( previous_module_id != module_name or content_page_info.get_active_module_id() == "main"): action_bar.bread.remove_node_after_index(0) call_module_by_name(module_name, module_dict, slider, content_page_info, "right", "") application.raise_to_top() def message_receiver(self, *message): (message_type, message_content) = message if message_type == "send_plug_id": (module_id, plug_id) = message_content content_page = content_page_info.get_content_page(module_id) content_page.add_plug_id(plug_id) elif message_type == "send_module_info": (crumb_index, (module_id, crumb_name), argv) = message_content if argv == "": action_bar.bread.remove_node_after_index(0) action_bar.bread.add(Crumb(crumb_name, None)) else: menu_items = [ ThemeItem(x) for x in argv.split(';') if x.strip() ] action_bar.bread.add(Crumb(crumb_name, menu_items)) backward_module_id, forward_module_id = record_module_history( module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "send_submodule_info": (crumb_index, crumb_name, module_id) = message_content action_bar.bread.remove_node_after_index(1) action_bar.bread.add(Crumb(crumb_name, None)) backward_module_id, forward_module_id = record_module_history( module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "change_crumb": crumb_index = message_content action_bar.bread.remove_node_after_index(crumb_index) elif message_type == "goto": print "goto" (module_id, module_uid) = message_content action_bar.bread.remove_node_after_index(0) call_module_by_name(module_id, module_dict, slider, content_page_info, "right", module_uid) backward_module_id, forward_module_id = record_module_history( module_id) self.__set_ward(backward_module_id, forward_module_id) elif message_type == "back": index = message_content action_bar.bread.remove_node_after_index(index) elif message_type == "status": (module_id, status) = message_content if foot_box: foot_box.show(module_id) if status == "hide_reset": foot_box.hide_reset() elif status == "show_reset": foot_box.show_reset() else: foot_box.set_status(status) elif message_type == "dialog": (module_id, dialog_type, message, argv) = message_content if module_id == "bluetooth": if dialog_type == "progress": if argv == "": self.bluetooth_progress_dialog = BluetoothProgressDialog( cancel_cb=self.__on_bluetooth_cancel) self.bluetooth_progress_dialog.set_message(message) self.bluetooth_progress_dialog.show_all() elif argv == "-1": self.bluetooth_progress_dialog.destroy() else: self.bluetooth_progress_dialog.set_progress( int(argv)) elif dialog_type == "reply": is_succeed = True if argv == "False": is_succeed = False reply_dlg = BluetoothReplyDialog(message, is_succeed=is_succeed) # reply_dlg.place_center(application.window) reply_dlg.show_all() else: print message # Below code export dbus method dyanmically. # Don't use @dbus.service.method ! setattr(DBusService, 'message_receiver', dbus.service.method(APP_DBUS_NAME)(message_receiver)) setattr(DBusService, 'unique', dbus.service.method(APP_DBUS_NAME)(unique)) def __set_ward(self, backward_module_count=None, forward_module_count=None): if backward_module_count: action_bar.forward_button.set_sensitive(True) action_bar.forward_button.set_active(True) else: action_bar.forward_button.set_sensitive(False) action_bar.forward_button.set_active(False) if forward_module_count: action_bar.backward_button.set_sensitive(True) action_bar.backward_button.set_active(True) else: action_bar.backward_button.set_sensitive(False) action_bar.backward_button.set_active(False) def __on_bluetooth_cancel(self): send_message("bluetooth", "cancel", "progress cancel")