Changes include context creation and signalling of
dbus property property changes.
---
 src/packet.c |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 1 deletions(-)

diff --git a/src/packet.c b/src/packet.c
index ed8e1ae..f8a76c6 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -2950,6 +2950,100 @@ void *ofono_packet_service_get_data(struct 
ofono_packet_service *ps)
        return ps->driver_data;
 }
 
+void ofono_packet_service_default_context_notify(
+                               struct ofono_packet_service *ps,
+                               struct ofono_default_context_param *dc)
+{
+       DBusConnection *conn = ofono_dbus_get_connection();
+       struct context *ctx;
+       struct context_settings *settings;
+       GSList *l;
+       dbus_bool_t value;
+
+       /*
+        * Assumption: context id for default EPS context will have value
+        * outside the ranges indicated in the test form of the command
+        * +CGDCONT.
+        */
+       ctx = context_create(ps, "default", OFONO_PACKET_CONTEXT_TYPE_DEFAULT);
+       if (ctx == NULL) {
+               ofono_error("Unable to allocate memory for default context");
+               return;
+       }
+
+       ctx->id = dc->cid;
+       ctx->active = TRUE;
+       ctx->context.proto = dc->proto;
+       strcpy(ctx->context.apn, dc->apn);
+
+       for (l = ctx->ps->context_drivers; l; l = l->next) {
+               struct ofono_packet_context *pc = l->data;
+
+               if (pc->inuse == TRUE)
+                       continue;
+
+               if (pc->driver == NULL)
+                       continue;
+
+               if (pc->driver->activate_context == NULL ||
+                               pc->driver->deactivate_context == NULL)
+                       continue;
+
+               if (pc->type != OFONO_PACKET_CONTEXT_TYPE_ANY &&
+                               pc->type != ctx->type)
+                       continue;
+
+               ctx->context_driver = pc;
+               ctx->context_driver->inuse = TRUE;
+
+               if (ctx->context.proto == OFONO_PACKET_PROTO_IPV4V6 ||
+                               ctx->context.proto == OFONO_PACKET_PROTO_IP)
+                       pc->settings->ipv4 = g_new0(struct ipv4_settings, 1);
+
+               if (ctx->context.proto == OFONO_PACKET_PROTO_IPV4V6 ||
+                               ctx->context.proto == OFONO_PACKET_PROTO_IPV6)
+                       pc->settings->ipv6 = g_new0(struct ipv6_settings, 1);
+
+               ofono_packet_context_set_type(pc, ctx->type);
+               ofono_packet_context_set_interface(pc, dc->interface);
+
+               if (pc->settings->ipv4) {
+                       ofono_packet_context_set_ipv4_address(pc, dc->address,
+                                                                       TRUE);
+                       ofono_packet_context_set_ipv4_gateway(pc, dc->gateway);
+                       ofono_packet_context_set_ipv4_dns_servers(pc, dc->dns);
+               }
+
+               if (pc->settings->ipv6) {
+                       ofono_packet_context_set_ipv6_address(pc, dc->address);
+                       ofono_packet_context_set_ipv6_gateway(pc, dc->gateway);
+                       ofono_packet_context_set_ipv6_dns_servers(pc, dc->dns);
+               }
+
+               break;
+       }
+
+       settings = ctx->context_driver->settings;
+
+       /*
+        * If context dbus registration fails or unregistered, context id is
+        * put back into the idmap which should not be done for default
+        * context if the context id doesn't fall within range supplied by
+        * +CGDCONT. TODO: This needs to be addressed.
+        */
+       if (!context_dbus_register(ctx)) {
+               ofono_error("Unable to register default context");
+               return;
+       }
+
+       ps->contexts = g_slist_append(ps->contexts, ctx);
+
+       value = ctx->active;
+       ofono_dbus_signal_property_changed(conn, ctx->path,
+                                       OFONO_CONNECTION_CONTEXT_INTERFACE,
+                                       "Active", DBUS_TYPE_BOOLEAN, &value);
+}
+
 int ofono_packet_service_get_technology(struct ofono_packet_service *ps)
 {
        if (ps->netreg_status != NETWORK_REGISTRATION_STATUS_ROAMING &&
@@ -2957,4 +3051,4 @@ int ofono_packet_service_get_technology(struct 
ofono_packet_service *ps)
                return -1;
 
        return ps->netreg_access_tech;
-}
\ No newline at end of file
+}
-- 
1.7.0.4

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to