---
 src/gprs.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index 9949210..9107a72 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -107,6 +107,7 @@ struct context_settings {
 
 struct pri_context {
        ofono_bool_t active;
+       int bearer;
        enum ofono_gprs_context_type type;
        char name[MAX_CONTEXT_NAME_LENGTH + 1];
        char message_proxy[MAX_MESSAGE_PROXY_LENGTH + 1];
@@ -596,6 +597,13 @@ static void append_context_properties(struct pri_context 
*ctx,
        value = ctx->active;
        ofono_dbus_dict_append(dict, "Active", DBUS_TYPE_BOOLEAN, &value);
 
+       if (ctx->active) {
+               const char *bearer = packet_bearer_to_string(ctx->bearer);
+
+               ofono_dbus_dict_append(dict, "Bearer",
+                                       DBUS_TYPE_STRING, &bearer);
+       }
+
        ofono_dbus_dict_append(dict, "Type", DBUS_TYPE_STRING, &type);
 
        ofono_dbus_dict_append(dict, "Protocol", DBUS_TYPE_STRING, &proto);
@@ -710,6 +718,7 @@ static void pri_deactivate_callback(const struct 
ofono_error *error, void *data)
        gprs_cid_release(ctx->gprs, ctx->context.cid);
        ctx->context.cid = 0;
        ctx->active = FALSE;
+       ctx->bearer = -1;
        ctx->context_driver->inuse = FALSE;
        ctx->context_driver = NULL;
 
@@ -1308,6 +1317,7 @@ static void gprs_attached_update(struct ofono_gprs *gprs)
                        gprs_cid_release(gprs, ctx->context.cid);
                        ctx->context.cid = 0;
                        ctx->active = FALSE;
+                       ctx->bearer = -1;
                        ctx->context_driver->inuse = FALSE;
                        ctx->context_driver = NULL;
 
@@ -1591,6 +1601,7 @@ static struct pri_context *add_context(struct ofono_gprs 
*gprs,
                return NULL;
        }
 
+       context->bearer = -1;
        context->id = id;
 
        DBG("Registering new context");
@@ -1783,6 +1794,7 @@ static void gprs_deactivate_for_all(const struct 
ofono_error *error,
 
        gprs_cid_release(gprs, ctx->context.cid);
        ctx->active = FALSE;
+       ctx->bearer = -1;
        ctx->context.cid = 0;
        ctx->context_driver->inuse = FALSE;
        ctx->context_driver = NULL;
@@ -2001,6 +2013,31 @@ void ofono_gprs_add_context(struct ofono_gprs *gprs,
        __ofono_atom_register(gc->atom, gprs_context_unregister);
 }
 
+void ofono_gprs_bearer_notify(struct ofono_gprs *gprs,
+                               unsigned int cid, int bearer)
+{
+       DBusConnection *conn = ofono_dbus_get_connection();
+       GSList *l;
+
+       for (l = gprs->contexts; l; l = l->next) {
+               struct pri_context *ctx = l->data;
+               const char *value;
+
+               if (ctx->context.cid != cid)
+                       continue;
+
+               if (ctx->bearer == bearer)
+                       break;
+
+               value = packet_bearer_to_string(bearer);
+
+               ctx->bearer = bearer;
+               ofono_dbus_signal_property_changed(conn, ctx->path,
+                                       OFONO_CONNECTION_CONTEXT_INTERFACE,
+                                       "Bearer", DBUS_TYPE_STRING, &value);
+       }
+}
+
 void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc,
                                        unsigned int cid)
 {
@@ -2024,6 +2061,7 @@ void ofono_gprs_context_deactivated(struct 
ofono_gprs_context *gc,
                gprs_cid_release(ctx->gprs, ctx->context.cid);
                ctx->context.cid = 0;
                ctx->active = FALSE;
+               ctx->bearer = -1;
                ctx->context_driver->inuse = FALSE;
                ctx->context_driver = NULL;
 
-- 
1.7.1

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

Reply via email to