EntelPCS/Drivers: sonyericsson_md300.py

File sonyericsson_md300.py, 2.4 kB (added by jbustos, 7 weeks ago)
Line 
1# -*- coding: utf-8 -*-
2# Copyright (C) 2006-2008  EntelPCS Chile, S.A.
3# Author: Javier Bustos-Jimenez
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19__version__ = "$Rev$"
20
21from vmc.common.hardware.sonyericsson import SonyEricssonCustomizer
22from vmc.common.plugin import DBusDevicePlugin
23
24from vmc.common.middleware import SIMCardConnAdapter
25from vmc.common.exceptions import DeviceLacksExtractInfo
26
27class MD300SIMCardConnAdapter(SIMCardConnAdapter):
28    def set_charset(self, charset):
29        """
30        Some actions fail with UCS2
31        """
32        if charset == 'UCS2':
33            d = super(MD300SIMCardConnAdapter, self).set_charset('IRA')
34        else:
35            d = super(MD300SIMCardConnAdapter, self).set_charset(charset)
36        d.addCallback(lambda ignord: self.device.sim.set_charset(charset))
37        return d
38
39class SonyEricssonMD300Customizer(SonyEricssonCustomizer):
40    adapter = MD300SIMCardConnAdapter
41
42class SonyEricssonMD300USB(DBusDevicePlugin):
43    """L{vmc.common.plugin.DBusDevicePlugin} for Sony Ericsson MD300"""
44    name = "Sony Ericsson MD300"
45    version = "0.1"
46    author = u"Javier Bustos-Jimenez"
47    custom = SonyEricssonMD300Customizer
48
49    baudrate = 460800
50
51    __remote_name__ = "MD300"
52
53    __properties__ = {
54        'usb_device.vendor_id': [0x0fce],
55        'usb_device.product_id': [0xd0cf],
56    }
57
58    def extract_info(self, children):
59        for device in children:
60            try:
61                if device['serial.port'] == 0: #data port
62                    self.dport = device['serial.device'].encode('utf8')
63            except KeyError:
64                pass
65       
66        if not self.dport:
67            raise DeviceLacksExtractInfo(self)
68
69sonyericsson_MD300USB = SonyEricssonMD300USB()
70