Example #1
0
        def get_network_mode_cb(resp):
            mode = int(resp[0].group('mode'))
            ICERA_MODE_DICT_REV = revert_dict(self.custom.conn_dict)
            if mode in ICERA_MODE_DICT_REV:
                return ICERA_MODE_DICT_REV[mode]

            raise KeyError("Unknown network mode %s" % mode)
Example #2
0
        def get_network_mode_cb(resp):
            mode = int(resp[0].group('mode'))
            OPTION_CONN_DICT_REV = revert_dict(OPTION_CONN_DICT)
            if mode in OPTION_CONN_DICT_REV:
                return OPTION_CONN_DICT_REV[mode]

            raise KeyError("Unknown network mode %d" % mode)
Example #3
0
    def get_network_mode(self):
        ERICSSON_CONN_DICT_REV = revert_dict(ERICSSON_CONN_DICT)

        def get_network_mode_cb(mode):
            if mode in ERICSSON_CONN_DICT_REV:
                return ERICSSON_CONN_DICT_REV[mode]

            raise E.General("unknown network mode: %d" % mode)

        d = self.get_radio_status()
        d.addCallback(get_network_mode_cb)
        return d
Example #4
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from wader.common.hardware.ericsson import (EricssonDevicePlugin,
                                            EricssonWrapper,
                                            EricssonCustomizer,
                                            ERICSSON_CONN_DICT)
from wader.common.utils import revert_dict


ERICSSON_CONN_DICT_REV = revert_dict(ERICSSON_CONN_DICT)


class EricssonMD300Wrapper(EricssonWrapper):

    def get_network_mode(self):

        def get_radio_status_cb(mode):
            if mode in ERICSSON_CONN_DICT_REV:
                return ERICSSON_CONN_DICT_REV[mode]

            raise KeyError("Unknown network mode %d" % mode)

        d = self.get_radio_status()
        d.addCallback(get_radio_status_cb)
        return d
Example #5
0
NM09_MODEM_INTFACE = '%s.Modem' % NM_DEVICE
NM09_SETTINGS = NM_SERVICE
NM09_SETTINGS_INT = '%s.Settings' % NM_INTFACE
NM09_SETTINGS_OBJ = '%s/Settings' % NM_OBJPATH
NM09_SETTINGS_CONNECTION = '%s.Connection' % NM09_SETTINGS_INT

GCONF_PROFILES_BASE = '/system/networking/connections'

NM_NETWORK_TYPE_MAP = {
    MM_ALLOWED_MODE_ANY: -1,
    MM_ALLOWED_MODE_2G_PREFERRED: 3,
    MM_ALLOWED_MODE_3G_PREFERRED: 2,
    MM_ALLOWED_MODE_2G_ONLY: 1,
    MM_ALLOWED_MODE_3G_ONLY: 0,
}
NM_NETWORK_TYPE_MAP_REV = revert_dict(NM_NETWORK_TYPE_MAP)


def transpose_from_NM(oldprops):
    # call on read
    props = copy.deepcopy(oldprops)

    if 'gsm' in props:
        # map to Modem manager constants, default to ANY
        if not 'network-type' in props['gsm']:
            props['gsm']['network-type'] = MM_ALLOWED_MODE_ANY
        else:
            nm_val = props['gsm'].get('network-type')
            props['gsm']['network-type'] = NM_NETWORK_TYPE_MAP_REV[nm_val]

        # Note: password is never retrieved via plain props but we map it
Example #6
0
    MM_NETWORK_BAND_ANY: _('Any'),
    MM_NETWORK_BAND_EGSM: _('EGSM 900'),
    MM_NETWORK_BAND_DCS: _('GSM DCS'),
    MM_NETWORK_BAND_PCS: _('GSM PCS'),
    MM_NETWORK_BAND_G850: _('GSM 850'),
    MM_NETWORK_BAND_U2100: _('WCDMA 2100'),
    MM_NETWORK_BAND_U1700: _('WCDMA 1700'),
    MM_NETWORK_BAND_17IV: _('WCDMA 17IV'),
    MM_NETWORK_BAND_U800: _('WCDMA 800'),
    MM_NETWORK_BAND_U850: _('WCDMA 850'),
    MM_NETWORK_BAND_U900: _('WCDMA 900'),
    MM_NETWORK_BAND_U17IX: _('WCDMA 17IX'),
    MM_NETWORK_BAND_U1900: _('WCDMA 1900'),
}

BAND_MAP_REV = revert_dict(BAND_MAP)

MODE_MAP = {
    MM_ALLOWED_MODE_ANY: _('Any'),
    MM_ALLOWED_MODE_2G_PREFERRED: _('2G preferred'),
    MM_ALLOWED_MODE_3G_PREFERRED: _('3G preferred'),
    MM_ALLOWED_MODE_2G_ONLY: _('2G only'),
    MM_ALLOWED_MODE_3G_ONLY: _('3G only'),
}
MODE_MAP_REV = revert_dict(MODE_MAP)

# We don't have any values for authentication methods
# in common.consts, so we'll have to invent them here
# for now
VM_NETWORK_AUTH_ANY = 0xff
VM_NETWORK_AUTH_PAP = 0x01
Example #7
0
 def get_network_mode_cb(resp):
     mode = resp[0].group('mode')
     return revert_dict(self.custom.conn_dict)[mode]
Example #8
0
 def get_band_cb(resp):
     band = resp[0].group('band')
     return revert_dict(self.custom.band_dict)[band]
Example #9
0
    MM_NETWORK_BAND_ANY: _('Any band'),
    MM_NETWORK_BAND_EGSM: _('EGSM 900'),
    MM_NETWORK_BAND_DCS: _('GSM DCS'),
    MM_NETWORK_BAND_PCS: _('GSM PCS'),
    MM_NETWORK_BAND_G850: _('GSM 850'),
    MM_NETWORK_BAND_U2100: _('WCDMA 2100'),
    MM_NETWORK_BAND_U1700: _('WCDMA 1700'),
    MM_NETWORK_BAND_17IV: _('WCDMA 17IV'),
    MM_NETWORK_BAND_U800: _('WCDMA 800'),
    MM_NETWORK_BAND_U850: _('WCDMA 850'),
    MM_NETWORK_BAND_U900: _('WCDMA 900'),
    MM_NETWORK_BAND_U17IX: _('WCDMA 17IX'),
    MM_NETWORK_BAND_U1900: _('WCDMA 1900'),
}

BAND_MAP_REV = revert_dict(BAND_MAP)

MODE_MAP = {
    MM_NETWORK_MODE_ANY: _('Any'),
    MM_NETWORK_MODE_GPRS: _('GPRS'),
    MM_NETWORK_MODE_EDGE: _('EDGE'),
    MM_NETWORK_MODE_UMTS: _('UMTS'),
    MM_NETWORK_MODE_HSDPA: _('HSDPA'),
    MM_NETWORK_MODE_HSUPA: _('HSUPA'),
    MM_NETWORK_MODE_HSPA: _('HSPA'),
    MM_NETWORK_MODE_2G_PREFERRED: _('2G preferred'),
    MM_NETWORK_MODE_3G_PREFERRED: _('3G preferred'),
    MM_NETWORK_MODE_2G_ONLY: _('2G only'),
    MM_NETWORK_MODE_3G_ONLY: _('3G only'),
}
Example #10
0
File: zte.py Project: achiang/wader
 def get_network_mode_cb(resp):
     only = int(resp[0].group('only'))
     order = int(resp[0].group('order'))
     return revert_dict(self.custom.conn_dict)[(only, order)]
Example #11
0
 def test_revert_dict(self):
     self.assertEqual(revert_dict({'a': 'b'}), {'b': 'a'})
     self.assertEqual(revert_dict(dict(foo='bar')), dict(bar='foo'))
Example #12
0
"""
Base classes for Controllers
"""

#from gtkmvc import Controller
from gui.contrib.gtkmvc import Controller

from wader.common.utils import revert_dict

TV_DICT = {0: 'inbox_treeview',
           1: 'inbox_treeview',
           2: 'drafts_treeview',
           3: 'sent_treeview',
           4: 'contacts_treeview'}

TV_DICT_REV = revert_dict(TV_DICT)


class WidgetController(Controller):
    """I maintain a list of widgets"""

    def __init__(self, model):
        super(WidgetController, self).__init__(model)
        self._widgets = []

    def hide_widgets(self):
        """Hides all the widgets that we're weeping track of"""
        for widget in self._widgets:
            try:
                widget.close()
            except:
    MM_NETWORK_BAND_ANY: _('Any'),
    MM_NETWORK_BAND_EGSM: _('EGSM 900'),
    MM_NETWORK_BAND_DCS: _('GSM DCS'),
    MM_NETWORK_BAND_PCS: _('GSM PCS'),
    MM_NETWORK_BAND_G850: _('GSM 850'),
    MM_NETWORK_BAND_U2100: _('WCDMA 2100'),
    MM_NETWORK_BAND_U1800: _('WCDMA 1800'),
    MM_NETWORK_BAND_U17IV: _('WCDMA 17IV'),
    MM_NETWORK_BAND_U800: _('WCDMA 800'),
    MM_NETWORK_BAND_U850: _('WCDMA 850'),
    MM_NETWORK_BAND_U900: _('WCDMA 900'),
    MM_NETWORK_BAND_U17IX: _('WCDMA 17IX'),
    MM_NETWORK_BAND_U1900: _('WCDMA 1900'),
}

BAND_MAP_REV = revert_dict(BAND_MAP)

MODE_MAP = {
    MM_ALLOWED_MODE_ANY: _('Any'),
    MM_ALLOWED_MODE_2G_PREFERRED: _('2G preferred'),
    MM_ALLOWED_MODE_3G_PREFERRED: _('3G preferred'),
    MM_ALLOWED_MODE_2G_ONLY: _('2G only'),
    MM_ALLOWED_MODE_3G_ONLY: _('3G only'),
}
MODE_MAP_REV = revert_dict(MODE_MAP)

# We don't have any values for authentication methods
# in common.consts, so we'll have to invent them here
# for now
GUI_NETWORK_AUTH_ANY = 0xff
GUI_NETWORK_AUTH_PAP = 0x01
Example #14
0
 def cb(resp):
     mode = resp[0].group('mode')
     return revert_dict(self.custom.conn_dict)[mode]
Example #15
0
"""

#from gtkmvc import Controller
from gui.contrib.gtkmvc import Controller

from wader.common.utils import revert_dict

TV_DICT = {
    0: 'inbox_treeview',
    1: 'inbox_treeview',
    2: 'drafts_treeview',
    3: 'sent_treeview',
    4: 'contacts_treeview'
}

TV_DICT_REV = revert_dict(TV_DICT)


class WidgetController(Controller):
    """I maintain a list of widgets"""
    def __init__(self, model):
        super(WidgetController, self).__init__(model)
        self._widgets = []

    def hide_widgets(self):
        """Hides all the widgets that we're weeping track of"""
        for widget in self._widgets:
            try:
                widget.close()
            except:
                pass
    MM_NETWORK_BAND_ANY: _('Any'),
    MM_NETWORK_BAND_EGSM: _('EGSM 900'),
    MM_NETWORK_BAND_DCS: _('GSM DCS'),
    MM_NETWORK_BAND_PCS: _('GSM PCS'),
    MM_NETWORK_BAND_G850: _('GSM 850'),
    MM_NETWORK_BAND_U2100: _('WCDMA 2100'),
    MM_NETWORK_BAND_U1800: _('WCDMA 1800'),
    MM_NETWORK_BAND_U17IV: _('WCDMA 17IV'),
    MM_NETWORK_BAND_U800: _('WCDMA 800'),
    MM_NETWORK_BAND_U850: _('WCDMA 850'),
    MM_NETWORK_BAND_U900: _('WCDMA 900'),
    MM_NETWORK_BAND_U17IX: _('WCDMA 17IX'),
    MM_NETWORK_BAND_U1900: _('WCDMA 1900'),
}

BAND_MAP_REV = revert_dict(BAND_MAP)

MODE_MAP = {
    MM_ALLOWED_MODE_ANY: _('Any'),
    MM_ALLOWED_MODE_2G_PREFERRED: _('2G preferred'),
    MM_ALLOWED_MODE_3G_PREFERRED: _('3G preferred'),
    MM_ALLOWED_MODE_2G_ONLY: _('2G only'),
    MM_ALLOWED_MODE_3G_ONLY: _('3G only'),
}
MODE_MAP_REV = revert_dict(MODE_MAP)

# We don't have any values for authentication methods
# in common.consts, so we'll have to invent them here
# for now
GUI_NETWORK_AUTH_ANY = 0xff
GUI_NETWORK_AUTH_PAP = 0x01