Commit b606e0c5 authored by Slava Monich's avatar Slava Monich

Added mms_connman_default_imsi API

parent db2304ae
......@@ -19,6 +19,7 @@
typedef struct mms_connman_class {
GObjectClass parent;
char* (*fn_default_imsi)(MMSConnMan* cm);
MMSConnection* (*fn_open_connection)(MMSConnMan* cm, const char* imsi,
gboolean user_request);
} MMSConnManClass;
......@@ -35,6 +36,14 @@ void
mms_connman_unref(
MMSConnMan* cm);
/**
* Returns default (first available) IMSI or NULL if SIM is not present
* or not configured. Caller must g_free() the returned string.
*/
char*
mms_connman_default_imsi(
MMSConnMan* cm);
/**
* Creates a new connection or returns the reference to an aready active one.
* The caller must release the reference.
......
......@@ -55,6 +55,23 @@ mms_connman_init(
{
}
/**
* Returns default (first available) IMSI or NULL if SIM is not present
* or not configured. Caller must g_free() the returned string.
*/
char*
mms_connman_default_imsi(
MMSConnMan* cm)
{
if (cm) {
MMSConnManClass* klass = MMS_CONNMAN_GET_CLASS(cm);
if (klass->fn_default_imsi) {
return klass->fn_default_imsi(cm);
}
}
return NULL;
}
/**
* Creates a new connection or returns the reference to an aready active one.
* The caller must release the reference.
......
......@@ -37,6 +37,24 @@ G_DEFINE_TYPE(MMSOfonoConnMan, mms_ofono_connman, MMS_TYPE_CONNMAN);
#define MMS_OFONO_CONNMAN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
MMS_TYPE_OFONO_CONNMAN, MMSOfonoConnMan))
/**
* Returns IMSI of the default SIM
*/
static
char*
mms_ofono_connman_default_imsi(
MMSConnMan* cm)
{
MMSOfonoConnMan* ofono = MMS_OFONO_CONNMAN(cm);
if (ofono->man) {
MMSOfonoModem* modem = mms_ofono_manager_default_modem(ofono->man);
if (modem && modem->imsi) {
return g_strdup(modem->imsi);
}
}
return NULL;
}
/**
* Creates a new connection or returns the reference to an aready active one.
* The caller must release the reference.
......@@ -153,6 +171,7 @@ void
mms_ofono_connman_class_init(
MMSOfonoConnManClass* klass)
{
klass->fn_default_imsi = mms_ofono_connman_default_imsi;
klass->fn_open_connection = mms_ofono_connman_open_connection;
G_OBJECT_CLASS(klass)->dispose = mms_ofono_connman_dispose;
}
......
......@@ -155,6 +155,21 @@ mms_ofono_manager_modem_imsi_find_cb(
return modem->imsi && !strcmp(modem->imsi, imsi);
}
MMSOfonoModem*
mms_ofono_manager_default_modem(
MMSOfonoManager* ofono)
{
if (g_hash_table_size(ofono->modems) > 0) {
GHashTableIter iter;
gpointer key, value = NULL;
g_hash_table_iter_init(&iter, ofono->modems);
if (g_hash_table_iter_next(&iter, &key, &value)) {
return value;
}
}
return NULL;
}
MMSOfonoModem*
mms_ofono_manager_modem_for_imsi(
MMSOfonoManager* ofono,
......
......@@ -25,6 +25,10 @@ void
mms_ofono_manager_free(
MMSOfonoManager* ofono);
MMSOfonoModem*
mms_ofono_manager_default_modem(
MMSOfonoManager* ofono);
MMSOfonoModem*
mms_ofono_manager_modem_for_imsi(
MMSOfonoManager* ofono,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment