def show_icon_cb(checkbutton):
            if checkbutton.get_active():
                if not tray_available():
                    # block the handler so the set_active method doesnt
                    # executes this callback again
                    checkbutton.handler_block(self._hid2)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid2)
                    message = _("Missing dependency")
                    details = _("""
To use this feature you need either pygtk >= 2.10 or the egg.trayicon module
""")
                    dialogs.open_warning_dialog(message, details)
                    return True
                else:
                    # attach and show systray icon
                    self.parent_ctrl._setup_trayicon(ignoreconf=True)
                    # if there's an available tray, enable this chkbtn
                    close_win_chkbtn = self.view['close_window_checkbutton']
                    close_win_chkbtn.set_sensitive(True)
            
            else:
                # detach icon from systray
                self.parent_ctrl._detach_trayicon()
                # close_window_checkbutton depends on this checkbutton
                # being active, thats why we set insensitive the chkbtn
                self.view['close_window_checkbutton'].set_sensitive(False)
                self.view['close_window_checkbutton'].set_active(False)
    def on_ok_button_clicked(self, widget):
        settings = self.get_profile_settings()
        
        if not settings:
            # preferred connection or auth not specified
            return
        
        if settings['staticdns']:
            if not self.dns1_entry.isvalid() or not self.dns2_entry.isvalid():
                # DNS must be valid
                return
        
        if not settings['profile_name'] or settings['profile_name'] == '':
            self.view['profile_name_entry'].grab_focus()
            return
        
        if self.is_profile_name_insane():
            message = _('Invalid characters in profile name')
            details = _("""
The following characters are not allowed in a profile name:
%s""") % ' '.join(INVALID_CHARS)
            dialogs.open_warning_dialog(message, details)
            return
        
        prof_manager = get_profile_manager(self.model.get_device())
        prof_manager.edit_profile(self.profile, settings)
        
        # now hide
        self.hide_ourselves()
        def get_selected_device_eb(failure):
            failure.trap(SerialException)
            message = _('Device setup not completed')
            details = _("""
An unknown error occur when setting up the device:
%s""") % failure.getErrorMessage()
            dialogs.open_warning_dialog(message, details)
    def settings_valid(self,settings):
        class Problem(Exception):
            def __init__(self,detail):
                self.detail = detail
            def __str__(self):
                return repr(self.detail)

        try:
            if not settings:
                raise Problem("Profile settings are Null")

            if settings['staticdns']:
                if self.dns1_entry.get_text() == '' and self.dns2_entry.get_text() == '':
                    raise Problem("If static DNS is enabled, you must define at least one address")

                if not self.dns1_entry.isvalid() and not self.dns1_entry.get_text() == '':
                    raise Problem("Primary DNS address is invalid")

                if not self.dns2_entry.isvalid() and not self.dns2_entry.get_text() == '':
                    raise Problem("Secondary DNS address is invalid")

            if settings['apn'] == '':
                raise Problem("You must specify an APN")

            if not settings['profile_name'] or settings['profile_name'] == '':
                self.view['profile_name_entry'].grab_focus()
                raise Problem("profile name is invalid")
        
            if self.is_profile_name_insane():
                raise Problem(_("""The following characters are not allowed in a profile name: %s""") % ' '.join(INVALID_CHARS))

        except Problem, (instance): 
                message = _('Invalid value in profile')
                dialogs.open_warning_dialog(message, instance.detail)
                return False
    def show_icon_cb(self, checkbutton):
        if checkbutton.get_active():
            if not tray_available():
                # block the handler so the set_active method doesnt
                # executes this callback again
                checkbutton.handler_block(self._hid2)
                checkbutton.set_active(False)
                # restore handler
                checkbutton.handler_unblock(self._hid2)
                message = _("Missing dependency")
                details = _("""
To use this feature you need either pygtk >= 2.10 or the egg.trayicon module
""")
                dialogs.open_warning_dialog(message, details)
                return True
            else:
                # attach and show systray icon
                self.parent_ctrl._setup_trayicon(ignoreconf=True)
                # if there's an available tray, enable this chkbtn
                close_win_chkbtn = self.view['close_window_checkbutton']
                close_win_chkbtn.set_sensitive(True)

        else:
            # detach icon from systray
            self.parent_ctrl._detach_trayicon()
            # close_window_checkbutton depends on this checkbutton
            # being active, thats why we set insensitive the chkbtn
            self.view['close_window_checkbutton'].set_sensitive(False)
            self.view['close_window_checkbutton'].set_active(False)
示例#6
0
    def on_ok_button_clicked(self, widget):
        settings = self.get_profile_settings()

        if not settings:
            # preferred connection or auth not specified
            return

        if settings['staticdns']:
            if not self.dns1_entry.isvalid() or not self.dns2_entry.isvalid():
                # DNS must be valid
                return

        if not settings['profile_name'] or settings['profile_name'] == '':
            self.view['profile_name_entry'].grab_focus()
            return

        if self.is_profile_name_insane():
            message = _('Invalid characters in profile name')
            details = _("""
The following characters are not allowed in a profile name:
%s""") % ' '.join(INVALID_CHARS)
            dialogs.open_warning_dialog(message, details)
            return

        prof_manager = get_profile_manager(self.model.get_device())
        prof_manager.edit_profile(self.profile, settings)

        # now hide
        self.hide_ourselves()
示例#7
0
        def get_selected_device_eb(failure):
            failure.trap(SerialException)
            message = _('Device setup not completed')
            details = _("""
An unknown error occur when setting up the device:
%s""") % failure.getErrorMessage()
            dialogs.open_warning_dialog(message, details)
        def get_remote_plugin_eb(failure):
            failure.trap(SerialException)
            apb.close()
            
            port = cport and cport or dport
            message = _('Exception received connecting to %s') % port
            details = _("""
The following error was received while trying to establish a connection:
%s""") % failure.getErrorMessage()
            dialogs.open_warning_dialog(message, details)
示例#9
0
        def device_serial_eb(failure):
            from vmc.gtk import dialogs
            failure.trap(SerialException)
            message = _('Device setup not completed')
            details = _("""
Your device has been detected but it has been impossible to connect to it.

%s""") % failure.getErrorMessage()
            dialogs.open_warning_dialog(message, details)
            _device_select([], self.configure_hardware, self.splash)
        def device_serial_eb(failure):
            from vmc.gtk import dialogs
            failure.trap(SerialException)
            message = _('Device setup not completed')
            details = _("""
Your device has been detected but it has been impossible to connect to it.

%s""") % failure.getErrorMessage()
            dialogs.open_warning_dialog(message, details)
            _device_select([], self.configure_hardware, self.splash)
示例#11
0
        def get_remote_plugin_eb(failure):
            failure.trap(SerialException)
            apb.close()

            port = cport and cport or dport
            message = _('Exception received connecting to %s') % port
            details = _("""
The following error was received while trying to establish a connection:
%s""") % failure.getErrorMessage()
            dialogs.open_warning_dialog(message, details)
        def device_timeout_eb(failure):
            failure.trap(ex.ATTimeout)
            from vmc.gtk import dialogs
            from vmc.common.shutdown import shutdown_core

            message = _('Device not responding')
            details = _("""
Your device took more than 15 seconds to reply to my last command. Unplug it,
plug it again, and try in a moment.""")
            dialogs.open_warning_dialog(message, details)
            shutdown_core(delay=.2)
示例#13
0
        def device_timeout_eb(failure):
            failure.trap(ex.ATTimeout)
            from vmc.gtk import dialogs
            from vmc.common.shutdown import shutdown_core

            message = _('Device not responding')
            details = _("""
Your device took more than 15 seconds to reply to my last command. Unplug it,
plug it again, and try in a moment.""")
            dialogs.open_warning_dialog(message, details)
            shutdown_core(delay=.2)
示例#14
0
        def identify_dev_eb(failure):
            failure.trap(SerialException)

            from vmc.gtk import dialogs
            info = dict(name=device.name, vmc=APP_LONG_NAME)
            message = _('Device setup not completed')
            details = _("""
%(vmc)s cannot connect with the selected device (%(name)s).
""") % info
            dialogs.open_warning_dialog(message, details)
            config.set_last_device('')
            self.detect_hardware()
        def identify_dev_eb(failure):
            failure.trap(SerialException)
            
            from vmc.gtk import dialogs
            info = dict(name=device.name, vmc=APP_LONG_NAME)
            message = _('Device setup not completed')
            details = _("""
%(vmc)s cannot connect with the selected device (%(name)s).
""") % info
            dialogs.open_warning_dialog(message, details)
            config.set_last_device('')
            self.detect_hardware()
示例#16
0
    def on_pin_modify_ok_button_clicked(self, widget):
        oldpin = self.view['pin_modify_current_pin_entry'].get_text()
        newpin = self.view['pin_modify_new_pin_entry'].get_text()
        newpin2 = self.view['pin_modify_confirm_pin_entry'].get_text()
        if newpin == newpin2:
            def callback(resp):
                self.hide_widgets()
                self.model.unregister_observer(self)
                self.view.hide()
            
            def bad_passwd_eb(failure):
                failure.trap(ex.CMEErrorIncorrectPassword, ex.ATError)
                title = _("Incorrect PIN")
                details = _("""
<small>The PIN you've just entered is
incorrect. Bear in mind that after
three failed PINs you'll be asked
for the PUK code</small>
""")
                
                notification = show_error_notification(
                            self.view['pin_modify_current_pin_entry'],
                            title, details)
                self.append_widget(notification)
                self.view['pin_modify_current_pin_entry'].grab_focus()
                self.view['pin_modify_current_pin_entry'].select_region(0, -1)
            
            def garbage_passwd_eb(failure):
                failure.trap(ex.InputValueError)
                title = _("Invalid PIN")
                details = _("""
<small>The PIN you've just entered is
invalid. The PIN must be a 4 digit code</small>
""")
                
                notification = show_error_notification(
                            self.view['pin_modify_new_pin_entry'],
                            title, details)
                self.append_widget(notification)
                self.view['pin_modify_new_pin_entry'].select_region(0, -1)
                self.view['pin_modify_confirm_pin_entry'].select_region(0, -1)
                self.view['pin_modify_new_pin_entry'].grab_focus()
                
            d = self.model.change_pin(oldpin, newpin)
            d.addCallback(callback)
            d.addErrback(bad_passwd_eb)
            d.addErrback(garbage_passwd_eb)
        else:
            dialogs.open_warning_dialog(_("Error"),
                                        _("Passwords don't match"))
            self.view['pin_modify_new_pin_entry'].select_region(0, -1)
            self.view['pin_modify_confirm_pin_entry'].select_region(0, -1)
            self.view['pin_modify_new_pin_entry'].grab_focus()
示例#17
0
        def pin_req_eb(failure):
            failure.trap(ex.CMEErrorIncorrectPassword, ex.ATError)
            title = _("Incorrect PIN")
            details = _("""
<small>The PIN you've just entered is
incorrect. Bear in mind that after
three failed PINs you'll be asked
for the PUK code</small>
""")
            dialogs.open_warning_dialog(title, details)
            self.view['pin_modify_current_pin_entry'].grab_focus()
            self.view['pin_modify_current_pin_entry'].select_region(0, -1)
def ensure_have_config(force_create=False):
    if os.path.exists(consts.VMC_CFG) and not force_create:
        return
    print "ensure I have config: checked OS path exists"
    try:
        from vmc.common.oal import osobj
    except RuntimeError, e:
        message = _('User Permissions Problem.')
        details = """
It appears that you do not have privillages to run the %s application.
You need to be part of the groups 'dialout' and 'lock' to run the Modem Manager. If you have already added yourself to those groups, try restarting the computer or logging in as yourself to activate your changes.
""" % APP_LONG_NAME
        dialogs.open_warning_dialog(message, details)
        shutil.rmtree(consts.VMC_HOME, True)
        raise SystemExit()
示例#19
0
            def list_cb(resp):
                if self.sms:
                    self.delete_messages_from_db_and_tv([self.sms])

                if sent_list:
                    self.save_messages_to_db(sent_list, 
                                             TV_DICT_REV['sent_treeview'])
                if err_list:
                    dialogs.open_warning_dialog(
                        _("Unknown Error"),
                        _("Your message cannot be sent to some of its recipients. Unsent messages have been saved in drafts. Please, check that you have typed the number correctly."))
                    self.save_messages_to_db(err_list,
                                             TV_DICT_REV['drafts_treeview'])
                self.model.unregister_observer(self)
                self.view.hide()
示例#20
0
def ensure_have_config(force_create=False):
    if os.path.exists(consts.VMC_CFG) and not force_create:
        return
    print "ensure I have config: checked OS path exists"
    try:
        from vmc.common.oal import osobj
    except RuntimeError, e:
        message = _('User Permissions Problem.')
        details = """
It appears that you do not have privillages to run the %s application.
You need to be part of the groups 'dialout' and 'lock' to run the Modem Manager. If you have already added yourself to those groups, try restarting the computer or logging in as yourself to activate your changes.
""" % APP_LONG_NAME
        dialogs.open_warning_dialog(message, details)
        shutil.rmtree(consts.VMC_HOME, True)
        raise SystemExit()
示例#21
0
            def list_cb(resp):
                if self.sms:
                    self.delete_messages_from_db_and_tv([self.sms])

                if sent_list:
                    self.save_messages_to_db(sent_list,
                                             TV_DICT_REV['sent_treeview'])
                if err_list:
                    dialogs.open_warning_dialog(
                        _("Unknown Error"),
                        _("Your message cannot be sent to some of its recipients. Unsent messages have been saved in drafts. Please, check that you have typed the number correctly."
                          ))
                    self.save_messages_to_db(err_list,
                                             TV_DICT_REV['drafts_treeview'])
                self.model.unregister_observer(self)
                self.view.hide()
        def device_lacks_extractinfo_eb(failure):
            failure.trap(ex.DeviceLacksExtractInfo)
            from vmc.gtk import dialogs
            from vmc.common.shutdown import shutdown_core

            device = failure.value.args[0]
            info = dict(name=device.name, vmc=APP_LONG_NAME)
            message = _('Device setup not completed')
            details = _("""
Your device "%(name)s" is not properly registered with the kernel. %(vmc)s
needs at least two serial ports to communicate with your %(name)s.
The program includes a set of udev rules plus some binaries that make sure
that your device is always recognised properly. If you've installed from
source, then make sure to copy the relevant files in the contrib dir
""") % info
            dialogs.open_warning_dialog(message, details)

            shutdown_core(delay=.2)
示例#23
0
        def device_lacks_extractinfo_eb(failure):
            failure.trap(ex.DeviceLacksExtractInfo)
            from vmc.gtk import dialogs
            from vmc.common.shutdown import shutdown_core

            device = failure.value.args[0]
            info = dict(name=device.name, vmc=APP_LONG_NAME)
            message = _('Device setup not completed')
            details = _("""
Your device "%(name)s" is not properly registered with the kernel. %(vmc)s
needs at least two serial ports to communicate with your %(name)s.
The program includes a set of udev rules plus some binaries that make sure
that your device is always recognised properly. If you've installed from
source, then make sure to copy the relevant files in the contrib dir
""") % info
            dialogs.open_warning_dialog(message, details)

            shutdown_core(delay=.2)
示例#24
0
        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()
示例#25
0
        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()
        def keyringtoggled_cb(checkbutton):
            """
            Callback for the gnomekeyring_checkbutton::toggled signal
            
            we are gonna try to import gnomekeyring beforehand, if we
            get an ImportError we will inform the user about what she
            should do
            """
            if checkbutton.get_active():
                try:
                    import gnomekeyring
                except ImportError:
                    # block the handler so the set_active method doesnt executes
                    # this callback again
                    checkbutton.handler_block(self._hid1)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid1)
                    message = _("Missing dependency")
                    details = _(
"""To use this feature you need the gnomekeyring module""")
                    dialogs.open_warning_dialog(message, details)
                    return True
示例#27
0
     def toggled_cb(checkbutton):
         """
         Callback for the gnomekeyring_checkbutton::toggled signal
         
         we are gonna try to import gnomekeyring beforehand, if we
         get an ImportError we will inform the user about what she
         should do
         """
         if checkbutton.get_active():
             try:
                 import gnomekeyring
             except ImportError:
                 # block the handler so the set_active method doesnt
                 # executes this callback again
                 checkbutton.handler_block(self._hid)
                 checkbutton.set_active(False)
                 # restore handler
                 checkbutton.handler_unblock(self._hid)
                 message = _("Missing dependency")
                 details = _(
 """To use this feature you need the gnomekeyring module""")
                 dialogs.open_warning_dialog(message, details)
                 return True
示例#28
0
    def on_ok_button_clicked(self, widget):
        settings = self.get_profile_settings()

        if not settings:
            # preferred connection or auth not specified
            return

        if settings['staticdns']:
            if not self.dns1_entry.isvalid() or not self.dns2_entry.isvalid():
                # DNS must be valid
                return

        if not settings['profile_name'] or settings['profile_name'] == '':
            self.view['profile_name_entry'].grab_focus()
            return

        if self.is_profile_name_insane():
            message = _('Invalid characters in profile name')
            details = _("""
The following characters are not allowed in a profile name:
%s""") % ' '.join(INVALID_CHARS)
            dialogs.open_warning_dialog(message, details)
            return

        from vmc.common.config import config
        prof_manager = get_profile_manager(self.model.get_device())
        prof = prof_manager.create_profile(settings['profile_name'], settings)
        config.set_current_profile(prof)

        if self.startup:
            self.aux_ctrl.start()

        elif self.hotplug:
            self.aux_ctrl.model.wrapper.start_behaviour(self.aux_ctrl)

        # now hide
        self.hide_ourselves()
    def on_ok_button_clicked(self, widget):
        settings = self.get_profile_settings()
        
        if not settings:
            # preferred connection or auth not specified
            return
        
        if settings['staticdns']:
            if not self.dns1_entry.isvalid() or not self.dns2_entry.isvalid():
                # DNS must be valid
                return
        
        if not settings['profile_name'] or settings['profile_name'] == '':
            self.view['profile_name_entry'].grab_focus()
            return
        
        if self.is_profile_name_insane():
            message = _('Invalid characters in profile name')
            details = _("""
The following characters are not allowed in a profile name:
%s""") % ' '.join(INVALID_CHARS)
            dialogs.open_warning_dialog(message, details)
            return
        
        from vmc.common.config import config
        prof_manager = get_profile_manager(self.model.get_device())
        prof = prof_manager.create_profile(settings['profile_name'], settings)
        config.set_current_profile(prof)
        
        if self.startup:
            self.aux_ctrl.start()
        
        elif self.hotplug:
            self.aux_ctrl.model.wrapper.start_behaviour(self.aux_ctrl)
        
        # now hide
        self.hide_ourselves()
示例#30
0
# we delays this imports as they depend on modules that in turn depend on
# stuff that depend on plugins. If we dont delay this imports after the
# initial setup is complete we would get a messy traceback
from vmc.gtk.startup import check_dependencies, GTKSerialService
from vmc.common import shell
from vmc.common.consts import APP_LONG_NAME, APP_SHORT_NAME, SSH_PORT
from vmc.gtk import dialogs
from vmc.common.encoding import _

probs = check_dependencies()
if probs:
    message = _('Missing dependencies')
    probtext = '\n'.join(probs)
    msg = _('The following dependencies are not satisfied:\n%s') % probtext
    dialogs.open_warning_dialog(message, msg)
    raise SystemExit()

# access osobj singleton
from vmc.common.exceptions import OSNotRegisteredError
try:
    from vmc.common.oal import osobj
except OSNotRegisteredError:
    message = _('OS/Distro not registered')
    details = """
The OS/Distro under which you are running %s
is not registered in the OS database. Check the common.oal module for what
you can do in order to support your OS/Distro
""" % APP_LONG_NAME
    dialogs.open_warning_dialog(message, details)
    raise SystemExit()
示例#31
0
 def create_bonding_eb(failure):
     msg = _('Authentication Error from %s !') % address
     self.view['statusbar1'].push(1, msg)
     dialogs.open_warning_dialog(msg, failure.getErrorMessage())
 def create_bonding_eb(failure):
     msg = _('Authentication Error from %s !') % address
     self.view['statusbar1'].push(1, msg)
     dialogs.open_warning_dialog(msg, failure.getErrorMessage())
    # Create the initial config
    ensure_have_config(force_create=True)
    print "create skelaton and do setup: finished ensure_have_config"
    touch(consts.CHAP_PROFILE)
    touch(consts.DEFAULT_PROFILE)
    touch(consts.PAP_PROFILE)
    print "create skelaton and do setup: touch run"
    # This makes not save LOCK file if dialer_profiles have not been correctly created.
    if not os.path.exists(consts.CHAP_PROFILE) or \
            not os.path.exists(consts.DEFAULT_PROFILE) or \
            not os.path.exists(consts.PAP_PROFILE):
       
        print " Error creating dialer profile."
        message = _('ERROR creating dialer_profile. You should restart the application.')
        dialogs.open_warning_dialog(message, "")
        raise SystemExit()
    
    from vmc.common import plugin
    save_file(LOCK, str(plugin.VERSION))
    
def populate_dbs():
    """
    Populates the different databases
    """
    try:
        # only will succeed on development 
        vf_networks = __import__('resources/extra/vf_networks')
        xx_networks = __import__('resources/extra/xx_networks')
    except ImportError:
        try:
示例#34
0
    ensure_have_config(force_create=True)
    print "create skelaton and do setup: finished ensure_have_config"
    touch(consts.CHAP_PROFILE)
    touch(consts.DEFAULT_PROFILE)
    touch(consts.PAP_PROFILE)
    print "create skelaton and do setup: touch run"
    # This makes not save LOCK file if dialer_profiles have not been correctly created.
    if not os.path.exists(consts.CHAP_PROFILE) or \
            not os.path.exists(consts.DEFAULT_PROFILE) or \
            not os.path.exists(consts.PAP_PROFILE):

        print " Error creating dialer profile."
        message = _(
            'ERROR creating dialer_profile. You should restart the application.'
        )
        dialogs.open_warning_dialog(message, "")
        raise SystemExit()

    from vmc.common import plugin
    save_file(LOCK, str(plugin.VERSION))


def populate_dbs():
    """
    Populates the different databases
    """
    try:
        # only will succeed on development
        vf_networks = __import__('resources/extra/vf_networks')
        xx_networks = __import__('resources/extra/xx_networks')
    except ImportError: