~ubuntu-branches/ubuntu/vivid/modemmanager/vivid-proposed

« back to all changes in this revision

Viewing changes to plugins/mm-plugin-longcheer.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-16 17:12:41 UTC
  • mfrom: (16.1.1 oneiric)
  • Revision ID: james.westby@ubuntu.com-20110616171241-k8vgsdmbpsvx467q
Tags: 0.4.997-1
* debian/watch: Switch to .bz2 tarballs.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "mm-modem-longcheer-gsm.h"
21
21
#include "mm-generic-gsm.h"
22
22
#include "mm-generic-cdma.h"
 
23
#include "mm-modem-helpers.h"
23
24
 
24
25
G_DEFINE_TYPE (MMPluginLongcheer, mm_plugin_longcheer, MM_TYPE_PLUGIN_BASE)
25
26
 
62
63
    mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
63
64
}
64
65
 
 
66
static gboolean
 
67
custom_init_response_cb (MMPluginBaseSupportsTask *task,
 
68
                         GString *response,
 
69
                         GError *error,
 
70
                         guint32 tries,
 
71
                         gboolean *out_stop,
 
72
                         guint32 *out_level,
 
73
                         gpointer user_data)
 
74
{
 
75
    const char *p = response->str;
 
76
 
 
77
    if (error)
 
78
        return tries <= 4 ? TRUE : FALSE;
 
79
 
 
80
    /* Note the lack of a ':' on the GMR; the X200 doesn't send one */
 
81
    p = mm_strip_tag (response->str, "AT+GMR");
 
82
    if (*p == 'L') {
 
83
        /* X200 modems have a GMR firmware revision that starts with 'L', and
 
84
         * as far as I can tell X060s devices have a revision starting with 'C'.
 
85
         * So use that to determine if the device is an X200, which this plugin
 
86
         * does not support since it uses a different chipset even though the
 
87
         * X060s and the X200 have the exact same USB VID and PID.
 
88
         */
 
89
        *out_level = 0;
 
90
        *out_stop = TRUE;
 
91
        return FALSE;
 
92
    }
 
93
 
 
94
    /* Continue with generic probing */
 
95
    return FALSE;
 
96
}
 
97
 
65
98
static MMPluginSupportsResult
66
99
supports_port (MMPluginBase *base,
67
100
               MMModem *existing,
69
102
{
70
103
    GUdevDevice *port;
71
104
    guint32 cached = 0, level;
72
 
    guint16 vendor = 0;
 
105
    guint16 vendor = 0, product = 0;
73
106
    const char *subsys, *name;
74
107
 
75
108
    /* Can't do anything with non-serial ports */
80
113
    subsys = g_udev_device_get_subsystem (port);
81
114
    name = g_udev_device_get_name (port);
82
115
 
83
 
    if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, NULL))
 
116
    if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product))
84
117
        return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
85
118
 
86
119
    /* Longcheer and TAMobile */
87
120
    if (vendor != 0x1c9e && vendor != 0x1bbb)
88
121
        return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
89
122
 
 
123
    /* Some TAMobile devices are different chipsets and should be handled
 
124
     * by other plugins, so only handle LONGCHEER tagged devices here.
 
125
     */
 
126
    if (g_udev_device_get_property_as_boolean (port, "ID_MM_LONGCHEER_TAGGED") == FALSE)
 
127
        return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
 
128
 
90
129
    if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
91
130
        level = get_level_for_capabilities (cached);
92
131
        if (level) {
96
135
        return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
97
136
    }
98
137
 
 
138
    /* TCT/Alcatel in their infinite wisdom assigned the same USB VID/PID to
 
139
     * the x060s (Longcheer firmware) and the x200 (something else) and thus
 
140
     * we can't tell them apart via udev rules.  Worse, they both report the
 
141
     * same +GMM and +GMI, so we're left with just +GMR which is a sketchy way
 
142
     * to tell modems apart.  We can't really use Longcheer-specific commands
 
143
     * like AT+MODODR or AT+PSRAT because we're not sure if they work when the
 
144
     * SIM PIN has not been entered yet; many modems have a limited command
 
145
     * parser before the SIM is unlocked.
 
146
     */
 
147
    if (vendor == 0x1bbb && product == 0x0000) {
 
148
        mm_plugin_base_supports_task_add_custom_init_command (task,
 
149
                                                              "AT+GMR",
 
150
                                                              3,
 
151
                                                              custom_init_response_cb,
 
152
                                                              NULL);
 
153
    }
 
154
 
99
155
    /* Otherwise kick off a probe */
100
156
    if (mm_plugin_base_probe_port (base, task, 100000, NULL))
101
157
        return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;