ofono: do not use context path as network group identifier
authorKalle Valo <kalle.valo@canonical.com>
Fri, 11 Jun 2010 06:12:06 +0000 (09:12 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 11 Jun 2010 06:56:17 +0000 (23:56 -0700)
The ofono plugin was using context path as network group identifier
which caused service path to end something like this:

/profile/default/cellular_244053111242822_huawei2_primarycontext1

But the problem here is that with certain modems (like my Huawei E1552)
the path will change every time the modem in replugged. This meant
that a new connman service was created everytime and I had to
enter APN everytime, instead of using the stored service which already
had APN correctly set.

Fix this by using only the last part from path, for example in this
case primarycontext1:

/profile/default/cellular_244053111242822_primarycontext1

Now with huawei modems the service id stays always the same as it should.

plugins/ofono.c

index d0e4641..126d616 100644 (file)
@@ -170,19 +170,16 @@ static struct connman_device_driver modem_driver = {
 
 static char *get_ident(const char *path)
 {
-       char *ident, *pos;
+       char *pos;
 
        if (*path != '/')
                return NULL;
 
-       ident = g_strdup(path + 1);
-
-       pos = ident;
-
-       while ((pos = strchr(pos, '/')) != NULL)
-               *pos = '_';
+       pos = strrchr(path, '/');
+       if (pos == NULL)
+               return NULL;
 
-       return ident;
+       return g_strdup(pos + 1);
 }
 
 static void create_service(struct connman_network *network)