[PATCH 2/4] add create/destroy_interface to ofono_gprs_context_driver
Martin Xu
martin.xu at intel.com
Sun Nov 8 23:37:59 PST 2009
---
include/gprs-context.h | 4 ++++
src/gprs.c | 20 ++++++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/include/gprs-context.h b/include/gprs-context.h
index adb0820..b8c770d 100644
--- a/include/gprs-context.h
+++ b/include/gprs-context.h
@@ -57,6 +57,10 @@ struct ofono_gprs_context_driver {
void (*deactivate_primary)(struct ofono_gprs_context *gc,
unsigned int id,
ofono_gprs_context_cb_t cb, void *data);
+ void (*create_interface)(struct ofono_gprs_context *gc,
+ struct ofono_gprs_primary_context *ctx);
+ void (*destroy_interface)(struct ofono_gprs_context *gc,
+ struct ofono_gprs_primary_context *ctx);
};
void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc, unsigned id);
diff --git a/src/gprs.c b/src/gprs.c
index 18ae82a..60d26ec 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -498,21 +498,29 @@ static struct pri_context *pri_context_create(struct ofono_gprs *gprs,
const char *name,
enum gprs_context_type type)
{
- struct pri_context *context = g_try_new0(struct pri_context, 1);
+ struct ofono_gprs_context *gc = gprs->context_driver;
+ struct pri_context *ctx = g_try_new0(struct pri_context, 1);
- if (!context)
+ if (!ctx)
return NULL;
- context->gprs = gprs;
- strcpy(context->name, name);
- context->type = type;
+ ctx->gprs = gprs;
+ strcpy(ctx->name, name);
+ ctx->type = type;
+
+ if (gc->driver->create_interface)
+ gc->driver->create_interface(gc, &ctx->context);
- return context;
+ return ctx;
}
static void pri_context_destroy(gpointer userdata)
{
struct pri_context *ctx = userdata;
+ struct ofono_gprs_context *gc = ctx->gprs->context_driver;
+
+ if (gc->driver->destroy_interface)
+ gc->driver->destroy_interface(gc, &ctx->context);
if (ctx->path)
g_free(ctx->path);
--
1.6.1.3
More information about the ofono
mailing list