Skip to content

Commit

Permalink
[mms-ofono] Wait until ofono client interfaces are initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Nov 6, 2015
1 parent 0c9f064 commit e4457b5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions mms-ofono/src/mms_ofono_connman.c
Expand Up @@ -62,6 +62,45 @@ 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))

#define MMS_OFONO_TIMEOUT (30000)

/**
* Waits until ofono client interfaces are initialized.
*/
static
void
mms_ofono_connman_wait_valid(
MMSOfonoConnMan* self)
{
GError* error = NULL;
if (ofono_manager_wait_valid(self->manager, MMS_OFONO_TIMEOUT, &error)) {
if (self->default_modem &&
self->default_modem->modem &&
!ofono_modem_wait_valid(self->default_modem->modem,
MMS_OFONO_TIMEOUT, &error)) {
MMS_ERR("%s", MMS_ERRMSG(error));
g_error_free(error);
}
if (self->default_modem &&
self->default_modem->simmgr &&
!ofono_simmgr_wait_valid(self->default_modem->simmgr,
MMS_OFONO_TIMEOUT, &error)) {
MMS_ERR("%s", MMS_ERRMSG(error));
g_error_free(error);
}
if (self->default_modem &&
self->default_modem->connmgr &&
!ofono_connmgr_wait_valid(self->default_modem->connmgr,
MMS_OFONO_TIMEOUT, &error)) {
MMS_ERR("%s", MMS_ERRMSG(error));
g_error_free(error);
}
} else {
MMS_ERR("%s", MMS_ERRMSG(error));
g_error_free(error);
}
}

/**
* Finds OfonoModem for the specified IMSI. If it returns non-NULL, the modem
* is guaranteed to have SimManager associated with it.
Expand All @@ -72,6 +111,7 @@ mms_ofono_connman_modem_for_imsi(
MMSOfonoConnMan* self,
const char* imsi)
{
mms_ofono_connman_wait_valid(self);
if (imsi) {
GHashTableIter iter;
gpointer key, value;
Expand Down Expand Up @@ -111,6 +151,7 @@ mms_ofono_connman_default_imsi(
MMSConnMan* cm)
{
MMSOfonoConnMan* self = MMS_OFONO_CONNMAN(cm);
mms_ofono_connman_wait_valid(self);
if (self->default_modem &&
self->default_modem->simmgr &&
self->default_modem->simmgr->imsi &&
Expand Down
2 changes: 1 addition & 1 deletion rpm/mms-engine.spec
Expand Up @@ -20,7 +20,7 @@ BuildRequires: pkgconfig(gmime-2.6)
BuildRequires: pkgconfig(glib-2.0) >= 2.32
BuildRequires: pkgconfig(libsoup-2.4) >= 2.38
BuildRequires: pkgconfig(libwspcodec) >= 2.2
BuildRequires: pkgconfig(libgofono)
BuildRequires: pkgconfig(libgofono) >= 1.0.5
BuildRequires: pkgconfig(libglibutil)
#BuildRequires: pkgconfig(ImageMagick)
BuildRequires: pkgconfig(Qt5Gui)
Expand Down

0 comments on commit e4457b5

Please sign in to comment.