Exemplo n.º 1
0
def send(sender, message, style=""):
	Notify.Notify(sender, message, style)
	open("c:\\bin\\video_mes.txt", "a+").write("\nFrom: %s\nMessage:\n\t%s\n===="%(sender, message))
Exemplo n.º 2
0
    def __init__(self):
        gobject.GObject.__init__(self)
        self._device_manager = FreeDesktop.DeviceManager()
        self.conf = Config.Config(tgcm.country_support)
        self.notify = Notify.Notify()
        self.__updater = TrafficUpdater.TrafficUpdater()
        self.__main_modem = FreeDesktop.MainModem.MainModem()
        self.__main_wifi = FreeDesktop.MainWifi.MainWifi()

        # FIXME: Usually it is a bad idea to have a dependency to a UI element in the Core
        self.__dock = tgcm.ui.ThemedDock()

        #TrafficHistoryGraphData
        db_file = os.path.join(tgcm.config_dir,
                               "traffic-%s.db" % tgcm.country_support)
        self._storage = TrafficStorage.TrafficStorage(self.conf, db_file)

        self.is_roaming = None

        # Billing period related expenses
        self._cached_expenses = {}
        self._cached_monthly_limit = {}
        self._cached_billing_period = None

        # Session related expenses
        self.session_data_transfered = 0
        self.session_max_speed = 0

        # Various
        self.last_received_bytes = 0
        self.last_sent_bytes = 0
        self.__monitoring = self.MONITORING_IDLE

        ## Check if a billing period has expired between now and the latest execution ##
        # The only thing necessary that needs to be reset is the SMS counters, because
        # unlike the traffic accounting, it is saved in a incremental register in GConf.
        if self.conf.is_last_imsi_seen_valid():
            imsi = self.conf.get_last_imsi_seen()
            billing_period = self.conf.get_imsi_based_billing_period(imsi)

            # The billing period is a list of Date objects, and the last execution is a
            # Datetime object. In order to compare them, it is necessary to convert the
            # first date of the billing period from Date to Datetime
            last_execution = self.conf.get_last_execution_datetime()
            first_day_period = datetime.datetime.combine(
                billing_period[0], datetime.time())

            # If the date time of the last execution is older than the date of the first
            # day of current billing period, I assume that there have been a billing period
            # change and it is necessary to reset the SMS counters
            if last_execution < first_day_period:
                self.__reset_sms_counters(imsi)

        # Configure current traffic history
        self.__billing_period_change_event = None
        self.__start_traffic_history()

        # Create alert list for current recognized IMSI
        self.__create_current_alerts()

        # -- Signals from the MainModem for detecting the connected/disconnected signals
        self.__main_modem.connect('main-modem-connected',
                                  self.__main_modem_connected_cb)
        self.__main_modem.connect('main-modem-disconnected',
                                  self.__main_modem_disconnected_cb)
        self.__main_wifi.connect('main-wifi-connected',
                                 self.__main_wifi_connected_cb)
        self.__main_wifi.connect('main-wifi-disconnected',
                                 self.__main_wifi_disconnected_cb)

        self.__updater.connect("traffic-updater-trigger",
                               self.__traffic_updater_trigger_cb)

        self.conf.connect('last-imsi-seen-changed',
                          self.__on_last_imsi_changed)
        self.conf.connect('billing-day-changed', self.__on_billing_day_changed)
        self.conf.connect('monthly-limit-changed',
                          self.__on_monthly_limit_changed)
        self.conf.connect('alerts-info-changed', self.__on_alerts_changed)
        self.__dock.connect('app-closing', self.__on_app_close)

        # -- Start the thread that will update the session time
        self.__session_time_event = threading.Event()
        self.__session_time_state = self.SESSION_TIME_INIT
        thread.start_new_thread(self.__session_time_thread, ())
        glib.idle_add(self.__init)