示例#1
0
    def __install_item_success_hook(self, entry_data, item_to_install):
        if entry_data is None:
            tgcm.debug('Error: empty item data!')
            self.__call_install_callback_if_possible(False)
            return False

        tgcm.debug('Item download successful')

        tmp_file = tempfile.NamedTemporaryFile()
        tmp_file.write(entry_data)
        tmp_file.seek(0)

        entry_tag = item_to_install['tags'][0]['term']
        is_success = False
        if entry_tag == 'update-hotspots':
            is_success = self.hs_service.register_new_hotspot_file(tmp_file.name)
        else:
            is_success = self.importer.update_bookmarks_and_connections_from_file (tmp_file.name)

        tmp_file.close()

        if is_success:
            self.mark_as_installed(item_to_install['id'])

        self.__call_install_callback_if_possible(is_success)

        return False
示例#2
0
    def __install_item_success_hook(self, entry_data, item_to_install):
        if entry_data is None:
            tgcm.debug('Error: empty item data!')
            self.__call_install_callback_if_possible(False)
            return False

        tgcm.debug('Item download successful')

        tmp_file = tempfile.NamedTemporaryFile()
        tmp_file.write(entry_data)
        tmp_file.seek(0)

        entry_tag = item_to_install['tags'][0]['term']
        is_success = False
        if entry_tag == 'update-hotspots':
            is_success = self.hs_service.register_new_hotspot_file(
                tmp_file.name)
        else:
            is_success = self.importer.update_bookmarks_and_connections_from_file(
                tmp_file.name)

        tmp_file.close()

        if is_success:
            self.mark_as_installed(item_to_install['id'])

        self.__call_install_callback_if_possible(is_success)

        return False
示例#3
0
    def __init_comboboxes(self):
        tgcm.debug("init comboboxes")

        self.state_combobox = gtk.combo_box_entry_new_text()
        self.city_combobox = gtk.combo_box_entry_new_text()
        self.type_combobox = gtk.combo_box_entry_new_text()
        self.zipcode_combobox = gtk.combo_box_entry_new_text()

        foo = ((self.state_vbox, self.state_combobox,
                self.hs_service.get_states_list),
               (self.city_vbox, self.city_combobox,
                self.hs_service.get_cities_list),
               (self.type_vbox, self.type_combobox,
                self.hs_service.get_types_list),
               (self.zipcode_vbox, self.zipcode_combobox,
                self.hs_service.get_zipcodes_list))

        for vbox, combobox, function in foo:
            vbox.add(combobox)
            combobox.show()
            for row in function():
                combobox.append_text(row)
            combobox.set_active(0)

        tgcm.debug("end comboboxes")
示例#4
0
    def __request_button_cb(self, widget, data):
        self.progress = tgcm.ui.MSD.MSDProgressWindow()
        self.progress.set_show_buttons(False)
        self.progress.show(_("Please wait a minute..."),
                           _("Please wait a minute..."))

        self.progress.progressbar.hide()
        gtk_sleep(0.5)

        mainloop = gobject.MainLoop(is_running=True)
        context = mainloop.get_context()

        while context.pending():
            context.iteration()

        dev = self.mcontroller.get_main_device()
        cover_key = ""

        if dev != None and dev.get_type(
        ) == tgcm.core.DeviceManager.DEVICE_MODEM and dev.get_card_status(
        ) == CARD_STATUS_READY:
            if dev.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI):
                tgcm.debug("Sending ussd code : %s" %
                           self._get_conf_key_value("ussd"))
                cover_key = dev.get_cover_key(self._get_conf_key_value("ussd"),
                                              self.__cover_key_func,
                                              self.__cover_key_error_func)
                return

        self.progress.hide()
示例#5
0
    def __recharge_button_cb(self, widget, data):
        self.number_entry.set_text("")
        if self.request_recharge_dialog.run() != gtk.RESPONSE_OK :
            self.request_recharge_dialog.hide()
            return

        self.request_recharge_dialog.hide()
        self.recharge_dialog.hide()
        self.progress = tgcm.ui.MSD.MSDProgressWindow()
        self.progress.set_show_buttons(False)
        self.progress.show(_("Please wait a minute..."), _("Please wait a minute..."))

        mainloop =  gobject.MainLoop(is_running=True)
        context = mainloop.get_context()

        while context.pending() :
            context.iteration()

        ussd_request = self._get_conf_key_value("ussd_recharge").replace("%1%",self.number_entry.get_text())

        dev = self.device_manager.get_main_device()
        if dev == None:
            self.__ussd_call_error_func(None)
        elif dev.get_type() == tgcm.core.DeviceManager.DEVICE_MODEM :
            tgcm.debug("Sending ussd code : %s" % ussd_request)
            ussd_request = dev.get_cover_key(ussd_request,
                                              self.__ussd_call_func,
                                              self.__ussd_call_error_func)
        else:
            self.__ussd_call_error_func(None)
示例#6
0
    def __request_recharge_cb(self, widget, data):
        self.recharge_dialog.hide()
        self.progress = tgcm.ui.MSD.MSDProgressWindow()
        self.progress.set_show_buttons(False)
        self.progress.show(_("Please wait a minute..."),
                           _("Please wait a minute..."))

        mainloop = gobject.MainLoop(is_running=True)
        context = mainloop.get_context()

        while context.pending():
            context.iteration()

        ussd_request = self._get_conf_key_value("ussd_recharge").replace(
            "%1%", self.number_entry.get_text())

        dev = self.device_manager.get_main_device()
        if dev == None:
            self.__ussd_call_error_func(None)
        elif dev.get_type() == tgcm.core.DeviceManager.DEVICE_MODEM:
            tgcm.debug("Sending ussd code : %s" % ussd_request)
            ussd_request = dev.get_cover_key(ussd_request,
                                             self.__ussd_call_func,
                                             self.__ussd_call_error_func)
        else:
            self.__ussd_call_error_func(None)
示例#7
0
    def __request_button_cb(self, widget, data):
        self.progress = tgcm.ui.MSD.MSDProgressWindow()
        self.progress.set_show_buttons(False)
        self.progress.show(_("Please wait a minute..."), _("Please wait a minute..."))

        self.progress.progressbar.hide()
        gtk_sleep(0.5)

        mainloop = gobject.MainLoop(is_running=True)
        context = mainloop.get_context()

        while context.pending():
            context.iteration()

        dev = self.mcontroller.get_main_device()
        cover_key = ""

        if (
            dev != None
            and dev.get_type() == tgcm.core.DeviceManager.DEVICE_MODEM
            and dev.get_card_status() == CARD_STATUS_READY
        ):
            if dev.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI):
                tgcm.debug("Sending ussd code : %s" % self._get_conf_key_value("ussd"))
                cover_key = dev.get_cover_key(
                    self._get_conf_key_value("ussd"), self.__cover_key_func, self.__cover_key_error_func
                )
                return

        self.progress.hide()
示例#8
0
    def refresh_async(self, reason=UNKNOWN, callback=None):
        self.refresh_callback = callback

        update_url = self.conf.get_updater_feed_url()
        tgcm.debug('Attempting to download RSS "%s"' % update_url)

        download_helper = DownloadHelper.DownloadHelper2(update_url)
        download_helper.read_async(self.__rss_success_callback, success_param=reason)
示例#9
0
    def refresh_async(self, reason=UNKNOWN, callback=None):
        self.refresh_callback = callback

        update_url = self.conf.get_updater_feed_url()
        tgcm.debug('Attempting to download RSS "%s"' % update_url)

        download_helper = DownloadHelper.DownloadHelper2(update_url)
        download_helper.read_async(self.__rss_success_callback,
                                   success_param=reason)
示例#10
0
    def import_regional_info (self):
        if os.path.exists(os.path.join(tgcm.config_dir, 'regional-info.%s.xml' % tgcm.country_support)):
            return

        self.conf.set_install_date(datetime.date.today())

        tgcm.debug("IMPORTING %s" % self.conf_file)
        self.xml = ElementTree.parse (self.conf_file)
        root = self.xml.getroot()

        for node in root:
            if node.tag == 'profile-info':
                self.import_profile_info(node)
            elif node.tag == 'user-profile':
                self.import_user_profile(node)
            elif node.tag == 'boem':
                self.import_boem(node)
            elif node.tag == 'client-info':
                self.import_client_info(node)
            elif node.tag == 'coverage':
                self.import_coverage(node)
            elif node.tag == 'device':
                self.import_device(node)
            elif node.tag == 'services':
                self.import_services(node)
            elif node.tag == 'dock':
                self.import_dock(node)
            elif node.tag == 'favorite-list':
                self.import_favorite_list(node)
            elif node.tag == 'policies':
                self.import_policies (node)
            elif node.tag == 'connection-list':
                self.import_connection_list(node)
            elif node.tag == 'news':
                self.import_news (node)
            elif node.tag == 'traffic':
                self.import_traffic (node)
            elif node.tag == 'spec-ssids':
                self.import_spec_ssids (node)
            elif node.tag == 'homezone':
                self.import_homezone (node)
            elif node.tag == 'prepay':
                self.import_prepay (node)
            elif node.tag == 'eapsim':
                self.import_eapsim (node)
            elif node.tag == 'userdata':
                self.import_userdata (node)
            elif node.tag == 'addressbook':
                self.import_addressbook (node)
            elif node.tag == 'sim-locks':
                self.import_sim_locks(node)
            elif node.tag == 'ads':
                self.import_ads(node)

        shutil.copy (self.conf_file, os.path.join(tgcm.config_dir, 'regional-info.%s.xml' % tgcm.country_support))
        self.import_em7_info()
示例#11
0
    def _connecting_cb(self, dialer):
        if self.abort_now_flag == True:
            self.__abort_connection_actions()
            self.abort_now_flag == False
            self.connection_successful = False
            tgcm.debug("CONNECTING (Aborted)")
            return

        tgcm.debug("CONNECTING ---> %s" % self.starting_connection)
        self.connection_successful = False
示例#12
0
    def _connecting_cb(self, dialer):
        if self.abort_now_flag == True:
            self.__abort_connection_actions()
            self.abort_now_flag == False
            self.connection_successful = False
            tgcm.debug("CONNECTING (Aborted)")
            return

        tgcm.debug("CONNECTING ---> %s" % self.starting_connection)
        self.connection_successful = False
示例#13
0
    def install_async(self, entry_id, callback):
        self.install_callback = callback
        item_to_install = self.__get_item(entry_id)
        if item_to_install is not None:
            url = item_to_install['link']

            tgcm.debug('Download item from %s' % url)
            download_helper = DownloadHelper.DownloadHelper2(url)
            download_helper.read_async(self.__install_item_success_hook, \
                    success_param=item_to_install)
示例#14
0
    def install_async(self, entry_id, callback):
        self.install_callback = callback
        item_to_install = self.__get_item(entry_id)
        if item_to_install is not None:
            url = item_to_install['link']

            tgcm.debug('Download item from %s' % url)
            download_helper = DownloadHelper.DownloadHelper2(url)
            download_helper.read_async(self.__install_item_success_hook, \
                    success_param=item_to_install)
示例#15
0
    def __start_tgcm_logging_service(self):
        tgcm.debug('Attempting to start TGCM Logging service')

        command = ['tgcm-logging']
        command.append('-c')
        command.append(tgcm.country_support)
        self._logging_desc = subprocess.Popen(command)

        # Wait a little to give a change to TGCM Logger to
        # create its D-Bus services
        time.sleep(1)
示例#16
0
    def __register_imsi(self, device, status=None):
        if status is None:
            status = device.get_card_status()

        if status == CARD_STATUS_READY:
            try:
                imsi = device.get_imsi()
                if (imsi is not None) and (len(imsi) > 0):
                    self._config.set_last_imsi_seen(imsi)
                    tgcm.debug("Set imsi preferred : %s" % imsi)
            except DeviceHasNotCapability:
                pass
示例#17
0
    def __register_imsi(self, device, status=None):
        if status is None:
            status = device.get_card_status()

        if status == CARD_STATUS_READY:
            try:
                imsi = device.get_imsi()
                if (imsi is not None) and (len(imsi) > 0):
                    self._config.set_last_imsi_seen(imsi)
                    tgcm.debug("Set imsi preferred : %s" % imsi)
            except DeviceHasNotCapability:
                pass
示例#18
0
    def __hotspots_updated(self, hs_service):
        tgcm.debug("Hotspots updated !!")
        self.__refresh_update_date_label()

        # Remove old comboboxes and create new ones. That is far less
        # resource expensive than attempting to clear the models
        for vbox, combobox in ((self.state_vbox, self.state_combobox),
                               (self.city_vbox, self.city_combobox),
                               (self.type_vbox, self.type_combobox),
                               (self.zipcode_vbox, self.zipcode_combobox)):
            vbox.remove(combobox)

        self.__init_comboboxes()
示例#19
0
    def __hotspots_updated(self, hs_service):
        tgcm.debug("Hotspots updated !!")
        self.__refresh_update_date_label()

        # Remove old comboboxes and create new ones. That is far less
        # resource expensive than attempting to clear the models
        for vbox, combobox in (
            (self.state_vbox, self.state_combobox),
            (self.city_vbox, self.city_combobox),
            (self.type_vbox, self.type_combobox),
            (self.zipcode_vbox, self.zipcode_combobox),
        ):
            vbox.remove(combobox)

        self.__init_comboboxes()
示例#20
0
    def __download_ad_success_hook(self, raw_image, ad_info):
        if raw_image is None:
            return

        url_id = ad_info[0]
        ad_url = ad_info[2]
        tgcm.debug('Download advertising image (%s) successful' % url_id)

        tmp_file = tempfile.NamedTemporaryFile()
        tmp_file.write(raw_image)
        tmp_file.seek(0)

        self._advertising[url_id] = \
                (gtk.gdk.pixbuf_new_from_file(tmp_file.name), ad_url)
        tmp_file.close()

        self.emit('updated')
示例#21
0
    def __refresh_ads_success_hook(self, raw_xml, url_id):
        if raw_xml is None:
            return

        tgcm.debug('Advertising petition (%s) successful' % url_id)

        try:
            image_url, ad_url = self.__process_advertising_xml(raw_xml)
            ad_info = (url_id, image_url, ad_url)
            tgcm.debug('Download advertising image (%s): %s' % \
                    (url_id, image_url))

            request = DownloadHelper.DownloadHelper2(image_url)
            request.read_async(self.__download_ad_success_hook, \
                    success_param=ad_info)
        except ET.ParseError, err:
            tgcm.error('Error parsing advertising XML: %s' % err)
示例#22
0
    def __download_ad_success_hook(self, raw_image, ad_info):
        if raw_image is None:
            return

        url_id = ad_info[0]
        ad_url = ad_info[2]
        tgcm.debug('Download advertising image (%s) successful' % url_id)

        tmp_file = tempfile.NamedTemporaryFile()
        tmp_file.write(raw_image)
        tmp_file.seek(0)

        self._advertising[url_id] = \
                (gtk.gdk.pixbuf_new_from_file(tmp_file.name), ad_url)
        tmp_file.close()

        self.emit('updated')
示例#23
0
    def __process_advertising_xml(self, raw_xml):
        image_url = None
        url = None
        root = ET.fromstring(raw_xml)

        server_response = root.findall(".//returncode")[0].text
        tgcm.debug("Advertising server response: %s" % server_response)

        image_node = root.findall(".//attribute[@type='locator']")
        if len(image_node) > 0:
            image_url = image_node[0].text

        url_node = root.findall(".//attribute[@type='URL']")
        if len(url_node) > 0:
            url = url_node[0].text

        return image_url, url
示例#24
0
    def __process_advertising_xml(self, raw_xml):
        image_url = None
        url = None
        root = ET.fromstring(raw_xml)

        server_response = root.findall(".//returncode")[0].text
        tgcm.debug("Advertising server response: %s" % server_response)

        image_node = root.findall(".//attribute[@type='locator']")
        if len(image_node) > 0:
            image_url = image_node[0].text

        url_node = root.findall(".//attribute[@type='URL']")
        if len(url_node) > 0:
            url = url_node[0].text

        return image_url, url
示例#25
0
    def __refresh_ads_success_hook(self, raw_xml, url_id):
        if raw_xml is None:
            return

        tgcm.debug('Advertising petition (%s) successful' % url_id)

        try:
            image_url, ad_url = self.__process_advertising_xml(raw_xml)
            ad_info = (url_id, image_url, ad_url)
            tgcm.debug('Download advertising image (%s): %s' % \
                    (url_id, image_url))

            request = DownloadHelper.DownloadHelper2(image_url)
            request.read_async(self.__download_ad_success_hook, \
                    success_param=ad_info)
        except ET.ParseError, err:
            tgcm.error('Error parsing advertising XML: %s' % err)
示例#26
0
    def _connected_cb(self, dialer):
        if self.abort_now_flag == True:
            self.__abort_connection_actions()
            tgcm.debug("CONNECTED (Aborted)")
            return

        #self.actual_connection = self.starting_connection
        self.actual_connection = dialer.get_current_conn_settings()
        self.starting_connection = None
        self.launch_service()

        # Log connection attempt
        self._conn_logger.register_connection_attempt(self.actual_connection)

        tgcm.debug("CONNECTED ---> %s" % self.actual_connection["name"])
        self.connection_successful = True
        if self.reconnect_on_disconnect==None:
            self.reconnect_on_disconnect=self._conf.get_reconnect_on_disconnect()
示例#27
0
    def is_roaming(self):
        if (os.path.exists(os.path.join(tgcm.config_dir, "roaming"))) :
            return True

        if self.cache.has_key("roaming") :
            return self.cache["roaming"]
        else:
            if self.device_dialer.status() != PPP_STATUS_DISCONNECTED and not self.is_multiport_device() :
                tgcm.debug("MMC : return not roaming, because MM don't know this info and can't ask it")
                return False

            if self.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI) :
                ret = self.__state.IsRoaming()
                self.cache["roaming"] = ret
                return ret
            else:
                self.cache["roaming"] = False
                return False
示例#28
0
    def _connected_cb(self, dialer):
        if self.abort_now_flag == True:
            self.__abort_connection_actions()
            tgcm.debug("CONNECTED (Aborted)")
            return

        #self.actual_connection = self.starting_connection
        self.actual_connection = dialer.get_current_conn_settings()
        self.starting_connection = None
        self.launch_service()

        # Log connection attempt
        self._conn_logger.register_connection_attempt(self.actual_connection)

        tgcm.debug("CONNECTED ---> %s" % self.actual_connection["name"])
        self.connection_successful = True
        if self.reconnect_on_disconnect == None:
            self.reconnect_on_disconnect = self._conf.get_reconnect_on_disconnect(
            )
示例#29
0
    def __check_and_close_pin_dialog(self, window):
        if (self.nm_applet_process is None) or \
                (not psutil.pid_exists(self.nm_applet_process.pid)):
            self.__find_nm_applet_process()

        if self.nm_applet_process is None:
            return

        application = window.get_application()
        if application.get_pid() != self.nm_applet_process.pid:
            return

        for key in self.keywords:
            if key in window.get_name().lower():
                tgcm.debug('Closing window "%s" (PID: %d)' % \
                        (window.get_name(), self.nm_applet_process.pid))
                timestamp = gtk.get_current_event_time()
                window.close(timestamp)
                break
示例#30
0
    def __show_plan_management_page(self, page=None):
        self.progress = tgcm.ui.MSD.MSDProgressWindow()
        self.progress.set_show_buttons(False)
        self.progress.show(_("Please wait a minute..."), _("Please wait a minute..."))

        if page == None :
            ussd_request = "*117*1#"
        else:
            ussd_request = page

        dev = self.device_manager.get_main_device()
        if dev == None:
            self.__plan_management_error_func(None)
        elif dev.get_type() == tgcm.core.DeviceManager.DEVICE_MODEM :
            tgcm.debug("Sending ussd code : %s" % ussd_request)
            ussd_request = dev.get_cover_key(ussd_request,
                                             self.__plan_management_menu_func,
                                             self.__plan_management_error_func)
        else:
            self.__plan_management_error_func(None)
示例#31
0
    def refresh(self):
        now = datetime.datetime.now()
        service_id = self.config.get_ads_service_id()
        sp_id = self.config.get_ads_sp_id()
        sp_password = self.config.get_ads_sp_password()
        consumer_key = '%s@%s' % (service_id, sp_id)
        timestamp = now.strftime('%Y%m%d%H%M%S')

        m = md5.new()
        m.update('%s%s%s' % (sp_id, sp_password, timestamp))
        signature = m.hexdigest().upper()

        ui = self.config.get_ads_ui()
        ai = 'rqid0001'

        token = ''.join(random.choice(string.ascii_uppercase + string.digits) \
                for x in range(8))

        header = []
        header.append('SDPBasicAuth realm="SDPAPIs"')
        header.append('consumer_key="%s"' % consumer_key)
        header.append('signature_method="MD5"')
        header.append('signature="%s"' % signature)
        header.append('requestor_type="1"')
        header.append('requestor_id="%s"' % ui)
        header.append('token="%s"' % token)
        header.append('timestamp="%s"' % timestamp)
        header.append('version="0.1"')
        header = ', '.join(header)

        for url_id in ('main', 'service'):
            url = self.config.get_ads_url(url_id)
            url = url.replace('%ui%', ui)
            url = url.replace('%ai%', ai)

            tgcm.debug('Advertising petition (%s): %s, %s' % \
                    (url_id, url, header))
            request = DownloadHelper.DownloadHelper2(url)
            request.add_header('Authorization', header)
            request.read_async(self.__refresh_ads_success_hook, \
                    success_param=url_id)
示例#32
0
    def refresh(self):
        now = datetime.datetime.now()
        service_id = self.config.get_ads_service_id()
        sp_id = self.config.get_ads_sp_id()
        sp_password = self.config.get_ads_sp_password()
        consumer_key = '%s@%s' % (service_id, sp_id)
        timestamp = now.strftime('%Y%m%d%H%M%S')

        m = md5.new()
        m.update('%s%s%s' % (sp_id, sp_password, timestamp))
        signature = m.hexdigest().upper()

        ui = self.config.get_ads_ui()
        ai = 'rqid0001'

        token = ''.join(random.choice(string.ascii_uppercase + string.digits) \
                for x in range(8))

        header = []
        header.append('SDPBasicAuth realm="SDPAPIs"')
        header.append('consumer_key="%s"' % consumer_key)
        header.append('signature_method="MD5"')
        header.append('signature="%s"' % signature)
        header.append('requestor_type="1"')
        header.append('requestor_id="%s"' % ui)
        header.append('token="%s"' % token)
        header.append('timestamp="%s"' % timestamp)
        header.append('version="0.1"')
        header = ', '.join(header)

        for url_id in ('main', 'service'):
            url = self.config.get_ads_url(url_id)
            url = url.replace('%ui%', ui)
            url = url.replace('%ai%', ai)

            tgcm.debug('Advertising petition (%s): %s, %s' % \
                    (url_id, url, header))
            request = DownloadHelper.DownloadHelper2(url)
            request.add_header('Authorization', header)
            request.read_async(self.__refresh_ads_success_hook, \
                    success_param=url_id)
示例#33
0
    def is_roaming(self):
        if (os.path.exists(os.path.join(tgcm.config_dir, "roaming"))):
            return True

        if self.cache.has_key("roaming"):
            return self.cache["roaming"]
        else:
            if self.device_dialer.status(
            ) != PPP_STATUS_DISCONNECTED and not self.is_multiport_device():
                tgcm.debug(
                    "MMC : return not roaming, because MM don't know this info and can't ask it"
                )
                return False

            if self.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI):
                ret = self.__state.IsRoaming()
                self.cache["roaming"] = ret
                return ret
            else:
                self.cache["roaming"] = False
                return False
示例#34
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 ---")
示例#35
0
    def __init_comboboxes(self):
        tgcm.debug("init comboboxes")

        self.state_combobox = gtk.combo_box_entry_new_text()
        self.city_combobox = gtk.combo_box_entry_new_text()
        self.type_combobox = gtk.combo_box_entry_new_text()
        self.zipcode_combobox = gtk.combo_box_entry_new_text()

        foo = (
            (self.state_vbox, self.state_combobox, self.hs_service.get_states_list),
            (self.city_vbox, self.city_combobox, self.hs_service.get_cities_list),
            (self.type_vbox, self.type_combobox, self.hs_service.get_types_list),
            (self.zipcode_vbox, self.zipcode_combobox, self.hs_service.get_zipcodes_list),
        )

        for vbox, combobox, function in foo:
            vbox.add(combobox)
            combobox.show()
            for row in function():
                combobox.append_text(row)
            combobox.set_active(0)

        tgcm.debug("end comboboxes")
示例#36
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 ---")
示例#37
0
 def show(self):
     tgcm.debug('Called "show" through D-Bus')
     if self._dock is not None:
         self._dock.show_main_window()
示例#38
0
 def hide(self):
     tgcm.debug('Called "hide" through D-Bus')
     if self._dock is not None:
         self._dock.hide_main_window()
示例#39
0
 def disconnect_from_connection(self, conn_settings):
     tgcm.debug("disconnect")
     self.ppp_manager.stop_connection(conn_settings)
示例#40
0
 def disconnect(self):
     tgcm.debug("disconnect")
     self.ppp_manager.stop()
示例#41
0
def set_active_dev_by_default(mcontroller):
    tgcm.debug("FIXME MM2 : set_active_dev_by_default")
示例#42
0
    def import_regional_info(self):
        if os.path.exists(
                os.path.join(tgcm.config_dir,
                             'regional-info.%s.xml' % tgcm.country_support)):
            return

        self.conf.set_install_date(datetime.date.today())

        tgcm.debug("IMPORTING %s" % self.conf_file)
        self.xml = ElementTree.parse(self.conf_file)
        root = self.xml.getroot()

        for node in root:
            if node.tag == 'profile-info':
                self.import_profile_info(node)
            elif node.tag == 'user-profile':
                self.import_user_profile(node)
            elif node.tag == 'boem':
                self.import_boem(node)
            elif node.tag == 'client-info':
                self.import_client_info(node)
            elif node.tag == 'coverage':
                self.import_coverage(node)
            elif node.tag == 'device':
                self.import_device(node)
            elif node.tag == 'services':
                self.import_services(node)
            elif node.tag == 'dock':
                self.import_dock(node)
            elif node.tag == 'favorite-list':
                self.import_favorite_list(node)
            elif node.tag == 'policies':
                self.import_policies(node)
            elif node.tag == 'connection-list':
                self.import_connection_list(node)
            elif node.tag == 'news':
                self.import_news(node)
            elif node.tag == 'traffic':
                self.import_traffic(node)
            elif node.tag == 'spec-ssids':
                self.import_spec_ssids(node)
            elif node.tag == 'homezone':
                self.import_homezone(node)
            elif node.tag == 'prepay':
                self.import_prepay(node)
            elif node.tag == 'eapsim':
                self.import_eapsim(node)
            elif node.tag == 'userdata':
                self.import_userdata(node)
            elif node.tag == 'addressbook':
                self.import_addressbook(node)
            elif node.tag == 'sim-locks':
                self.import_sim_locks(node)
            elif node.tag == 'ads':
                self.import_ads(node)

        shutil.copy(
            self.conf_file,
            os.path.join(tgcm.config_dir,
                         'regional-info.%s.xml' % tgcm.country_support))
        self.import_em7_info()
示例#43
0
    def __rss_success_callback(self, rss_data, reason=None):
        if rss_data is None:
            tgcm.debug('Error: empty RSS data!')
            self.__call_refresh_callback_if_possible()
            return

        # Attempt to parse RSS data
        f = feedparser.parse(rss_data)
        if f.bozo:
            tgcm.debug('Error parsing RSS data: %s' % f.bozo_exception)
            self.__call_refresh_callback_if_possible()
            return

        # Get the time when the RSS feed was updated for the last time
        if 'updated_parsed' not in f['feed']:
            last_update = None
            for rss_entry in f['entries']:
                entry_last_update = rss_entry['updated_parsed']
                if (last_update is None) or (last_update < entry_last_update):
                    last_update = entry_last_update

            f['feed']['updated_parsed'] = last_update

        # Check if this RSS feed has been already parsed
        if ('updated_parsed' in self.db_contents) and \
                (self.db_contents['updated_parsed'] == f['feed']['updated_parsed']):
            tgcm.debug("Refreshed RSS, not necessary")
            self.__call_refresh_callback_if_possible()
            return

        # Is this RSS feed empty?
        if len(f['entries']) == 0:
            tgcm.debug("Refreshed RSS, not necessary (no entries)")
            self.__call_refresh_callback_if_possible()
            return

        # Manually parse XML for some non-standard RSS elements
        items_with_device_node = {}
        root = ElementTree.fromstring(rss_data)
        for item in root.iterfind('.//device/../..'):
            guid = item.find('guid').text
            items_with_device_node[guid] = item

        # Process every entry found in the RSS feed
        tgcm.debug("Release date %s" % self.conf.get_release_date())
        release_date = time.strptime(self.conf.get_release_date(),
                                     "%Y-%m-%d %H:%M:%S")
        emit_signal = False
        for entry in f['entries']:
            # This is a very ugly hack, but python-feedparser is not able to
            # deal with our non-standard RSS feed (it's our fault).
            entry['devices'] = []
            guid = entry['guid']
            if guid in items_with_device_node:
                self.__process_device_info(entry, items_with_device_node[guid])

            if entry['updated_parsed'] > release_date:
                emit_signal = True
            self.__save_entry(entry)

        self.db_contents['updated_parsed'] = f['feed']['updated_parsed']
        self.__save()

        tgcm.debug("Refreshed RSS")
        self.__call_refresh_callback_if_possible()

        if emit_signal:
            self.emit("news-updated", reason)
示例#44
0
 def disconnect_from_connection(self, conn_settings):
     tgcm.debug("disconnect")
     self.ppp_manager.stop_connection(conn_settings)
示例#45
0
    def __rss_success_callback(self, rss_data, reason=None):
        if rss_data is None:
            tgcm.debug('Error: empty RSS data!')
            self.__call_refresh_callback_if_possible()
            return

        # Attempt to parse RSS data
        f = feedparser.parse(rss_data)
        if f.bozo:
            tgcm.debug('Error parsing RSS data: %s' % f.bozo_exception)
            self.__call_refresh_callback_if_possible()
            return

        # Get the time when the RSS feed was updated for the last time
        if 'updated_parsed' not in f['feed']:
            last_update = None
            for rss_entry in f['entries']:
                entry_last_update = rss_entry['updated_parsed']
                if (last_update is None) or (last_update < entry_last_update):
                    last_update = entry_last_update

            f['feed']['updated_parsed'] = last_update

        # Check if this RSS feed has been already parsed
        if ('updated_parsed' in self.db_contents) and \
                (self.db_contents['updated_parsed'] == f['feed']['updated_parsed']):
            tgcm.debug("Refreshed RSS, not necessary")
            self.__call_refresh_callback_if_possible()
            return

        # Is this RSS feed empty?
        if len(f['entries']) == 0:
            tgcm.debug("Refreshed RSS, not necessary (no entries)")
            self.__call_refresh_callback_if_possible()
            return

        # Manually parse XML for some non-standard RSS elements
        items_with_device_node = {}
        root = ElementTree.fromstring(rss_data)
        for item in root.iterfind('.//device/../..'):
            guid = item.find('guid').text
            items_with_device_node[guid] = item

        # Process every entry found in the RSS feed
        tgcm.debug("Release date %s" % self.conf.get_release_date())
        release_date = time.strptime(self.conf.get_release_date(), "%Y-%m-%d %H:%M:%S")
        emit_signal = False
        for entry in f['entries']:
            # This is a very ugly hack, but python-feedparser is not able to
            # deal with our non-standard RSS feed (it's our fault).
            entry['devices'] = []
            guid = entry['guid']
            if guid in items_with_device_node:
                self.__process_device_info(entry, items_with_device_node[guid])

            if entry['updated_parsed'] > release_date:
                emit_signal = True
            self.__save_entry(entry)

        self.db_contents['updated_parsed'] = f['feed']['updated_parsed']
        self.__save()

        tgcm.debug("Refreshed RSS")
        self.__call_refresh_callback_if_possible()

        if emit_signal:
            self.emit("news-updated", reason)
示例#46
0
 def __DevRoamingActStatusChanged_cb(self, mcontroller, device, status):
     if self.path == device :
         self.cache["roaming"] = status
         tgcm.debug("Caching roaming value (%s , %s, %s)" % (self, device, status))
示例#47
0
 def disconnect (self):
     tgcm.debug("disconnect")
     self.ppp_manager.stop()
示例#48
0
 def __DevRoamingActStatusChanged_cb(self, mcontroller, device, status):
     if self.path == device:
         self.cache["roaming"] = status
         tgcm.debug("Caching roaming value (%s , %s, %s)" %
                    (self, device, status))