* [PATCH 1/5] ignore the NULL dict entry @ 2009-11-17 15:49 Martin Xu 2009-11-17 15:49 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Martin Xu 0 siblings, 1 reply; 6+ messages in thread From: Martin Xu @ 2009-11-17 15:49 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 514 bytes --] --- src/dbus.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index b74481f..942294e 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -134,6 +134,9 @@ static void append_dict_variant(DBusMessageIter *iter, int type, void *val) typesig, &array); for (i = 0; val_array[i]; i += 2) { + if (val_array[i + 1] == NULL) + continue; + dbus_message_iter_open_container(&array, DBUS_TYPE_DICT_ENTRY, NULL, &entry); -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context 2009-11-17 15:49 [PATCH 1/5] ignore the NULL dict entry Martin Xu @ 2009-11-17 15:49 ` Martin Xu 2009-11-17 15:49 ` [PATCH 3/5] ofono_gprs_context_update_settings Martin Xu 2009-11-18 0:57 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Denis Kenzior 0 siblings, 2 replies; 6+ messages in thread From: Martin Xu @ 2009-11-17 15:49 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 4282 bytes --] --- src/gprs.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-) diff --git a/src/gprs.c b/src/gprs.c index 0253109..a8d8afa 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -82,9 +82,19 @@ struct ofono_gprs { struct ofono_atom *atom; }; +struct context_settings { + char *interface; + char *method; + char *address; + char *netmask; + char *dns; + char *gateway; +}; + struct ofono_gprs_context { struct ofono_gprs *gprs; DBusMessage *pending; + struct context_settings settings; const struct ofono_gprs_context_driver *driver; void *driver_data; struct ofono_atom *atom; @@ -97,6 +107,7 @@ struct pri_context { char name[MAX_CONTEXT_NAME_LENGTH + 1]; char *path; char *key; + struct context_settings settings; struct ofono_gprs_primary_context context; struct ofono_gprs *gprs; }; @@ -190,6 +201,102 @@ static DBusMessage *pri_get_properties(DBusConnection *conn, return reply; } +static void context_settings_dup(struct context_settings *to, + struct context_settings *from) +{ + g_free(to->interface); + to->interface = g_strdup(from->interface); + + g_free(to->method); + to->method = g_strdup(from->method); + + g_free(to->address); + to->address = g_strdup(from->address); + + g_free(to->netmask); + to->netmask = g_strdup(from->netmask); + + g_free(to->dns); + to->dns = g_strdup(from->dns); + + g_free(to->gateway); + to->gateway = g_strdup(from->gateway); +} + +static void cleanup_context_settings(struct context_settings *settings) +{ + g_free(settings->interface); + settings->interface = NULL; + + g_free(settings->method); + settings->method = NULL; + + g_free(settings->address); + settings->address = NULL; + + g_free(settings->netmask); + settings->netmask = NULL; + + g_free(settings->dns); + settings->dns = NULL; + + g_free(settings->gateway); + settings->gateway = NULL; +} + +static char **get_settings(struct context_settings *settings) +{ + char **ret; + + ret = g_new0(char *, 13); + + ret[0] = g_strdup("Interface"); + ret[1] = g_strdup(settings->interface); + + ret[2] = g_strdup("Method"); + ret[3] = g_strdup(settings->method); + + ret[4] = g_strdup("Address"); + ret[5] = g_strdup(settings->address); + + ret[6] = g_strdup("Netmask"); + ret[7] = g_strdup(settings->netmask); + + ret[8] = g_strdup("DomainNameServers"); + ret[9] = g_strdup(settings->dns); + + ret[10] = g_strdup("GateWay"); + ret[11] = g_strdup(settings->gateway); + + return ret; +} + +static void pri_context_settings_changed(struct pri_context *ctx) +{ + DBusConnection *conn = ofono_dbus_get_connection(); + char **settings = get_settings(&ctx->settings); + + ofono_dbus_signal_dict_property_changed(conn, ctx->path, + DATA_CONTEXT_INTERFACE, + "Settings", + DBUS_TYPE_STRING, + &settings); + + g_strfreev(settings); +} + +static void update_pri_context_settings(ofono_bool_t active, + struct ofono_gprs_context *gc, + struct pri_context *ctx) +{ + if (active) + context_settings_dup(&ctx->settings, &gc->settings); + else + cleanup_context_settings(&ctx->settings); + + pri_context_settings_changed(ctx); +} + static void pri_set_active_callback(const struct ofono_error *error, void *data) { @@ -215,6 +322,9 @@ static void pri_set_active_callback(const struct ofono_error *error, dbus_message_new_method_return(gc->pending)); value = ctx->active; + + update_pri_context_settings(value, gc, ctx); + ofono_dbus_signal_property_changed(conn, ctx->path, DATA_CONTEXT_INTERFACE, "Active", DBUS_TYPE_BOOLEAN, @@ -510,6 +620,8 @@ static void pri_context_destroy(gpointer userdata) { struct pri_context *ctx = userdata; + cleanup_context_settings(&ctx->settings); + if (ctx->path) g_free(ctx->path); @@ -1185,6 +1297,8 @@ static void gprs_context_remove(struct ofono_atom *atom) if (gc->driver && gc->driver->remove) gc->driver->remove(gc); + cleanup_context_settings(&gc->settings); + g_free(gc); } @@ -1579,3 +1693,4 @@ void *ofono_gprs_get_data(struct ofono_gprs *gprs) { return gprs->driver_data; } + -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] ofono_gprs_context_update_settings 2009-11-17 15:49 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Martin Xu @ 2009-11-17 15:49 ` Martin Xu 2009-11-17 15:49 ` [PATCH 4/5] add function ofono_gprs_context_get_modem Martin Xu 2009-11-18 0:57 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Denis Kenzior 1 sibling, 1 reply; 6+ messages in thread From: Martin Xu @ 2009-11-17 15:49 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1773 bytes --] --- include/gprs-context.h | 8 ++++++++ src/gprs.c | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/include/gprs-context.h b/include/gprs-context.h index c4ebd23..8b860c2 100644 --- a/include/gprs-context.h +++ b/include/gprs-context.h @@ -71,6 +71,14 @@ void ofono_gprs_context_remove(struct ofono_gprs_context *gc); void ofono_gprs_context_set_data(struct ofono_gprs_context *gc, void *data); void *ofono_gprs_context_get_data(struct ofono_gprs_context *gc); +void ofono_gprs_context_update_settings(struct ofono_gprs_context *gc, + const char *interface, + const char *method, + const char *address, + const char *netmask, + const char *dns, + const char *gateway); + #ifdef __cplusplus } #endif diff --git a/src/gprs.c b/src/gprs.c index a8d8afa..a64ff45 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -1694,3 +1694,29 @@ void *ofono_gprs_get_data(struct ofono_gprs *gprs) return gprs->driver_data; } +void ofono_gprs_context_update_settings(struct ofono_gprs_context *gc, + const char *interface, + const char *method, + const char *address, + const char *netmask, + const char *dns, + const char *gateway) +{ + g_free(gc->settings.interface); + gc->settings.interface = g_strdup(interface); + + g_free(gc->settings.method); + gc->settings.method = g_strdup(method); + + g_free(gc->settings.address); + gc->settings.address = g_strdup(address); + + g_free(gc->settings.netmask); + gc->settings.netmask = g_strdup(netmask); + + g_free(gc->settings.dns); + gc->settings.dns = g_strdup(dns); + + g_free(gc->settings.gateway); + gc->settings.gateway = g_strdup(gateway); +} -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] add function ofono_gprs_context_get_modem 2009-11-17 15:49 ` [PATCH 3/5] ofono_gprs_context_update_settings Martin Xu @ 2009-11-17 15:49 ` Martin Xu 2009-11-17 15:49 ` [PATCH 5/5] update gprs context settings when activating primary conext Martin Xu 0 siblings, 1 reply; 6+ messages in thread From: Martin Xu @ 2009-11-17 15:49 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 985 bytes --] --- include/gprs-context.h | 2 ++ src/gprs.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/include/gprs-context.h b/include/gprs-context.h index 8b860c2..95b2bae 100644 --- a/include/gprs-context.h +++ b/include/gprs-context.h @@ -79,6 +79,8 @@ void ofono_gprs_context_update_settings(struct ofono_gprs_context *gc, const char *dns, const char *gateway); +struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc); + #ifdef __cplusplus } #endif diff --git a/src/gprs.c b/src/gprs.c index a64ff45..7d37389 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -1720,3 +1720,8 @@ void ofono_gprs_context_update_settings(struct ofono_gprs_context *gc, g_free(gc->settings.gateway); gc->settings.gateway = g_strdup(gateway); } + + struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc) +{ + return __ofono_atom_get_modem(gc->atom); +} -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] update gprs context settings when activating primary conext 2009-11-17 15:49 ` [PATCH 4/5] add function ofono_gprs_context_get_modem Martin Xu @ 2009-11-17 15:49 ` Martin Xu 0 siblings, 0 replies; 6+ messages in thread From: Martin Xu @ 2009-11-17 15:49 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1247 bytes --] --- drivers/mbmmodem/gprs-context.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/mbmmodem/gprs-context.c b/drivers/mbmmodem/gprs-context.c index ecbafa0..b800d4a 100644 --- a/drivers/mbmmodem/gprs-context.c +++ b/drivers/mbmmodem/gprs-context.c @@ -116,6 +116,18 @@ static void mbm_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data) CALLBACK_WITH_FAILURE(cb, cbd->data); } +static void update_gprs_context_settings(struct ofono_gprs_context *gc) +{ + const char *interface; + + struct ofono_modem *modem = ofono_gprs_context_get_modem(gc); + + interface = ofono_modem_get_string(modem, "NetworkInterface"); + + ofono_gprs_context_update_settings(gc, interface, "dhcp", + NULL, NULL, NULL, NULL); +} + static void mbm_gprs_activate_primary(struct ofono_gprs_context *gc, const struct ofono_gprs_primary_context *ctx, ofono_gprs_context_cb_t cb, void *data) @@ -132,6 +144,8 @@ static void mbm_gprs_activate_primary(struct ofono_gprs_context *gc, cbd->user = gc; + update_gprs_context_settings(gc); + /* TODO: Handle username / password fields */ len = sprintf(buf, "AT+CGDCONT=%u,\"IP\"", ctx->cid); -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context 2009-11-17 15:49 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Martin Xu 2009-11-17 15:49 ` [PATCH 3/5] ofono_gprs_context_update_settings Martin Xu @ 2009-11-18 0:57 ` Denis Kenzior 1 sibling, 0 replies; 6+ messages in thread From: Denis Kenzior @ 2009-11-18 0:57 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 272 bytes --] Hi Martin, > --- > src/gprs.c | 115 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files > changed, 115 insertions(+), 0 deletions(-) > So I pushed out my own changes inspired by your patch. Let me know how they work. Regards, -Denis ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-18 0:57 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-11-17 15:49 [PATCH 1/5] ignore the NULL dict entry Martin Xu 2009-11-17 15:49 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Martin Xu 2009-11-17 15:49 ` [PATCH 3/5] ofono_gprs_context_update_settings Martin Xu 2009-11-17 15:49 ` [PATCH 4/5] add function ofono_gprs_context_get_modem Martin Xu 2009-11-17 15:49 ` [PATCH 5/5] update gprs context settings when activating primary conext Martin Xu 2009-11-18 0:57 ` [PATCH 2/5] emit PropertyChanged Settings signal after active/deactive primary context Denis Kenzior
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.