diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-01-06 15:50:25 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-01-06 15:50:25 -0600 |
commit | 1b5c314f9afc487cb77dd12289853d4038a7ebda (patch) | |
tree | 96ad00ad24e89961629e03937538b23336e6c0df /src | |
parent | 45f2f9315fd48aa71d0a90dd82826125649382ee (diff) | |
download | ofono-1b5c314f9afc487cb77dd12289853d4038a7ebda.tar.bz2 |
Refactor: Allow persisent modem names
Diffstat (limited to 'src')
-rw-r--r-- | src/modem.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/modem.c b/src/modem.c index 85a851db..bbc99051 100644 --- a/src/modem.c +++ b/src/modem.c @@ -1035,17 +1035,23 @@ bool ofono_modem_get_boolean(struct ofono_modem *modem, const char *key) return value; } -struct ofono_modem *ofono_modem_create(const char *type) +struct ofono_modem *ofono_modem_create(const char *name, const char *type) { struct ofono_modem *modem; char path[128]; - DBG("%s", type); + DBG("name: %s, type: %s", name, type); if (strlen(type) > 16) return NULL; - snprintf(path, sizeof(path), "/%s%d", type, next_modem_id); + if (name && strlen(name) > 64) + return NULL; + + if (name == NULL) + snprintf(path, sizeof(path), "/%s%d", type, next_modem_id); + else + snprintf(path, sizeof(path), "/%s", name); if (__ofono_dbus_valid_object_path(path) == FALSE) return NULL; @@ -1062,7 +1068,8 @@ struct ofono_modem *ofono_modem_create(const char *type) g_modem_list = g_slist_prepend(g_modem_list, modem); - next_modem_id += 1; + if (name == NULL) + next_modem_id += 1; return modem; } |