def update_bars_user_limit(self): self.usage_user_limit = int( config.get('preferences', 'traffic_threshold')) self.usage_max_value = int(config.get('preferences', 'max_traffic')) for bar in self.usage_bars.values(): bar.set_user_limit(units_to_bits(self.usage_user_limit, UNIT_MB)) bar.set_max_value(units_to_bits(self.usage_max_value, UNIT_MB))
def __init__(self, ctrl): super(ApplicationView, self).__init__(ctrl, self.GLADE_FILE, 'main_window', register=False, domain="VMC") #Usage statistics self.usage_user_limit = int(config.get('preferences', 'traffic_threshold')) self.usage_max_value = int(config.get('preferences', 'max_traffic')) self.usage_units = UNIT_KB self.usage_bars = None self.setup_view() ctrl.register_view(self) self.throbber = None ctrl.update_usage_view() self.setup_treeview(ctrl)
def __init__(self, ctrl): super(ApplicationView, self).__init__(ctrl, self.GLADE_FILE, 'main_window', register=False, domain="VMC") #Usage statistics self.usage_user_limit = int( config.get('preferences', 'traffic_threshold')) self.usage_max_value = int(config.get('preferences', 'max_traffic')) self.usage_units = UNIT_KB self.usage_bars = None self.setup_view() ctrl.register_view(self) self.throbber = None ctrl.update_usage_view() self.setup_treeview(ctrl)
def check_profile_updates(self): updater = config.get('profile', 'updater') if not updater: return defer.succeed(None) updater_mixin = self.build_updater_mixin(updater) if not updater_mixin: return defer.succeed(None) d = updater_mixin.update_profile() d.addCallback(self._update_profile_cb) return d
def setup_mail_combobox(self): model = gtk.ListStore(gobject.TYPE_STRING) xdg_iter = model.append(['xdg-email']) custom_iter = model.append([_('Custom')]) self['mail_combobox'].set_model(model) binary = config.get('preferences', 'mail') _iter = (binary == 'xdg-email') and xdg_iter or custom_iter self['mail_combobox'].set_active_iter(_iter) if binary != 'xdg-email': self['mail_entry'].set_text(binary)
def get_messages_list(self): """Returns a list with all the messages to send/sav""" # get number list and text numbers = self.get_numbers_list() if not numbers: return succeed([]) message_text = self.get_message_text() message_text = unicode(message_text, 'utf8') validity = config.get('sms', 'validity') validity = transform_validity[validity] d = self.parent_ctrl.model.get_smsc() def get_smsc_cb(smsc): if not smsc or smsc == '': raise ex.CMEErrorNotFound() return [ ShortMessageSubmit(number, message_text, _datetime=datetime.datetime.now(), smsc=smsc, validity=validity) for number in numbers ] def get_smsc_eb(failure): failure.trap(ex.CMEErrorNotFound) # handle #179 message = _('No SMSC number') details = _(""" In order to send a SMS, %s needs to know the number of your provider's SMSC. If you do not know the SMSC number, contact your customer service. """) % consts.APP_LONG_NAME dialogs.open_warning_dialog(message, details) # prepare the dialog model = PreferencesModel(self.parent_ctrl.model.wrapper) ctrl = SMSPreferencesController(model) view = SMSPreferencesView(ctrl, self) view.set_parent_view(self.view) # hide ourselves self.model.unregister_observer(self) self.view.hide() # show the dialog view.show() d.addCallback(get_smsc_cb) d.addErrback(get_smsc_eb) return d
def __init__(self, ctrl): if gtk.gdk.screen_height() < 600: height = 420 GLADE_FILE = os.path.join(consts.GLADE_DIR, "VMC-reduced.glade") else: height = WIN_HEIGHT GLADE_FILE = os.path.join(consts.GLADE_DIR, "VMC.glade") super(ApplicationView, self).__init__(ctrl, GLADE_FILE, 'main_window', register=False, domain="VMC") #Usage statistics self.usage_user_limit = int(config.get('preferences', 'traffic_threshold')) self.usage_max_value = int(config.get('preferences', 'max_traffic')) self.usage_units = UNIT_KB self.usage_bars = None self.setup_view(height) ctrl.register_view(self) self.throbber = None ctrl.update_usage_view() self.setup_treeview(ctrl)
def _setup_message_options(self): validity = config.get('sms', 'validity') if not validity: config.set('sms', 'validity', 'maximum') config.write() validity = 'maximum' combobox = self.view['validity_combobox'] model = combobox.get_model() for i, row in enumerate(model): option = row[0] if validity == VALIDITY_DICT[option]: combobox.set_active(i) break
def init(self): """I start the application""" self.splash = SplashContainer() self.splash.pulse() profile_name = config.get('profile', 'name') if not profile_name: # user never never ran the app self.splash.set_text(_('Initial setup...')) self.splash.pulse() # populate databases and configure hardware afterwards populate_dbs() self.splash.pulse() self.detect_hardware()
def get_messages_list(self): """Returns a list with all the messages to send/sav""" # get number list and text numbers = self.get_numbers_list() if not numbers: return succeed([]) message_text = self.get_message_text() message_text = unicode(message_text, 'utf8') validity = config.get('sms', 'validity') validity = transform_validity[validity] d = self.parent_ctrl.model.get_smsc() def get_smsc_cb(smsc): if not smsc or smsc == '': raise ex.CMEErrorNotFound() return [ShortMessageSubmit(number, message_text, _datetime=datetime.datetime.now(), smsc=smsc, validity=validity) for number in numbers] def get_smsc_eb(failure): failure.trap(ex.CMEErrorNotFound) # handle #179 message = _('No SMSC number') details = _( """ In order to send a SMS, %s needs to know the number of your provider's SMSC. If you do not know the SMSC number, contact your customer service. """) % consts.APP_LONG_NAME dialogs.open_warning_dialog(message, details) # prepare the dialog model = PreferencesModel(self.parent_ctrl.model.wrapper) ctrl = SMSPreferencesController(model) view = SMSPreferencesView(ctrl, self) view.set_parent_view(self.view) # hide ourselves self.model.unregister_observer(self) self.view.hide() # show the dialog view.show() d.addCallback(get_smsc_cb) d.addErrback(get_smsc_eb) return d
def init(self): """I start the application""" # avoid gnome warnings gnome.init(APP_LONG_NAME, __version__) self.splash = SplashContainer() self.splash.pulse() profile_name = config.get('profile', 'name') if not profile_name: # user never never ran the app self.splash.set_text(_('Initial setup...')) self.splash.pulse() # populate databases and configure hardware afterwards populate_dbs() self.splash.pulse() self.detect_hardware()
def init(self): """I start the application""" # avoid gnome warnings gnome.init(APP_LONG_NAME, __version__) self.splash = SplashContainer() self.splash.pulse() profile_name = config.get('profile', 'name') if not profile_name: # user never never ran the app self.splash.set_text(_('Initial setup...')) self.splash.pulse() # populate network database into memory and configure hardware afterwards populate_dbs() self.splash.pulse() self.detect_hardware()
def hook_it_up(splash, device=None): """Attachs comms core to GUI and presents main screen""" # get main screen up from vmc.gtk.models.application import ApplicationModel from vmc.gtk.views.application import ApplicationView from vmc.gtk.controllers.application import ApplicationController splash.pulse() model = ApplicationModel() ctrl = ApplicationController(model, splash) view = ApplicationView(ctrl) # we keep a reference of the controller in the model model.ctrl = ctrl if not device: ctrl.start() return unsolicited_notifications_callbacks = { N.SIG_RSSI: ctrl._change_signal_level, N.SIG_RFSWITCH: ctrl._change_radio_state, N.SIG_SPEED: ctrl._change_net_stats_cb, N.SIG_NEW_CONN_MODE: ctrl._conn_mode_changed, N.SIG_NEW_NETWORK: ctrl._network_changed, N.SIG_SMS: ctrl._on_sms_received, N.SIG_CALL: None, N.SIG_CREG: None, N.SIG_CONNECTED: None, N.SIG_CONN: None, # Why are there two notifications for 'Connect'? N.SIG_DISCONNECTED: None, } profile_name = config.get('profile', 'name') statemachine_callbacks = {} if not profile_name: # user never run the app before statemachine_callbacks['InitExit'] = lambda: ctrl.ask_for_new_profile( startup=True, aux_ctrl=ctrl) else: statemachine_callbacks['InitExit'] = ctrl.start splash.start_pulse() def on_auth_exit(): splash.set_text(_('Authenticated!')) splash.stop_pulse() statemachine_callbacks['AuthEnter'] = lambda: splash.set_text( _('Authenticating...')) statemachine_callbacks['AuthExit'] = on_auth_exit statemachine_callbacks['NetRegExit'] = ctrl.on_netreg_exit statemachine_errbacks = { 'AlreadyConnecting': None, 'AlreadyConnected': None, 'IllegalOperationError': ctrl.on_illegal_operation, } from vmc.gtk.wrapper import GTKWrapper ctrl.model.wrapper = GTKWrapper(device, unsolicited_notifications_callbacks, statemachine_callbacks, statemachine_errbacks, ctrl) ctrl.model.wrapper.start_behaviour(ctrl)
def hook_it_up(splash, device_listener, device=None): """Attachs comms core to GUI and presents main screen""" # get main screen up from vmc.gtk.models.application import ApplicationModel from vmc.gtk.views.application import ApplicationView from vmc.gtk.controllers.application import ApplicationController splash.pulse() model = ApplicationModel() ctrl = ApplicationController(model, device_listener, splash) view = ApplicationView(ctrl) # we keep a reference of the controller in the model model.ctrl = ctrl if not device: ctrl.start() return unsolicited_notifications_callbacks = { N.SIG_RSSI: ctrl._change_signal_level, N.SIG_SPEED: ctrl._change_net_stats_cb, N.SIG_NEW_CONN_MODE: ctrl._conn_mode_changed, N.SIG_SMS: ctrl._on_sms_received, N.SIG_CALL: None, } profile_name = config.get('profile', 'name') statemachine_callbacks = {} if not profile_name: # user never run the app before def configure_device(): _model = NewProfileModel(device) _ctrl = NewProfileController(_model, startup=True, aux_ctrl=ctrl) _view = NewProfileView(_ctrl) _view.set_parent_view(view) # center on main screen _view.show() statemachine_callbacks['PostInitExit'] = configure_device else: statemachine_callbacks['PostInitExit'] = ctrl.start try: splash.start_pulse() except: pass def on_auth_exit(): splash.set_text(_('Authenticated!')) try: splash.stop_pulse() except: pass statemachine_callbacks['PreInitExit'] = lambda: splash.set_text( _('Authenticating...')) statemachine_callbacks['AuthExit'] = on_auth_exit statemachine_errbacks = { 'AlreadyConnecting': None, 'AlreadyConnected': None, 'IllegalOperationError': ctrl.on_illegal_operation, } from vmc.gtk.wrapper import GTKWrapper ctrl.model.wrapper = GTKWrapper(device, unsolicited_notifications_callbacks, statemachine_callbacks, statemachine_errbacks, ctrl) ctrl.model.wrapper.start_behaviour(ctrl)
def update_bars_user_limit(self): self.usage_user_limit = int(config.get('preferences', 'traffic_threshold')) self.usage_max_value = int(config.get('preferences', 'max_traffic')) for bar in self.usage_bars.values(): bar.set_user_limit(units_to_bits(self.usage_user_limit, UNIT_MB)) bar.set_max_value(units_to_bits(self.usage_max_value, UNIT_MB))
def hook_it_up(splash, device_listener, device=None): """Attachs comms core to GUI and presents main screen""" # get main screen up from vmc.gtk.models.application import ApplicationModel from vmc.gtk.views.application import ApplicationView from vmc.gtk.controllers.application import ApplicationController splash.pulse() model = ApplicationModel() ctrl = ApplicationController(model, device_listener, splash) view = ApplicationView(ctrl) # we keep a reference of the controller in the model model.ctrl = ctrl if not device: ctrl.start() return unsolicited_notifications_callbacks = { N.SIG_RSSI : ctrl._change_signal_level, N.SIG_SPEED : ctrl._change_net_stats_cb, N.SIG_NEW_CONN_MODE : ctrl._conn_mode_changed, N.SIG_SMS : ctrl._on_sms_received, N.SIG_CALL : None, } profile_name = config.get('profile', 'name') statemachine_callbacks = {} if not profile_name: # user never run the app before def configure_device(): _model = NewProfileModel(device) _ctrl = NewProfileController(_model, startup=True, aux_ctrl=ctrl) _view = NewProfileView(_ctrl) _view.set_parent_view(view) # center on main screen _view.show() statemachine_callbacks['PostInitExit'] = configure_device else: statemachine_callbacks['PostInitExit'] = ctrl.start try: splash.start_pulse() except: pass def on_auth_exit(): splash.set_text(_('Authenticated!')) try: splash.stop_pulse() except: pass statemachine_callbacks['PreInitExit'] = lambda: splash.set_text(_('Authenticating...')) statemachine_callbacks['AuthExit'] = on_auth_exit statemachine_errbacks = { 'AlreadyConnecting' : None, 'AlreadyConnected' : None, 'IllegalOperationError' : ctrl.on_illegal_operation, } from vmc.gtk.wrapper import GTKWrapper ctrl.model.wrapper = GTKWrapper(device, unsolicited_notifications_callbacks, statemachine_callbacks, statemachine_errbacks, ctrl) ctrl.model.wrapper.start_behaviour(ctrl)
def hook_it_up(splash, device=None): """Attachs comms core to GUI and presents main screen""" # get main screen up from vmc.gtk.models.application import ApplicationModel from vmc.gtk.views.application import ApplicationView from vmc.gtk.controllers.application import ApplicationController splash.pulse() model = ApplicationModel() ctrl = ApplicationController(model, splash) view = ApplicationView(ctrl) # we keep a reference of the controller in the model model.ctrl = ctrl if not device: ctrl.start() return unsolicited_notifications_callbacks = { N.SIG_RSSI : ctrl._change_signal_level, N.SIG_RFSWITCH : ctrl._change_radio_state, N.SIG_SPEED : ctrl._change_net_stats_cb, N.SIG_NEW_CONN_MODE : ctrl._conn_mode_changed, N.SIG_NEW_NETWORK : ctrl._network_changed, N.SIG_SMS : ctrl._on_sms_received, N.SIG_CALL : None, N.SIG_CREG : None, N.SIG_CONNECTED : None, N.SIG_CONN : None, # Why are there two notifications for 'Connect'? N.SIG_DISCONNECTED : None, } profile_name = config.get('profile', 'name') statemachine_callbacks = {} if not profile_name: # user never run the app before statemachine_callbacks['InitExit'] = lambda: ctrl.ask_for_new_profile(startup=True, aux_ctrl=ctrl) else: statemachine_callbacks['InitExit'] = ctrl.start splash.start_pulse() def on_auth_exit(): splash.set_text(_('Authenticated!')) splash.stop_pulse() statemachine_callbacks['AuthEnter'] = lambda: splash.set_text(_('Authenticating...')) statemachine_callbacks['AuthExit'] = on_auth_exit statemachine_callbacks['NetRegExit'] = ctrl.on_netreg_exit statemachine_errbacks = { 'AlreadyConnecting' : None, 'AlreadyConnected' : None, 'IllegalOperationError' : ctrl.on_illegal_operation, } from vmc.gtk.wrapper import GTKWrapper ctrl.model.wrapper = GTKWrapper(device, unsolicited_notifications_callbacks, statemachine_callbacks, statemachine_errbacks, ctrl) ctrl.model.wrapper.start_behaviour(ctrl)