mirror of git://git.sysmocom.de/ofono
Refactor: Allow persisent modem names
This commit is contained in:
parent
45f2f9315f
commit
1b5c314f9a
|
@ -43,7 +43,7 @@ const char *ofono_modem_get_path(struct ofono_modem *modem);
|
||||||
void ofono_modem_set_data(struct ofono_modem *modem, void *data);
|
void ofono_modem_set_data(struct ofono_modem *modem, void *data);
|
||||||
void *ofono_modem_get_data(struct ofono_modem *modem);
|
void *ofono_modem_get_data(struct ofono_modem *modem);
|
||||||
|
|
||||||
struct ofono_modem *ofono_modem_create(const char *type);
|
struct ofono_modem *ofono_modem_create(const char *name, const char *type);
|
||||||
int ofono_modem_register(struct ofono_modem *modem);
|
int ofono_modem_register(struct ofono_modem *modem);
|
||||||
void ofono_modem_remove(struct ofono_modem *modem);
|
void ofono_modem_remove(struct ofono_modem *modem);
|
||||||
|
|
||||||
|
|
11
src/modem.c
11
src/modem.c
|
@ -1035,17 +1035,23 @@ bool ofono_modem_get_boolean(struct ofono_modem *modem, const char *key)
|
||||||
return value;
|
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;
|
struct ofono_modem *modem;
|
||||||
char path[128];
|
char path[128];
|
||||||
|
|
||||||
DBG("%s", type);
|
DBG("name: %s, type: %s", name, type);
|
||||||
|
|
||||||
if (strlen(type) > 16)
|
if (strlen(type) > 16)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (name && strlen(name) > 64)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
snprintf(path, sizeof(path), "/%s%d", type, next_modem_id);
|
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)
|
if (__ofono_dbus_valid_object_path(path) == FALSE)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1062,6 +1068,7 @@ struct ofono_modem *ofono_modem_create(const char *type)
|
||||||
|
|
||||||
g_modem_list = g_slist_prepend(g_modem_list, modem);
|
g_modem_list = g_slist_prepend(g_modem_list, modem);
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
next_modem_id += 1;
|
next_modem_id += 1;
|
||||||
|
|
||||||
return modem;
|
return modem;
|
||||||
|
|
Loading…
Reference in New Issue