Exemple #1
0
    def _disconnected_cb(self, dialer):
        # Log disconnection attempt
        self._conn_logger.register_disconnection_attempt(
            self.actual_connection)

        if self.connection_successful == False:
            if self.abort_now_flag == True:
                self.__abort_connection_actions()
                self.abort_now_flag == False
                self.reconnect_on_disconnect = False
                tgcm.debug("DISCONNECTED (Aborted)")
                return

            self.actual_connection = None
            self.waiting_connection = None
            self.connection_successful = None

            if self.is_in_first_reconnection_with_smart_connector:
                self.is_in_first_reconnection_with_smart_connector = False
                self.do_connect_with_smart_connector(
                    skip_connection_index=self.connection_index)
                return

            if self.smart_connector == False:
                self.error_on_connection()
            else:
                #self.connection_zone.do_connect_with_smart_connector()
                self.__connect_with_smart_connector()

        else:
            self.is_in_first_reconnection_with_smart_connector = False
            self.reconnect_on_disconnect = self.reconnect_on_disconnect and self._conf.get_reconnect_on_disconnect(
            )
            if self.reconnect_on_disconnect:
                if self.smart_connector == True:
                    tgcm.info("Trying reconnect with smart_connector %s" %
                              self.actual_connection['name'])
                    if (self.connect_to_connection(
                            connection_settings=self.actual_connection,
                            smart_connector=True) == 0):
                        self.is_in_first_reconnection_with_smart_connector = True
                    else:
                        self.do_connect_with_smart_connector(
                            skip_connection_index=self.connection_index)

                else:
                    tgcm.info("Reconnect to connection")
                    self.connect_to_connection(
                        connection_settings=self.actual_connection,
                        smart_connector=False)

            else:
                self.actual_connection = None
                if self.abort_now_flag == True:
                    self.__abort_connection_actions()
                    self.abort_now_flag == False
                    tgcm.debug("DISCONNECTED (Aborted)")
                    return

        tgcm.debug("DISCONNECTED ---")
Exemple #2
0
    def __init__(self, conn_manager):
        tgcm.info("Init tgcmActionsManager")
        self._actions_manager = tgcm.core.Actions.ActionManager()
        self.conn_manager = conn_manager
        self.systray = None

        self.action_list = self._actions_manager.get_actions()
Exemple #3
0
 def _connect_on_startup(self):
     if self._config.get_connect_on_startup():
         if self.device_dialer.nmConnectionState(
         ) == NetworkManager.State.DISCONNECTED:
             tgcm.info("Trying to connect on startup...")
             MSDConnManager = tgcm.ui.MSD.MSDConnectionsManager()
             MSDConnManager.do_connect_with_smart_connector()
Exemple #4
0
    def __init__(self):
        tgcm.info("Init MSDAInternet")
        tgcm.ui.MSD.MSDAction.__init__(self, "internet")

        theme_manager = tgcm.core.Theme.ThemeManager()
        self.taskbar_icon_name = 'internet_taskbar.png'
        self.window_icon_path = theme_manager.get_icon('icons',
                                                       self.taskbar_icon_name)

        self.browser_by_default_checkbutton = self.get_prefs_widget(
            "browser_by_default_checkbutton")
        self.initial_webpage_entry = self.get_prefs_widget(
            "initial_webpage_entry")

        if self._get_conf_key_value("url") is not None:
            self.initial_webpage_entry.set_text(
                self._get_conf_key_value("url"))

        if self._get_conf_key_value("open_browser_by_default") == True:
            self.browser_by_default_checkbutton.set_active(True)
        else:
            self.browser_by_default_checkbutton.set_active(False)
            self.initial_webpage_entry.set_sensitive(False)

        self.browser_by_default_checkbutton.connect(
            "toggled", self.__browser_checkbutton_cb, None)
        self.initial_webpage_entry.connect("changed",
                                           self.__initial_webpage_entry_cb,
                                           None)
    def __new_connection_active_dialog(self, connection_name, action, bookmark_info):
        tgcm.info("new-connection-dialog")
        if action == None and bookmark_info == None:
            if self._connection_manager.get_ask_before_connect() == False:
                return 2
        else:
            if self._connection_manager.get_ask_before_connect_to_action() == False:
                return 2

        dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO)
        vbox = dlg.vbox
        check_button = gtk.CheckButton(_("Do not ask again"))
        vbox.pack_end(check_button, expand=False)
        check_button.set_property("has-focus", False)
        check_button.set_property("has-default", False)
        check_button.set_property("can-focus", False)
        check_button.set_property("can-default", False)
        check_button.show()

        if connection_name == None:
            if action != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_SERVICE_TITLE % action.get_visible_action_name())

            if bookmark_info != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE % bookmark_info.name)

            if action == None and bookmark_info == None:
                dlg.set_markup(MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_TITLE)

            message = self._connection_manager.get_default_connection_name()
            if message == "None":
                message = ""
            dlg.format_secondary_markup (MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_CONN % message)
        else:
            if action != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_SERVICE_TITLE  % action.get_visible_action_name())
                dlg.format_secondary_markup (MSG_CONN_MANAGER_OPEN_SERVICE  % connection_name)
            if bookmark_info != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE % bookmark_info.name)
                dlg.format_secondary_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK % connection_name)
            if action == None and bookmark_info == None:
                dlg.set_markup(MSG_CONN_MANAGER_CONNECT_TO_CONN_TITLE)
                dlg.format_secondary_markup (MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_CONN % connection_name)

        dlg.add_buttons(gtk.STOCK_CANCEL, 1, gtk.STOCK_CONNECT, 2)
        dlg.set_default_response(2)
        ret = dlg.run()
        dlg.destroy()

        if action == None and bookmark_info == None:
            if ret > 1:
                self._connection_manager.set_ask_before_connect(not check_button.get_active())
        else:
            if ret > 1:
                self._connection_manager.set_ask_before_connect_to_action(not check_button.get_active())

        return ret
    def _disconnected_cb(self, dialer):
        # Log disconnection attempt
        self._conn_logger.register_disconnection_attempt(self.actual_connection)

        if self.connection_successful == False:
            if self.abort_now_flag == True:
                self.__abort_connection_actions()
                self.abort_now_flag == False
                self.reconnect_on_disconnect=False
                tgcm.debug("DISCONNECTED (Aborted)")
                return

            self.actual_connection = None
            self.waiting_connection = None
            self.connection_successful = None

            if self.is_in_first_reconnection_with_smart_connector:
                self.is_in_first_reconnection_with_smart_connector=False
                self.do_connect_with_smart_connector(skip_connection_index=self.connection_index)
                return

            if self.smart_connector==False:
                self.error_on_connection()
            else:
                #self.connection_zone.do_connect_with_smart_connector()
                self.__connect_with_smart_connector()


        else:
            self.is_in_first_reconnection_with_smart_connector=False
            self.reconnect_on_disconnect=self.reconnect_on_disconnect and self._conf.get_reconnect_on_disconnect()
            if self.reconnect_on_disconnect:
                if self.smart_connector==True:
                    tgcm.info("Trying reconnect with smart_connector %s" % self.actual_connection['name'])
                    if (self.connect_to_connection(connection_settings=self.actual_connection,smart_connector=True)==0):
                        self.is_in_first_reconnection_with_smart_connector=True
                    else:
                        self.do_connect_with_smart_connector(skip_connection_index=self.connection_index)

                else:
                    tgcm.info("Reconnect to connection")
                    self.connect_to_connection(connection_settings=self.actual_connection,smart_connector=False)

            else:
                self.actual_connection = None
                if self.abort_now_flag == True:
                    self.__abort_connection_actions()
                    self.abort_now_flag == False
                    tgcm.debug("DISCONNECTED (Aborted)")
                    return

        tgcm.debug("DISCONNECTED ---")
Exemple #7
0
    def __init__(self):
        tgcm.info("Init CZSelfcare")

        tgcm.ui.MSD.MSDAction.__init__(self, "selfcare")

        theme_manager = tgcm.core.Theme.ThemeManager()
        self.taskbar_icon_name = "selfcare_taskbar.png"
        self.window_icon_path = theme_manager.get_icon("icons", self.taskbar_icon_name)

        self.device_manager = tgcm.core.FreeDesktop.DeviceManager()
        self.security_manager = tgcm.ui.MSD.MSDSecurityManager()
        self.action_dir = os.path.join(tgcm.actions_data_dir, self.codename)
        self.device_dialer = tgcm.core.FreeDesktop.DeviceDialer()
Exemple #8
0
    def __init__(self):
        tgcm.info("Init CZSelfcare")

        tgcm.ui.MSD.MSDAction.__init__(self, "selfcare")

        theme_manager = tgcm.core.Theme.ThemeManager()
        self.taskbar_icon_name = 'selfcare_taskbar.png'
        self.window_icon_path = theme_manager.get_icon('icons',
                                                       self.taskbar_icon_name)

        self.device_manager = tgcm.core.FreeDesktop.DeviceManager()
        self.security_manager = tgcm.ui.MSD.MSDSecurityManager()
        self.action_dir = os.path.join(tgcm.actions_data_dir, self.codename)
        self.device_dialer = tgcm.core.FreeDesktop.DeviceDialer()
Exemple #9
0
    def __init__(self):
        tgcm.info ("Init DERecharge")

        tgcm.ui.MSD.MSDAction.__init__(self, "prepay")

        self.device_manager = tgcm.core.FreeDesktop.DeviceManager()
        self.taskbar_icon_name = 'prepay_taskbar.png'
        self.security_manager = tgcm.ui.MSD.MSDSecurityManager()
        self.action_dir = os.path.join(tgcm.actions_data_dir , self.codename)
        self.theme_manager = tgcm.core.Theme.ThemeManager()
        self.window_icon_path = self.theme_manager.get_icon('icons', self.taskbar_icon_name)

        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'DERecharge_main.ui'), \
                prefix='der')

        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'DERecharge_recharge.ui'), \
                prefix='der')

        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'DERecharge_plan.ui'), \
                prefix='der')

        parent = tgcm.ui.ThemedDock().get_main_window()
        self.recharge_dialog = tgcm.ui.windows.Dialog( \
                parent = parent, buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE), \
                title = "%s - %s" % (self.conf.get_app_name(), "o2credit"))

        # FIXME: We are always loading unnecessary services independently of the
        # country support. Sometimes that situation causes many problems, for example
        # when a theme-related resource is required and it is only available in the
        # theme package of a specific country.
        if self.window_icon_path is not None:
            self.recharge_dialog.set_icon_from_file(self.window_icon_path)

        self.hovering_over_link = False
        self.hand_cursor = gtk.gdk.Cursor(gtk.gdk.HAND2)
        self.regular_cursor = gtk.gdk.Cursor(gtk.gdk.XTERM)

        self.recharge_button.connect("clicked", self.__recharge_button_cb, None)
        self.balance_button.connect("clicked", self.__balance_button_cb, None)
        self.plan_button.connect("clicked", self.__plan_button_cb, None)
        self.plan_management_textview.connect("key-press-event", self.__key_press_event)
        self.plan_management_textview.connect("event-after", self.__event_after)
        self.plan_management_textview.connect("motion-notify-event", self.__motion_notify_event)
        self.plan_management_textview.connect("visibility-notify-event", self.__visibility_notify_event)

        self.recharge_dialog.add(self.main_widget)
Exemple #10
0
    def __set_current_mode_domain(self, device, status=None):
        ''' Configures the technology (mode) and domain of the WWAN device to the last
        values established by the user or the operator '''

        if status is None:
            status = device.get_card_status()

        if status == CARD_STATUS_READY:
            mode = self._config.get_last_device_mode()
            domain = self._config.get_last_domain()

            device.set_technology(mode)
            device.set_domain(domain)
            tgcm.info("Set regional info domain preferred")

        return False
Exemple #11
0
    def __set_current_mode_domain(self, device, status=None):
        ''' Configures the technology (mode) and domain of the WWAN device to the last
        values established by the user or the operator '''

        if status is None:
            status = device.get_card_status()

        if status == CARD_STATUS_READY:
            mode = self._config.get_last_device_mode()
            domain = self._config.get_last_domain()

            device.set_technology(mode)
            device.set_domain(domain)
            tgcm.info("Set regional info domain preferred")

        return False
    def __detect_active_connection_dialog(self, connection_name, action, bookmark_info):
        tgcm.info("detect-connection-dialog")
        if self._connection_manager.get_ask_before_change_connection() == False:
            return 3

        dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO)
        dlg.set_markup (MSG_CONN_MANAGER_ACTIVE_CONN_DETECT_TITLE)
        vbox = dlg.vbox
        check_button = gtk.CheckButton(_("Do not show this dialogue again"))
        vbox.pack_end(check_button, expand=False)
        check_button.hide()

        if connection_name == None or connection_name == self._connection_manager.get_default_connection_name():
            if action != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_SERVICE_TITLE % action.get_visible_action_name())
                dlg.format_secondary_markup (MSG_CONN_MANAGER_OPEN_SERVICE_WITH_ACTIVE_CONN_DEFAULT % (self.actual_connection["name"], self._connection_manager.get_default_connection_name()))

            if bookmark_info != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE % bookmark_info.name)
                dlg.format_secondary_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK_WITH_ACTIVE_CONN_DEFAULT  % (self.actual_connection["name"], self._connection_manager.get_default_connection_name()))

            if action == None and bookmark_info == None:
                dlg.set_markup(MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_TITLE)
                dlg.format_secondary_markup (MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_WITH_ACTIVE_CONN % (self.actual_connection["name"], self._connection_manager.get_default_connection_name()))
        else:
            if action != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_SERVICE_TITLE % action.get_visible_action_name())
                dlg.format_secondary_markup (MSG_CONN_MANAGER_OPEN_SERVICE_WITH_ACTIVE_CONN % (self.actual_connection["name"], connection_name))
            if bookmark_info != None:
                dlg.set_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE % bookmark_info.name)
                dlg.format_secondary_markup (MSG_CONN_MANAGER_OPEN_BOOKMARK_WITH_ACTIVE_CONN % (self.actual_connection["name"], connection_name))

        dlg.add_buttons(gtk.STOCK_CANCEL, 1, _("_Use established connection"), 2, gtk.STOCK_CONNECT, 3)
        ret = dlg.run()
        dlg.destroy()

        if ret > 1 :
            self._connection_manager.set_ask_before_change_connection(not check_button.get_active())

        return ret
Exemple #13
0
    def __init__(self):
        tgcm.info("Init MSDAInternet")
        tgcm.ui.MSD.MSDAction.__init__(self, "internet")

        theme_manager = tgcm.core.Theme.ThemeManager()
        self.taskbar_icon_name = 'internet_taskbar.png'
        self.window_icon_path = theme_manager.get_icon('icons', self.taskbar_icon_name)

        self.browser_by_default_checkbutton = self.get_prefs_widget("browser_by_default_checkbutton")
        self.initial_webpage_entry = self.get_prefs_widget("initial_webpage_entry")

        if self._get_conf_key_value("url") is not None:
            self.initial_webpage_entry.set_text(self._get_conf_key_value("url"))

        if self._get_conf_key_value("open_browser_by_default") == True :
            self.browser_by_default_checkbutton.set_active(True)
        else:
            self.browser_by_default_checkbutton.set_active(False)
            self.initial_webpage_entry.set_sensitive(False)

        self.browser_by_default_checkbutton.connect("toggled", self.__browser_checkbutton_cb, None)
        self.initial_webpage_entry.connect("changed", self.__initial_webpage_entry_cb, None)
Exemple #14
0
    def __init__(self):
        tgcm.info("Init CZRecharge")

        tgcm.ui.MSD.MSDAction.__init__(self, "prepay")

        self.device_manager = tgcm.core.FreeDesktop.DeviceManager()
        self.taskbar_icon_name = 'prepay_taskbar.png'
        self.security_manager = tgcm.ui.MSD.MSDSecurityManager()
        self.action_dir = os.path.join(tgcm.actions_data_dir, self.codename)
        self.theme_manager = tgcm.core.Theme.ThemeManager()
        self.window_icon_path = self.theme_manager.get_icon(
            'icons', self.taskbar_icon_name)

        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'CZRecharge_main.ui'), \
                prefix='czr')

        parent = tgcm.ui.ThemedDock().get_main_window()
        self.recharge_dialog = tgcm.ui.windows.Dialog( \
                title="%s - %s" % (self.conf.get_app_name(), "Dobíjení Kreditu"), \
                parent = parent, buttons=(gtk.STOCK_CLOSE,  gtk.RESPONSE_CLOSE))

        # FIXME: We are always loading unnecessary services independently of the
        # country support. Sometimes that situation causes many problems, for example
        # when a theme-related resource is required and it is only available in the
        # theme package of a specific country.
        if self.window_icon_path is not None:
            self.recharge_dialog.set_icon_from_file(self.window_icon_path)

        self.recharge_dialog.add(self.main_widget)

        self.number_entry.connect("changed", self.__number_entry_changed_cb,
                                  None)
        self.recharge_button.connect("clicked", self.__request_recharge_cb,
                                     None)
        self.check_button.connect("clicked", self.__request_check_cb, None)

        self.recharge_button.set_sensitive(False)
Exemple #15
0
    def __init__(self):
        tgcm.info("Init MSDAIntranet")
        tgcm.ui.MSD.MSDAction.__init__(self, "intranet")

        self.taskbar_icon_name = 'intranet_taskbar.png'

        self.browser_by_default_checkbutton = self.get_prefs_widget("browser_by_default_checkbutton")
        self.initial_webpage_entry = self.get_prefs_widget("initial_webpage_entry")

        webpage = self._get_conf_key_value("url")
        if webpage == None:
            webpage = ""

        self.initial_webpage_entry.set_text(webpage)

        if self._get_conf_key_value("open_browser_by_default") == True :
            self.browser_by_default_checkbutton.set_active(True)
        else:
            self.browser_by_default_checkbutton.set_active(False)
            self.initial_webpage_entry.set_sensitive(False)

        self.browser_by_default_checkbutton.connect("toggled", self.__browser_checkbutton_cb, None)
        self.initial_webpage_entry.connect("changed", self.__initial_webpage_entry_cb, None)
Exemple #16
0
    def set_mode_domain(self, mode=None, domain=None):
        d = domain
        m = mode
        if d == None:
            d = self.domain
        if m == None:
            m = self.mode

        if d == MobileManager.CARD_DOMAIN_CS_PS:
            tgcm.info("Setting  DOMAIN : CS_PS")
        elif d == MobileManager.CARD_DOMAIN_CS:
            tgcm.info("Setting  DOMAIN : CS")
        elif d == MobileManager.CARD_DOMAIN_PS:
            tgcm.info("Setting  DOMAIN : PS")

        if m == MobileManager.CARD_TECH_SELECTION_AUTO:
            tgcm.info("Setting  MODE : AUTO")
        elif m == MobileManager.CARD_TECH_SELECTION_GPRS:
            tgcm.info("Setting  MODE : GPRS")
        elif m == MobileManager.CARD_TECH_SELECTION_UMTS:
            tgcm.info("Setting  MODE : UMTS")
        elif m == MobileManager.CARD_TECH_SELECTION_GRPS_PREFERED:
            tgcm.info("Setting  MODE : GPRS_PREF")
        elif m == MobileManager.CARD_TECH_SELECTION_UMTS_PREFERED:
            tgcm.info("Setting  MODE : UMTS_PREF")

        if self.__state.SetModeDomain(m, d):
            self.mode = m
            self.domain = d

        return
Exemple #17
0
    def __init__(self, dock_launcher = False, bookmarks_list_store = None):
        tgcm.info("Init MSDABookmarks")
        tgcm.ui.MSD.MSDAction.__init__(self, "favorites")

        self.dock_launcher = dock_launcher
        self.connection_settings_manager = tgcm.core.ConnectionSettingsManager.ConnectionSettingsManager()

        self.action_dir = os.path.join(tgcm.actions_data_dir , self.codename)
        self.taskbar_icon_name = 'favorites_taskbar.png'

        self.connection_manager = tgcm.core.Connections.ConnectionManager()
        self.bookmarks_manager = tgcm.core.Bookmarks.BookmarksManager()
        self.security_manager = tgcm.ui.MSD.MSDSecurityManager()
        self.conf = tgcm.core.Config.Config()
        self.theme_manager = tgcm.core.Theme.ThemeManager()
        self.xml_theme_manager = tgcm.core.XMLTheme.XMLTheme()

        self.conf.connect("bookmark-added", self.__reload_bookmarks)
        self.conf.connect("bookmark-deleted", self.__reload_bookmarks)
        self.conf.connect("bookmark-changed", self.__reload_bookmarks)

        self.connection_manager.connect("connections_changed", self.__connection_manager_changed)

        self.add_bookmark_button = self.get_prefs_widget("add_bookmark_button")
        self.edit_bookmark_button = self.get_prefs_widget("edit_bookmark_button")
        self.del_bookmark_button = self.get_prefs_widget("del_bookmark_button")
        self.open_bookmark_button = self.get_prefs_widget("open_bookmark_button")
        self.bookmarks_treeview = self.get_prefs_widget("bookmarks_treeview")

        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'MSDABookmarks_dialog.ui'), \
                prefix='bmk')

        self.window_icon_path = self.theme_manager.get_icon('icons', self.taskbar_icon_name)
        self.bookmark_dialog.set_icon_from_file(self.window_icon_path)

        self.bd_is_add_dialog = None
        self.bd_show_confirmation = False

        # -- Favorites service dialog, it is shown when 'launch_action()' is executed
        self.dialog = tgcm.ui.windows.ServiceWindow('banner.favorites', _("Favourites"))
        self.dialog.set_icon_from_file(self.window_icon_path)
        self.dialog.resize (750, 500)
        self.dialog_bookmark_container = None

        if tgcm.country_support == "uk":
            self.bd_connection_help_label.set_text (_("(*) If you do not select this option, the connection used will be the one that is currently active or the preferred O2 connection."))

        # Bookmarks confirmation dialog
        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'MSDABookmarks_confirm.ui'), \
                prefix='bmk')

        self.bookmark_confirmation_dialog.set_icon_from_file(self.window_icon_path)
        self.bookmark_confirmation_icon.set_from_file(self.window_icon_path)

        self.importer = tgcm.ui.MSD.MSDImporter ()
        self.importer.bookmarks_treeview = self.bookmarks_treeview
        self.importer.connect("bookmark-imported", self.__bookmark_imported_cb)

        self.dialog.connect('delete-event', self.__dialog_close_event_cb)
        self.dialog.close_button.connect('clicked', self.__dialog_close_event_cb)

        self.bookmark_dialog.connect("delete_event", self.__delete_event_bookmarks_cb)
        if self.bookmarks_manager.can_create_bookmarks ():
            self.add_bookmark_button.connect("clicked", self.__add_bookmark_button_cb, None)
        else:
            self.add_bookmark_button.set_sensitive(False)
        self.edit_bookmark_button.connect("clicked", self.__edit_bookmark_button_cb, None)
        self.del_bookmark_button.connect("clicked", self.__del_bookmark_button_cb, None)
        self.open_bookmark_button.connect('clicked', self.__open_bookmark_button_cb, None)

        self.bookmark_confirmation_dialog.connect("delete_event", self.__delete_event_bookmark_confirmation_cb)
        self.bookmark_confirmation_ok_button.connect("clicked", self.__ok_bookmark_confirmation_button_cb, None)
        self.bookmark_confirmation_dont_show.connect("toggled", self.__dont_show_bookmark_confirmation_cb, None)

        self.bd_url_radio_button.connect("toggled", self.__bd_url_radio_button_cb, None)
        self.bd_check_connection.connect("toggled", self.__bd_check_connection_cb, None)
        self.bd_cancel_button.connect("clicked", self.__bd_cancel_button_cb, None)
        self.bd_ok_button.connect("clicked", self.__bd_ok_button_cb, None)

        treeselection = self.bookmarks_treeview.get_selection()
        treeselection.connect("changed" , self.__bookmarks_treview_row_changed_cb, None)
        self.__bookmarks_treview_row_changed_cb(treeselection, None)

        #Populate bd_connection_combobox
        liststore = self.conn_manager.get_connections_model()
        self.bd_connection_combobox.set_model(liststore)
        cell = gtk.CellRendererText()
        self.bd_connection_combobox.pack_start(cell, True)
        self.bd_connection_combobox.add_attribute(cell, 'text', 1)
        self.bd_connection_combobox.set_active(0)

        #Populate bookmarks in the bookmarks tab treeview
        liststore = gtk.ListStore(tgcm.core.Bookmarks.Bookmark, gtk.gdk.Pixbuf, str, long, str)

        name_column = gtk.TreeViewColumn('bookmark_name')
        self.bookmarks_treeview.append_column(name_column)

        icon_cell = gtk.CellRendererPixbuf()
        name_cell = gtk.CellRendererText()

        name_column.pack_start(icon_cell, False)
        name_column.pack_start(name_cell, True)

        name_column.set_attributes(icon_cell, pixbuf=1)
        name_column.set_attributes(name_cell, text=2)

        if self.dock_launcher == True:
            url_column = gtk.TreeViewColumn('bookmark_url')
            self.bookmarks_treeview.append_column(url_column)

            url_cell = gtk.CellRendererText()
            url_column.pack_start(url_cell, True)

            url_column.set_attributes(url_cell, text=4)

        self.bookmarks_treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
        self.bookmarks_treeview.set_headers_visible(False)

        self.bookmark_icon_pixbuf = self.xml_theme_manager.get_pixbuf('favorite-item')

        if bookmarks_list_store == None :
            self.bookmarks_treeview.set_model(liststore)
            self.load_bookmarks()
            self.bookmarks_treeview.connect("row-activated", self.__on_bookmarks_edit_row_activated)
        else:
            self.bookmarks_treeview.set_model(bookmarks_list_store)
            self.bookmarks_treeview.connect("row-activated", self.__on_bookmarks_row_activated)
Exemple #18
0
    def __init__(self, dock_launcher=False, bookmarks_list_store=None):
        tgcm.info("Init MSDABookmarks")
        tgcm.ui.MSD.MSDAction.__init__(self, "favorites")

        self.dock_launcher = dock_launcher
        self.connection_settings_manager = tgcm.core.ConnectionSettingsManager.ConnectionSettingsManager(
        )

        self.action_dir = os.path.join(tgcm.actions_data_dir, self.codename)
        self.taskbar_icon_name = 'favorites_taskbar.png'

        self.connection_manager = tgcm.core.Connections.ConnectionManager()
        self.bookmarks_manager = tgcm.core.Bookmarks.BookmarksManager()
        self.security_manager = tgcm.ui.MSD.MSDSecurityManager()
        self.conf = tgcm.core.Config.Config()
        self.theme_manager = tgcm.core.Theme.ThemeManager()
        self.xml_theme_manager = tgcm.core.XMLTheme.XMLTheme()

        self.conf.connect("bookmark-added", self.__reload_bookmarks)
        self.conf.connect("bookmark-deleted", self.__reload_bookmarks)
        self.conf.connect("bookmark-changed", self.__reload_bookmarks)

        self.connection_manager.connect("connections_changed",
                                        self.__connection_manager_changed)

        self.add_bookmark_button = self.get_prefs_widget("add_bookmark_button")
        self.edit_bookmark_button = self.get_prefs_widget(
            "edit_bookmark_button")
        self.del_bookmark_button = self.get_prefs_widget("del_bookmark_button")
        self.open_bookmark_button = self.get_prefs_widget(
            "open_bookmark_button")
        self.bookmarks_treeview = self.get_prefs_widget("bookmarks_treeview")

        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'MSDABookmarks_dialog.ui'), \
                prefix='bmk')

        self.window_icon_path = self.theme_manager.get_icon(
            'icons', self.taskbar_icon_name)
        self.bookmark_dialog.set_icon_from_file(self.window_icon_path)

        self.bd_is_add_dialog = None
        self.bd_show_confirmation = False

        # -- Favorites service dialog, it is shown when 'launch_action()' is executed
        self.dialog = tgcm.ui.windows.ServiceWindow('banner.favorites',
                                                    _("Favourites"))
        self.dialog.set_icon_from_file(self.window_icon_path)
        self.dialog.resize(750, 500)
        self.dialog_bookmark_container = None

        if tgcm.country_support == "uk":
            self.bd_connection_help_label.set_text(
                _("(*) If you do not select this option, the connection used will be the one that is currently active or the preferred O2 connection."
                  ))

        # Bookmarks confirmation dialog
        gtk_builder_magic(self, \
                filename=os.path.join(self.action_dir, 'MSDABookmarks_confirm.ui'), \
                prefix='bmk')

        self.bookmark_confirmation_dialog.set_icon_from_file(
            self.window_icon_path)
        self.bookmark_confirmation_icon.set_from_file(self.window_icon_path)

        self.importer = tgcm.ui.MSD.MSDImporter()
        self.importer.bookmarks_treeview = self.bookmarks_treeview
        self.importer.connect("bookmark-imported", self.__bookmark_imported_cb)

        self.dialog.connect('delete-event', self.__dialog_close_event_cb)
        self.dialog.close_button.connect('clicked',
                                         self.__dialog_close_event_cb)

        self.bookmark_dialog.connect("delete_event",
                                     self.__delete_event_bookmarks_cb)
        if self.bookmarks_manager.can_create_bookmarks():
            self.add_bookmark_button.connect("clicked",
                                             self.__add_bookmark_button_cb,
                                             None)
        else:
            self.add_bookmark_button.set_sensitive(False)
        self.edit_bookmark_button.connect("clicked",
                                          self.__edit_bookmark_button_cb, None)
        self.del_bookmark_button.connect("clicked",
                                         self.__del_bookmark_button_cb, None)
        self.open_bookmark_button.connect('clicked',
                                          self.__open_bookmark_button_cb, None)

        self.bookmark_confirmation_dialog.connect(
            "delete_event", self.__delete_event_bookmark_confirmation_cb)
        self.bookmark_confirmation_ok_button.connect(
            "clicked", self.__ok_bookmark_confirmation_button_cb, None)
        self.bookmark_confirmation_dont_show.connect(
            "toggled", self.__dont_show_bookmark_confirmation_cb, None)

        self.bd_url_radio_button.connect("toggled",
                                         self.__bd_url_radio_button_cb, None)
        self.bd_check_connection.connect("toggled",
                                         self.__bd_check_connection_cb, None)
        self.bd_cancel_button.connect("clicked", self.__bd_cancel_button_cb,
                                      None)
        self.bd_ok_button.connect("clicked", self.__bd_ok_button_cb, None)

        treeselection = self.bookmarks_treeview.get_selection()
        treeselection.connect("changed",
                              self.__bookmarks_treview_row_changed_cb, None)
        self.__bookmarks_treview_row_changed_cb(treeselection, None)

        #Populate bd_connection_combobox
        liststore = self.conn_manager.get_connections_model()
        self.bd_connection_combobox.set_model(liststore)
        cell = gtk.CellRendererText()
        self.bd_connection_combobox.pack_start(cell, True)
        self.bd_connection_combobox.add_attribute(cell, 'text', 1)
        self.bd_connection_combobox.set_active(0)

        #Populate bookmarks in the bookmarks tab treeview
        liststore = gtk.ListStore(tgcm.core.Bookmarks.Bookmark, gtk.gdk.Pixbuf,
                                  str, long, str)

        name_column = gtk.TreeViewColumn('bookmark_name')
        self.bookmarks_treeview.append_column(name_column)

        icon_cell = gtk.CellRendererPixbuf()
        name_cell = gtk.CellRendererText()

        name_column.pack_start(icon_cell, False)
        name_column.pack_start(name_cell, True)

        name_column.set_attributes(icon_cell, pixbuf=1)
        name_column.set_attributes(name_cell, text=2)

        if self.dock_launcher == True:
            url_column = gtk.TreeViewColumn('bookmark_url')
            self.bookmarks_treeview.append_column(url_column)

            url_cell = gtk.CellRendererText()
            url_column.pack_start(url_cell, True)

            url_column.set_attributes(url_cell, text=4)

        self.bookmarks_treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
        self.bookmarks_treeview.set_headers_visible(False)

        self.bookmark_icon_pixbuf = self.xml_theme_manager.get_pixbuf(
            'favorite-item')

        if bookmarks_list_store == None:
            self.bookmarks_treeview.set_model(liststore)
            self.load_bookmarks()
            self.bookmarks_treeview.connect(
                "row-activated", self.__on_bookmarks_edit_row_activated)
        else:
            self.bookmarks_treeview.set_model(bookmarks_list_store)
            self.bookmarks_treeview.connect("row-activated",
                                            self.__on_bookmarks_row_activated)
Exemple #19
0
    def __active_device_card_status_changed(self, mcontroller, status):
        device = self._device_manager.get_main_device()

        if status == CARD_STATUS_DETECTED:
            pass

        elif status == CARD_STATUS_CONFIGURED:
            pass

        elif (status == CARD_STATUS_NO_SIM) or (status == CARD_STATUS_ERROR):
            self._connection_logger.register_invalid_imsi()

            self._is_on_startup = False
            self.startup_time = 0
            if self.is_showing_no_sim_dialog == True:
                return

            self.is_showing_no_sim_dialog = True

            # -- Turn the device off before opening the error dialog otherwise the device checker remains triggering
            # -- AT commands to the Mobile Manager
            if device is not None:
                device.turn_off()

            msg = _(
                "The Internet Mobile Device does not have a valid SIM card. Please, check that the SIM card is correctly inserted in the Internet Mobile Device."
            )
            markup = _("<b>SIM not found</b>")
            error_dialog(msg, markup)

            self.is_showing_no_sim_dialog = False

        elif status == CARD_STATUS_PIN_REQUIRED:
            if (time.time() - self.startup_time) < STARTUP_SECS:
                self._is_on_startup = True

            rstatus = device.pin_status()
            device.stop_checker()
            self._device_manager.emit("active-dev-pin-act-status-changed",
                                      True)

            if rstatus != PIN_STATUS_WAITING_PIN:
                tgcm.info("PIN REQUIRED ... not")
                return

            pin_dialog = tgcm.ui.windows.AskPinDialog()
            pin_dialog.run()

        elif status == CARD_STATUS_PUK_REQUIRED:
            if (time.time() - self.startup_time) < STARTUP_SECS:
                self._is_on_startup = True

            tgcm.info("PUK REQUIRED")
            if device.is_on() == False:
                return

            rstatus = device.pin_status()
            device.stop_checker()
            if rstatus != PIN_STATUS_WAITING_PUK:
                tgcm.info("PUK REQUIRED ... not")
                return

            self._device_manager.emit("active-dev-pin-act-status-changed",
                                      True)

            ask_puk = tgcm.ui.windows.PukDialog()
            ask_puk.request()

        elif status == CARD_STATUS_OFF:
            self._is_on_startup = False
            self.startup_time = 0

        elif status == CARD_STATUS_ATTACHING:
            # Check if device is not network locked for this card
            if device.is_operator_locked():
                # Prompt the user to remove the network lock
                self.__ask_network_pin_code(device)

        elif status == CARD_STATUS_READY:
            # Register the device in the connection log
            self._connection_logger.register_new_device(device)

            try:
                self._device_manager.emit("active-dev-roaming-status-changed",
                                          device.is_roaming())
                self._device_manager.emit("active-dev-pin-act-status-changed",
                                          device.is_pin_active())

                # Check if the IMSI has been blacklisted
                is_imsi_allowed = self.__is_imsi_allowed(device)

                # NOTE:
                # Originally the following code was used to ensure that the device was registered
                # in the network with the values established by the operator in the file
                # 'regional-info.xml':
                #
                # if dev.has_domain_preferred:
                #    gobject.timeout_add(3000, self.__set_current_mode_domain)
                #
                # Unfortunately we don't know the reason why the function '__set_current_mode_domain'
                # was being called with a delay of 3 seconds. Calling it directly seems to work
                # well.
                if is_imsi_allowed:

                    # Attempt to establish the correct device mode and domain
                    self.__set_current_mode_domain(device)

                    # Unknown connection procedure
                    if ((time.time() - self.startup_time) < STARTUP_SECS) \
                            or self._is_on_startup:
                        self._is_on_startup = False
                        self.startup_time = 0
                        self._connect_on_startup()
            except DeviceHasNotCapability:
                pass

        elif status == CARD_STATUS_PH_NET_PIN_REQUIRED:
            self.__ask_network_pin_code(device)

        elif status == CARD_STATUS_PH_NET_PUK_REQUIRED:
            pass
Exemple #20
0
 def _connect_on_startup(self):
     if self._config.get_connect_on_startup():
         if self.device_dialer.nmConnectionState() == NetworkManager.State.DISCONNECTED:
             tgcm.info("Trying to connect on startup...")
             MSDConnManager = tgcm.ui.MSD.MSDConnectionsManager()
             MSDConnManager.do_connect_with_smart_connector()
Exemple #21
0
    def __active_device_card_status_changed(self, mcontroller, status):
        device = self._device_manager.get_main_device()

        if status == CARD_STATUS_DETECTED:
            pass

        elif status == CARD_STATUS_CONFIGURED:
            pass

        elif (status == CARD_STATUS_NO_SIM) or (status == CARD_STATUS_ERROR):
            self._connection_logger.register_invalid_imsi()

            self._is_on_startup = False
            self.startup_time = 0
            if self.is_showing_no_sim_dialog == True:
                return

            self.is_showing_no_sim_dialog = True

            # -- Turn the device off before opening the error dialog otherwise the device checker remains triggering
            # -- AT commands to the Mobile Manager
            if device is not None:
                device.turn_off()

            msg = _("The Internet Mobile Device does not have a valid SIM card. Please, check that the SIM card is correctly inserted in the Internet Mobile Device.")
            markup = _("<b>SIM not found</b>")
            error_dialog(msg, markup)

            self.is_showing_no_sim_dialog = False

        elif status == CARD_STATUS_PIN_REQUIRED:
            if  (time.time() - self.startup_time) < STARTUP_SECS:
                self._is_on_startup = True

            rstatus = device.pin_status()
            device.stop_checker()
            self._device_manager.emit("active-dev-pin-act-status-changed",True)

            if rstatus != PIN_STATUS_WAITING_PIN:
                tgcm.info("PIN REQUIRED ... not")
                return

            pin_dialog = tgcm.ui.windows.AskPinDialog()
            pin_dialog.run()

        elif status == CARD_STATUS_PUK_REQUIRED:
            if (time.time() - self.startup_time) < STARTUP_SECS:
                self._is_on_startup = True

            tgcm.info("PUK REQUIRED")
            if device.is_on() == False:
                return

            rstatus = device.pin_status()
            device.stop_checker()
            if rstatus != PIN_STATUS_WAITING_PUK:
                tgcm.info("PUK REQUIRED ... not")
                return

            self._device_manager.emit("active-dev-pin-act-status-changed", True)

            ask_puk = tgcm.ui.windows.PukDialog()
            ask_puk.request()

        elif status == CARD_STATUS_OFF:
            self._is_on_startup = False
            self.startup_time = 0

        elif status == CARD_STATUS_ATTACHING:
            # Check if device is not network locked for this card
            if device.is_operator_locked():
                # Prompt the user to remove the network lock
                self.__ask_network_pin_code(device)

        elif status == CARD_STATUS_READY:
            # Register the device in the connection log
            self._connection_logger.register_new_device(device)

            try:
                self._device_manager.emit("active-dev-roaming-status-changed", device.is_roaming())
                self._device_manager.emit("active-dev-pin-act-status-changed", device.is_pin_active())

                # Check if the IMSI has been blacklisted
                is_imsi_allowed = self.__is_imsi_allowed(device)

                # NOTE:
                # Originally the following code was used to ensure that the device was registered
                # in the network with the values established by the operator in the file
                # 'regional-info.xml':
                #
                # if dev.has_domain_preferred:
                #    gobject.timeout_add(3000, self.__set_current_mode_domain)
                #
                # Unfortunately we don't know the reason why the function '__set_current_mode_domain'
                # was being called with a delay of 3 seconds. Calling it directly seems to work
                # well.
                if is_imsi_allowed:

                    # Attempt to establish the correct device mode and domain
                    self.__set_current_mode_domain(device)

                    # Unknown connection procedure
                    if ((time.time() - self.startup_time) < STARTUP_SECS) \
                            or self._is_on_startup:
                        self._is_on_startup = False
                        self.startup_time = 0
                        self._connect_on_startup()
            except DeviceHasNotCapability:
                pass

        elif status == CARD_STATUS_PH_NET_PIN_REQUIRED:
            self.__ask_network_pin_code(device)

        elif status == CARD_STATUS_PH_NET_PUK_REQUIRED:
            pass
Exemple #22
0
    def set_mode_domain(self, mode=None, domain=None):
        d = domain
        m = mode
        if d == None :
            d = self.domain
        if m == None :
            m = self.mode

        if d == MobileManager.CARD_DOMAIN_CS_PS :
            tgcm.info ("Setting  DOMAIN : CS_PS")
        elif d == MobileManager.CARD_DOMAIN_CS :
            tgcm.info ("Setting  DOMAIN : CS")
        elif d == MobileManager.CARD_DOMAIN_PS :
            tgcm.info ("Setting  DOMAIN : PS")


        if  m == MobileManager.CARD_TECH_SELECTION_AUTO :
            tgcm.info ("Setting  MODE : AUTO")
        elif m == MobileManager.CARD_TECH_SELECTION_GPRS :
            tgcm.info ("Setting  MODE : GPRS")
        elif m == MobileManager.CARD_TECH_SELECTION_UMTS :
            tgcm.info ("Setting  MODE : UMTS")
        elif m == MobileManager.CARD_TECH_SELECTION_GRPS_PREFERED :
            tgcm.info ("Setting  MODE : GPRS_PREF")
        elif m == MobileManager.CARD_TECH_SELECTION_UMTS_PREFERED :
            tgcm.info ("Setting  MODE : UMTS_PREF")

        if self.__state.SetModeDomain(m, d) :
            self.mode = m
            self.domain = d

        return
Exemple #23
0
    def connect_to_connection(self, connection_settings = None, force_connection = False, \
                action = None, bookmark_info = None, url = None, smart_connector = False):
        self.abort_now_flag = False
        self.smart_connector = smart_connector
        device_type = connection_settings["deviceType"]
        connection_name = connection_settings["name"]
        tgcm.info("Trying to connect to %s" % connection_name)
        if self.connect_to_bus() != True:
            return -1

        network_connection_status = self._connection_manager.ppp_manager.nmConnectionState(
        )

        if (device_type == tgcm.core.FreeDesktop.DEVICE_WLAN
                or device_type == tgcm.core.FreeDesktop.DEVICE_WLAN_PROFILE):
            odev = self.mcontroller.get_wifi_device()
            if odev == None:
                return -1
            if self._connection_settings_manager.is_wifi_ap_available(
                    connection_settings) == False:
                return -1

        if (device_type == tgcm.core.FreeDesktop.DEVICE_WIRED):
            odev = self.mcontroller.get_wired_device()
            if odev == None:
                return -1

        elif (device_type == tgcm.core.FreeDesktop.DEVICE_MODEM):

            if self._connection_manager.is_device_selected() == False:
                return -1

            odev = self.mcontroller.get_main_device()

            if odev.get_card_status() is not CARD_STATUS_READY:
                return -1

            if odev == None or odev.get_type(
            ) != tgcm.core.DeviceManager.DEVICE_MODEM:
                self.show_no_available_device_error()
                return -1

            if odev.is_roaming() and bool(
                    self._conf.check_policy('show-roaming-warning')):
                if tgcm.country_support == "es":
                    message = _(
                        "You are about to connect you in roaming and your customary data fares do not apply for the traffic that consummate abroad. Inform yourself of your roaming data fares in the 22119 (free call cost in the European Union; from other countries applicable price to calls with destination Spain according to roaming fare of the line). To control your bill you can define alerts in Escritorio Movistar and will receive notifications when reaching a certain amount of data spent."
                    )
                else:
                    message = _(
                        "You're about to connect while abroad. Network operators have different charges for data usage and costs can soon mount up. To set up alerts so you know approximately how much data you have used go to Settings / Alerts."
                    )
                title = _("Roaming alert")
                response = warning_dialog(msg=message, title=title)
                if response != gtk.RESPONSE_OK:
                    return -2

            if not odev.has_capability(
                    MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI):
                self.cardmanager = None
            else:
                self.cardmanager = odev
                if network_connection_status == PPP_STATUS_DISCONNECTED:
                    if self.cardmanager.get_card_status() != CARD_STATUS_READY:
                        if smart_connector == False:
                            error_dialog(markup=MSG_CONN_MANAGER_NO_CARDMANAGER_TITLE, \
                                    msg=MSG_CONN_MANAGER_NO_CARDMANAGER)
                        return -1

        if action != None:
            self.action = action

        if bookmark_info != None:
            self.bookmark_info = bookmark_info

        if url != None:
            self.url = url

        if network_connection_status == NetworkManager.State.CONNECTED:
            if self.actual_connection is not None and connection_settings[
                    "uuid"] == self.actual_connection["uuid"]:
                self.launch_service()
                return 0

            if force_connection == False:
                ret = self.__detect_active_connection_dialog(
                    connection_name, action, bookmark_info)
            else:
                ret = 3

            if ret == 1 or ret < 0:
                return 0  #Cancelled by the user
            elif ret == 2:
                self.launch_service()
                return 0
            elif ret == 3:
                self._connection_manager.ppp_manager.stop()
                gtk_sleep(0.1)
                self.waiting_connection = connection_settings

        self.reconnect_on_disconnect = None

        password = None
        if connection_settings["ask_password"] == True:
            password = self._ask_password(connection_name)
            if password is None:
                return 0  #Cancelled by the user

        #Reload connection info from gconf based on SIM characteristics
        try:
            if (connection_settings["origin"] != "networkmanager"
                    or connection_settings["ask_password"] == True):
                connection_settings = self._connection_settings_manager.get_connection_info_dict_from_gconf(
                    connection_settings['gconf_path'])
                self._connection_settings_manager.add_wwan_connection(
                    connection_settings,
                    write_gconf_if_required=False,
                    update_if_possible=True,
                    password=password)
                gtk_sleep(1.5)
                #time.sleep(1) #We must give some time to update the connection

        except (RuntimeError, TypeError, NameError):
            tgcm.error("Error in update")
            pass

        self._conf.set_proxy(connection_settings)

        ret = self._connection_manager.ppp_manager.start(
            connection_settings, odev)
        if ret != 0:
            self.action = None
            self.bookmark_info = None

        return ret
    def connect_to_connection(self, connection_settings = None, force_connection = False, \
                action = None, bookmark_info = None, url = None, smart_connector = False):
        self.abort_now_flag = False
        self.smart_connector=smart_connector
        device_type=connection_settings["deviceType"]
        connection_name=connection_settings["name"]
        tgcm.info("Trying to connect to %s" % connection_name)
        if self.connect_to_bus() != True:
            return -1

        network_connection_status = self._connection_manager.ppp_manager.nmConnectionState()

        if (device_type==tgcm.core.FreeDesktop.DEVICE_WLAN or device_type==tgcm.core.FreeDesktop.DEVICE_WLAN_PROFILE):
            odev = self.mcontroller.get_wifi_device()
            if odev == None:
                return -1
            if self._connection_settings_manager.is_wifi_ap_available(connection_settings)==False:
                return -1

        if (device_type==tgcm.core.FreeDesktop.DEVICE_WIRED):
            odev = self.mcontroller.get_wired_device()
            if odev == None:
                return -1

        elif (device_type==tgcm.core.FreeDesktop.DEVICE_MODEM):

            if self._connection_manager.is_device_selected() == False:
                return -1

            odev = self.mcontroller.get_main_device()

            if odev.get_card_status() is not CARD_STATUS_READY:
                return -1

            if odev == None or odev.get_type() != tgcm.core.DeviceManager.DEVICE_MODEM:
                self.show_no_available_device_error()
                return -1

            if odev.is_roaming() and  bool(self._conf.check_policy('show-roaming-warning')):
                if tgcm.country_support == "es":
                    message = _("You are about to connect you in roaming and your customary data fares do not apply for the traffic that consummate abroad. Inform yourself of your roaming data fares in the 22119 (free call cost in the European Union; from other countries applicable price to calls with destination Spain according to roaming fare of the line). To control your bill you can define alerts in Escritorio Movistar and will receive notifications when reaching a certain amount of data spent.")
                else:
                    message = _("You're about to connect while abroad. Network operators have different charges for data usage and costs can soon mount up. To set up alerts so you know approximately how much data you have used go to Settings / Alerts.")
                title = _("Roaming alert")
                response = warning_dialog(msg=message, title=title)
                if response != gtk.RESPONSE_OK:
                    return -2

            if not odev.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI) :
                self.cardmanager = None
            else:
                self.cardmanager = odev
                if network_connection_status == PPP_STATUS_DISCONNECTED:
                    if self.cardmanager.get_card_status() != CARD_STATUS_READY:
                        if smart_connector == False:
                            error_dialog(markup=MSG_CONN_MANAGER_NO_CARDMANAGER_TITLE, \
                                    msg=MSG_CONN_MANAGER_NO_CARDMANAGER)
                        return -1

        if action != None:
            self.action = action

        if bookmark_info != None:
            self.bookmark_info = bookmark_info

        if url != None:
            self.url = url

        if network_connection_status == NetworkManager.State.CONNECTED :
            if self.actual_connection is not None and connection_settings["uuid"]==self.actual_connection["uuid"]:
                self.launch_service()
                return 0

            if force_connection == False:
                ret = self.__detect_active_connection_dialog(connection_name, action, bookmark_info)
            else:
                ret = 3

            if ret == 1 or ret < 0:
                return 0 #Cancelled by the user
            elif ret == 2 :
                self.launch_service()
                return 0
            elif ret == 3:
                self._connection_manager.ppp_manager.stop()
                gtk_sleep(0.1);
                self.waiting_connection = connection_settings


        self.reconnect_on_disconnect=None

        password=None
        if connection_settings["ask_password"] == True:
            password = self._ask_password (connection_name)
            if password is None:
                return 0 #Cancelled by the user


        #Reload connection info from gconf based on SIM characteristics
        try:
            if (connection_settings["origin"]!="networkmanager" or connection_settings["ask_password"]==True):
                connection_settings=self._connection_settings_manager.get_connection_info_dict_from_gconf(connection_settings['gconf_path'])
                self._connection_settings_manager.add_wwan_connection(connection_settings,write_gconf_if_required=False,update_if_possible=True,password=password)
                gtk_sleep(1.5);
                #time.sleep(1) #We must give some time to update the connection

        except (RuntimeError, TypeError, NameError):
            tgcm.error("Error in update")
            pass


        self._conf.set_proxy(connection_settings)

        ret=self._connection_manager.ppp_manager.start(connection_settings,odev)
        if ret!=0:
            self.action = None
            self.bookmark_info =None

        return ret
Exemple #25
0
    def __detect_active_connection_dialog(self, connection_name, action,
                                          bookmark_info):
        tgcm.info("detect-connection-dialog")
        if self._connection_manager.get_ask_before_change_connection(
        ) == False:
            return 3

        dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO)
        dlg.set_markup(MSG_CONN_MANAGER_ACTIVE_CONN_DETECT_TITLE)
        vbox = dlg.vbox
        check_button = gtk.CheckButton(_("Do not show this dialogue again"))
        vbox.pack_end(check_button, expand=False)
        check_button.hide()

        if connection_name == None or connection_name == self._connection_manager.get_default_connection_name(
        ):
            if action != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_SERVICE_TITLE %
                               action.get_visible_action_name())
                dlg.format_secondary_markup(
                    MSG_CONN_MANAGER_OPEN_SERVICE_WITH_ACTIVE_CONN_DEFAULT %
                    (self.actual_connection["name"],
                     self._connection_manager.get_default_connection_name()))

            if bookmark_info != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE %
                               bookmark_info.name)
                dlg.format_secondary_markup(
                    MSG_CONN_MANAGER_OPEN_BOOKMARK_WITH_ACTIVE_CONN_DEFAULT %
                    (self.actual_connection["name"],
                     self._connection_manager.get_default_connection_name()))

            if action == None and bookmark_info == None:
                dlg.set_markup(MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_TITLE)
                dlg.format_secondary_markup(
                    MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_WITH_ACTIVE_CONN %
                    (self.actual_connection["name"],
                     self._connection_manager.get_default_connection_name()))
        else:
            if action != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_SERVICE_TITLE %
                               action.get_visible_action_name())
                dlg.format_secondary_markup(
                    MSG_CONN_MANAGER_OPEN_SERVICE_WITH_ACTIVE_CONN %
                    (self.actual_connection["name"], connection_name))
            if bookmark_info != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE %
                               bookmark_info.name)
                dlg.format_secondary_markup(
                    MSG_CONN_MANAGER_OPEN_BOOKMARK_WITH_ACTIVE_CONN %
                    (self.actual_connection["name"], connection_name))

        dlg.add_buttons(gtk.STOCK_CANCEL, 1, _("_Use established connection"),
                        2, gtk.STOCK_CONNECT, 3)
        ret = dlg.run()
        dlg.destroy()

        if ret > 1:
            self._connection_manager.set_ask_before_change_connection(
                not check_button.get_active())

        return ret
Exemple #26
0
    def __new_connection_active_dialog(self, connection_name, action,
                                       bookmark_info):
        tgcm.info("new-connection-dialog")
        if action == None and bookmark_info == None:
            if self._connection_manager.get_ask_before_connect() == False:
                return 2
        else:
            if self._connection_manager.get_ask_before_connect_to_action(
            ) == False:
                return 2

        dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO)
        vbox = dlg.vbox
        check_button = gtk.CheckButton(_("Do not ask again"))
        vbox.pack_end(check_button, expand=False)
        check_button.set_property("has-focus", False)
        check_button.set_property("has-default", False)
        check_button.set_property("can-focus", False)
        check_button.set_property("can-default", False)
        check_button.show()

        if connection_name == None:
            if action != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_SERVICE_TITLE %
                               action.get_visible_action_name())

            if bookmark_info != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE %
                               bookmark_info.name)

            if action == None and bookmark_info == None:
                dlg.set_markup(MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_TITLE)

            message = self._connection_manager.get_default_connection_name()
            if message == "None":
                message = ""
            dlg.format_secondary_markup(
                MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_CONN % message)
        else:
            if action != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_SERVICE_TITLE %
                               action.get_visible_action_name())
                dlg.format_secondary_markup(MSG_CONN_MANAGER_OPEN_SERVICE %
                                            connection_name)
            if bookmark_info != None:
                dlg.set_markup(MSG_CONN_MANAGER_OPEN_BOOKMARK_TITLE %
                               bookmark_info.name)
                dlg.format_secondary_markup(MSG_CONN_MANAGER_OPEN_BOOKMARK %
                                            connection_name)
            if action == None and bookmark_info == None:
                dlg.set_markup(MSG_CONN_MANAGER_CONNECT_TO_CONN_TITLE)
                dlg.format_secondary_markup(
                    MSG_CONN_MANAGER_CONNECT_TO_DEFAULT_CONN % connection_name)

        dlg.add_buttons(gtk.STOCK_CANCEL, 1, gtk.STOCK_CONNECT, 2)
        dlg.set_default_response(2)
        ret = dlg.run()
        dlg.destroy()

        if action == None and bookmark_info == None:
            if ret > 1:
                self._connection_manager.set_ask_before_connect(
                    not check_button.get_active())
        else:
            if ret > 1:
                self._connection_manager.set_ask_before_connect_to_action(
                    not check_button.get_active())

        return ret