コード例 #1
0
static void
look_for_sms_in_modem (GetSmsContext *ctx)
{
    MMModemMessaging *modem;

    if (!ctx->modems) {
        g_printerr ("error: couldn't find SMS at '%s': 'not found in any modem'\n",
                    ctx->sms_path);
        exit (EXIT_FAILURE);
    }

    /* Loop looking for the sms in each modem found */
    ctx->current = MM_OBJECT (ctx->modems->data);
    ctx->modems = g_list_delete_link (ctx->modems, ctx->modems);

    modem = mm_object_get_modem_messaging (ctx->current);
    if (modem) {
        g_debug ("Looking for sms '%s' in modem '%s'...",
                 ctx->sms_path,
                 mm_object_get_path (ctx->current));
        mm_modem_messaging_list (modem,
                                 ctx->cancellable,
                                 (GAsyncReadyCallback)list_sms_ready,
                                 ctx);
        g_object_unref (modem);
        return;
    }

    /* Current modem has no messaging capabilities, try with next modem */
    look_for_sms_in_modem (ctx);
}
コード例 #2
0
static MMObject *
find_modem (MMManager *manager,
            const gchar *modem_path)
{
    GList *modems;
    GList *l;
    MMObject *found = NULL;

    modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (manager));
    for (l = modems; l; l = g_list_next (l)) {
        MMObject *modem = MM_OBJECT (l->data);

        if (g_str_equal (mm_object_get_path (modem), modem_path)) {
            found = g_object_ref (modem);
            break;
        }
    }
    g_list_free_full (modems, (GDestroyNotify) g_object_unref);

    if (!found) {
        g_printerr ("error: couldn't find modem at '%s'\n", modem_path);
        exit (EXIT_FAILURE);
    }

    g_debug ("Modem found at '%s'\n", modem_path);

    return found;
}
コード例 #3
0
ファイル: gclue-modem-source.c プロジェクト: eggpi/mc723
static void
on_mm_object_removed (GDBusObjectManager *manager,
                      GDBusObject        *object,
                      gpointer            user_data)
{
        MMObject *mm_object = MM_OBJECT (object);
        GClueModemSourcePrivate *priv = GCLUE_MODEM_SOURCE (user_data)->priv;

        if (priv->mm_object == NULL || priv->mm_object != mm_object)
                return;

        g_clear_object (&priv->mm_object);
        g_clear_object (&priv->modem);
        g_clear_object (&priv->modem_location);
}
コード例 #4
0
static void
get_sim_manager_ready (GDBusConnection *connection,
                       GAsyncResult *res,
                       GetSimContext *ctx)
{
    GList *l;
    GList *modems;

    ctx->manager = mmcli_get_manager_finish (res);

    modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (ctx->manager));
    if (!modems) {
        g_printerr ("error: couldn't find sim at '%s': 'no modems found'\n",
                    ctx->sim_path);
        exit (EXIT_FAILURE);
    }

    for (l = modems; l; l = g_list_next (l)) {
        MMObject *object;
        MMModem *modem;

        object = MM_OBJECT (l->data);
        modem = mm_object_get_modem (object);
        if (g_str_equal (ctx->sim_path, mm_modem_get_sim_path (modem))) {
            ctx->modem  = g_object_ref (object);
            mm_modem_get_sim (modem,
                              ctx->cancellable,
                              (GAsyncReadyCallback)get_sim_ready,
                              ctx);
            break;
        }
        g_object_unref (modem);
    }

    if (!ctx->modem) {
        g_printerr ("error: couldn't find sim at '%s'\n",
                    ctx->sim_path);
        exit (EXIT_FAILURE);
    }

    g_list_free_full (modems, (GDestroyNotify) g_object_unref);
}
コード例 #5
0
ファイル: gclue-modem-source.c プロジェクト: eggpi/mc723
static void
on_mm_object_added (GDBusObjectManager *manager,
                    GDBusObject        *object,
                    gpointer            user_data)
{
        MMObject *mm_object = MM_OBJECT (object);
        GClueModemSource *source= GCLUE_MODEM_SOURCE (user_data);
        GClueModemSourceClass *klass = GCLUE_MODEM_SOURCE_GET_CLASS (source);
        MMModemLocation *modem_location;
        MMModemLocationSource req_caps, caps;
        const char *caps_name;

        if (source->priv->mm_object != NULL)
                return;

        g_debug ("New modem '%s'", mm_object_get_path (mm_object));
        modem_location = mm_object_peek_modem_location (mm_object);
        if (modem_location == NULL)
                return;

        g_debug ("Modem '%s' has location capabilities",
                 mm_object_get_path (mm_object));
        caps = mm_modem_location_get_capabilities (modem_location);
        req_caps = klass->get_req_modem_location_caps (source, &caps_name);
        if ((caps & req_caps) == 0)
                return;

        g_debug ("Modem '%s' has %s capabilities",
                 mm_object_get_path (mm_object),
                 caps_name);
        source->priv->mm_object = g_object_ref (mm_object);
        source->priv->modem = mm_object_get_modem (mm_object);
        source->priv->modem_location = mm_object_get_modem_location (mm_object);

        mm_modem_enable (source->priv->modem,
                         source->priv->cancellable,
                         on_modem_enabled,
                         user_data);
}
コード例 #6
0
static void
look_for_bearer_in_modem (GetBearerContext *ctx)
{
    MMModem *modem;

    if (!ctx->modems) {
        g_printerr ("error: couldn't find bearer at '%s': 'not found in any modem'\n",
                    ctx->bearer_path);
        exit (EXIT_FAILURE);
    }

    /* Loop looking for the bearer in each modem found */
    ctx->current = MM_OBJECT (ctx->modems->data);
    ctx->modems = g_list_delete_link (ctx->modems, ctx->modems);

    modem = mm_object_get_modem (ctx->current);

    /* Don't look for bearers in modems which are not fully initialized */
    if (mm_modem_get_state (modem) < MM_MODEM_STATE_DISABLED) {
        g_debug ("Skipping modem '%s' when looking for bearers "
                 "(not fully initialized)",
                 mm_object_get_path (ctx->current));
        g_object_unref (modem);
        look_for_bearer_in_modem (ctx);
        return;
    }

    g_debug ("Looking for bearer '%s' in modem '%s'...",
             ctx->bearer_path,
             mm_object_get_path (ctx->current));

    mm_modem_list_bearers (modem,
                           ctx->cancellable,
                           (GAsyncReadyCallback)list_bearers_ready,
                           ctx);
    g_object_unref (modem);
}
コード例 #7
0
MMSms *
mmcli_get_sms_sync (GDBusConnection *connection,
                    const gchar *path_or_index,
                    MMManager **o_manager,
                    MMObject **o_object)
{
    MMManager *manager;
    GList *modems;
    GList *l;
    MMSms *found = NULL;
    gchar *sms_path;

    sms_path = get_sms_path (path_or_index);

    manager = mmcli_get_manager_sync (connection);
    modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (manager));
    if (!modems) {
        g_printerr ("error: couldn't find sms at '%s': 'no modems found'\n",
                    sms_path);
        exit (EXIT_FAILURE);
    }

    for (l = modems; !found && l; l = g_list_next (l)) {
        GError *error = NULL;
        MMObject *object;
        MMModemMessaging *modem;
        GList *sms_list;

        object = MM_OBJECT (l->data);
        modem = mm_object_get_modem_messaging (object);

        /* If this modem doesn't implement messaging, continue to next one */
        if (!modem)
            continue;

        sms_list = mm_modem_messaging_list_sync (modem, NULL, &error);
        if (error) {
            g_printerr ("error: couldn't list SMS at '%s': '%s'\n",
                        mm_modem_messaging_get_path (modem),
                        error->message);
            exit (EXIT_FAILURE);
        }

        found = find_sms_in_list (sms_list, sms_path);
        g_list_free_full (sms_list, (GDestroyNotify) g_object_unref);

        if (found && o_object)
            *o_object = g_object_ref (object);

        g_object_unref (modem);
    }

    if (!found) {
        g_printerr ("error: couldn't find SMS at '%s': 'not found in any modem'\n",
                    sms_path);
        exit (EXIT_FAILURE);
    }

    g_list_free_full (modems, (GDestroyNotify) g_object_unref);
    g_free (sms_path);

    if (o_manager)
        *o_manager = manager;
    else
        g_object_unref (manager);

    return found;
}
コード例 #8
0
MMSim *
mmcli_get_sim_sync (GDBusConnection *connection,
                    const gchar *path_or_index,
                    MMManager **o_manager,
                    MMObject **o_object)
{
    MMManager *manager;
    GList *modems;
    GList *l;
    MMSim *found = NULL;
    gchar *sim_path;

    sim_path = get_sim_path (path_or_index);

    manager = mmcli_get_manager_sync (connection);
    modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (manager));
    if (!modems) {
        g_printerr ("error: couldn't find sim at '%s': 'no modems found'\n",
                    sim_path);
        exit (EXIT_FAILURE);
    }

    for (l = modems; !found && l; l = g_list_next (l)) {
        GError *error = NULL;
        MMObject *object;
        MMModem *modem;

        object = MM_OBJECT (l->data);
        modem = mm_object_get_modem (object);
        if (g_str_equal (sim_path, mm_modem_get_sim_path (modem))) {
            found = mm_modem_get_sim_sync (modem, NULL, &error);
            if (error) {
                g_printerr ("error: couldn't get sim '%s' in modem '%s': '%s'\n",
                            sim_path,
                            mm_modem_get_path (modem),
                            error->message);
                exit (EXIT_FAILURE);
            }

            if (found && o_object)
                *o_object = g_object_ref (object);
        }

        g_object_unref (modem);
    }

    if (!found) {
        g_printerr ("error: couldn't find sim at '%s'\n", sim_path);
        exit (EXIT_FAILURE);
    }

    g_list_free_full (modems, (GDestroyNotify) g_object_unref);
    g_free (sim_path);

    if (o_manager)
        *o_manager = manager;
    else
        g_object_unref (manager);

    return found;
}
コード例 #9
0
MMBearer *
mmcli_get_bearer_sync (GDBusConnection *connection,
                       const gchar *path_or_index,
                       MMManager **o_manager,
                       MMObject **o_object)
{
    MMManager *manager;
    GList *modems;
    GList *l;
    MMBearer *found = NULL;
    gchar *bearer_path;

    bearer_path = get_bearer_path (path_or_index);

    manager = mmcli_get_manager_sync (connection);
    modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (manager));
    if (!modems) {
        g_printerr ("error: couldn't find bearer at '%s': 'no modems found'\n",
                    bearer_path);
        exit (EXIT_FAILURE);
    }

    for (l = modems; !found && l; l = g_list_next (l)) {
        GError *error = NULL;
        MMObject *object;
        MMModem *modem;
        GList *bearers;

        object = MM_OBJECT (l->data);
        modem = mm_object_get_modem (object);

        /* Don't look for bearers in modems which are not fully initialized */
        if (mm_modem_get_state (modem) < MM_MODEM_STATE_DISABLED) {
            g_debug ("Skipping modem '%s' when looking for bearers "
                     "(not fully initialized)",
                     mm_object_get_path (object));
            g_object_unref (modem);
            continue;
        }

        bearers = mm_modem_list_bearers_sync (modem, NULL, &error);
        if (error) {
            g_printerr ("error: couldn't list bearers at '%s': '%s'\n",
                        mm_modem_get_path (modem),
                        error->message);
            exit (EXIT_FAILURE);
        }

        found = find_bearer_in_list (bearers, bearer_path);
        g_list_free_full (bearers, (GDestroyNotify) g_object_unref);

        if (found && o_object)
            *o_object = g_object_ref (object);

        g_object_unref (modem);
    }

    if (!found) {
        g_printerr ("error: couldn't find bearer at '%s': 'not found in any modem'\n",
                    bearer_path);
        exit (EXIT_FAILURE);
    }

    g_list_free_full (modems, (GDestroyNotify) g_object_unref);
    g_free (bearer_path);

    if (o_manager)
        *o_manager = manager;
    else
        g_object_unref (manager);

    return found;
}