static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_time = mm_object_get_modem_time (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_time)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_time));

    ensure_modem_time ();

    /* Request to get network time from the modem? */
    if (time_flag) {
        g_debug ("Asynchronously getting network time from the modem...");

        mm_modem_time_get_network_time (ctx->modem_time,
                                        ctx->cancellable,
                                        (GAsyncReadyCallback)get_network_time_ready,
                                        NULL);
        return;
    }

    g_warn_if_reached ();
}
Esempio n. 2
0
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_cdma)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_cdma));

    ensure_modem_cdma ();

    /* Request to activate the modem? */
    if (activate_str) {
        g_debug ("Asynchronously activating the modem...");
        mm_modem_cdma_activate (ctx->modem_cdma,
                                activate_str,
                                ctx->cancellable,
                                (GAsyncReadyCallback)activate_ready,
                                NULL);
        return;
    }

    g_warn_if_reached ();
}
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_messaging = mm_object_get_modem_messaging (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_messaging)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_messaging));

    ensure_modem_messaging ();

    if (status_flag)
        g_assert_not_reached ();

    /* Request to list SMS? */
    if (list_flag) {
        g_debug ("Asynchronously listing SMS in modem...");
        mm_modem_messaging_list (ctx->modem_messaging,
                                 ctx->cancellable,
                                 (GAsyncReadyCallback)list_ready,
                                 NULL);
        return;
    }

    /* Request to create a new SMS? */
    if (create_str) {
        MMSmsProperties *properties;

        properties = build_sms_properties_from_input (create_str,
                                                      create_with_data_str);
        g_debug ("Asynchronously creating new SMS in modem...");
        mm_modem_messaging_create (ctx->modem_messaging,
                                   properties,
                                   ctx->cancellable,
                                   (GAsyncReadyCallback)create_ready,
                                   NULL);
        g_object_unref (properties);
        return;
    }

    /* Request to delete a given SMS? */
    if (delete_str) {
        mmcli_get_sms (ctx->connection,
                       delete_str,
                       ctx->cancellable,
                       (GAsyncReadyCallback)get_sms_to_delete_ready,
                       NULL);
        return;
    }

    g_warn_if_reached ();
}
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_firmware = mm_object_get_modem_firmware (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_firmware)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_firmware));

    ensure_modem_firmware ();

    /* Request to list images? */
    if (list_flag) {
        g_debug ("Asynchronously listing firmware images in modem...");
        mm_modem_firmware_list (ctx->modem_firmware,
                                ctx->cancellable,
                                (GAsyncReadyCallback)list_ready,
                                NULL);
        return;
    }

    /* Request to select a given image? */
    if (select_str) {
        g_debug ("Asynchronously selecting firmware image in modem...");
        mm_modem_firmware_select (ctx->modem_firmware,
                                  select_str,
                                  ctx->cancellable,
                                  (GAsyncReadyCallback)create_ready,
                                  NULL);
        return;
    }

    g_warn_if_reached ();
}
Esempio n. 5
0
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_signal = mm_object_get_modem_signal (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_signal)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_signal));

    ensure_modem_signal ();

    if (get_flag)
        g_assert_not_reached ();

    /* Request to setup? */
    if (setup_str) {
        guint rate;

        if (!mm_get_uint_from_str (setup_str, &rate)) {
            g_printerr ("error: invalid rate value '%s'", setup_str);
            exit (EXIT_FAILURE);
        }

        g_debug ("Asynchronously setting up extended signal quality information retrieval...");
        mm_modem_signal_setup (ctx->modem_signal,
                               rate,
                               ctx->cancellable,
                               (GAsyncReadyCallback)setup_ready,
                               NULL);
        return;
    }

    g_warn_if_reached ();
}
Esempio n. 6
0
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_location = mm_object_get_modem_location (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_location)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_location));

    ensure_modem_location ();

    if (status_flag)
        g_assert_not_reached ();

    /* Request to setup location gathering? */
    if (enable_3gpp_flag ||
        disable_3gpp_flag ||
        enable_agps_flag ||
        disable_agps_flag ||
        enable_gps_nmea_flag ||
        disable_gps_nmea_flag ||
        enable_gps_raw_flag ||
        disable_gps_raw_flag ||
        enable_cdma_bs_flag ||
        disable_cdma_bs_flag ||
        enable_gps_unmanaged_flag ||
        disable_gps_unmanaged_flag ||
        set_enable_signal_flag ||
        set_disable_signal_flag) {
        g_debug ("Asynchronously setting up location gathering...");
        mm_modem_location_setup (ctx->modem_location,
                                 build_sources_from_flags (),
                                 build_signals_location_from_flags (),
                                 ctx->cancellable,
                                 (GAsyncReadyCallback)setup_ready,
                                 NULL);
        return;
    }

    /* Request to get location from the modem? */
    if (get_3gpp_flag ||
        get_gps_nmea_flag ||
        get_gps_raw_flag ||
        get_cdma_bs_flag) {
        g_debug ("Asynchronously getting location from the modem...");
        mm_modem_location_get_full (ctx->modem_location,
                                    ctx->cancellable,
                                    (GAsyncReadyCallback)get_location_ready,
                                    NULL);
        return;
    }

    /* Request to set SUPL server? */
    if (set_supl_server_str) {
        g_debug ("Asynchronously setting SUPL server...");
        mm_modem_location_set_supl_server (ctx->modem_location,
                                           set_supl_server_str,
                                           ctx->cancellable,
                                           (GAsyncReadyCallback)set_supl_server_ready,
                                           NULL);
        return;
    }

    /* Request to set GPS refresh rate? */
    if (set_gps_refresh_rate_str) {
        guint rate;

        if (!mm_get_uint_from_str (set_gps_refresh_rate_str, &rate)) {
            g_printerr ("error: couldn't set GPS refresh rate: invalid rate given: '%s'\n",
                        set_gps_refresh_rate_str);
            exit (EXIT_FAILURE);
        }
        g_debug ("Asynchronously setting GPS refresh rate...");
        mm_modem_location_set_gps_refresh_rate (ctx->modem_location,
                                                rate,
                                                ctx->cancellable,
                                                (GAsyncReadyCallback)set_gps_refresh_rate_ready,
                                                NULL);
        return;
    }

    g_warn_if_reached ();
}
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_simple = mm_object_get_modem_simple (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_simple)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_simple));

    ensure_modem_simple ();

    /* Request to connect the modem? */
    if (connect_str) {
        GError *error = NULL;
        MMSimpleConnectProperties *properties;

        g_debug ("Asynchronously connecting the modem...");

        properties = mm_simple_connect_properties_new_from_string (connect_str, &error);
        if (!properties) {
            g_printerr ("Error parsing connect string: '%s'\n", error->message);
            exit (EXIT_FAILURE);
        }

        mm_modem_simple_connect (ctx->modem_simple,
                                 properties,
                                 ctx->cancellable,
                                 (GAsyncReadyCallback)connect_ready,
                                 NULL);
        g_object_unref (properties);
        return;
    }

    /* Request to disconnect all bearers in the modem? */
    if (disconnect_flag) {
        g_debug ("Asynchronously disconnecting all bearers in the modem...");

        mm_modem_simple_disconnect (ctx->modem_simple,
                                    NULL,
                                    ctx->cancellable,
                                    (GAsyncReadyCallback)disconnect_ready,
                                    NULL);
        return;
    }

    /* Request to get status from the modem? */
    if (status_flag) {
        g_debug ("Asynchronously getting status from the modem...");

        mm_modem_simple_get_status (ctx->modem_simple,
                                    ctx->cancellable,
                                    (GAsyncReadyCallback)status_ready,
                                    NULL);
        return;
    }

    g_warn_if_reached ();
}
Esempio n. 8
0
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem = mm_object_get_modem (ctx->object);
    ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object);
    ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem));
    if (ctx->modem_3gpp)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp));
    if (ctx->modem_cdma)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_cdma));

    if (info_flag)
        g_assert_not_reached ();

    /* Request to monitor modems? */
    if (monitor_state_flag) {
        MMModemState current;

        g_signal_connect (ctx->modem,
                          "state-changed",
                          G_CALLBACK (state_changed),
                          NULL);

        current = mm_modem_get_state (ctx->modem);
        g_print ("\t%s: Initial state, '%s'\n",
                 mm_object_get_path (ctx->object),
                 mm_modem_state_get_string (current));

        /* If we get cancelled, operation done */
        g_cancellable_connect (ctx->cancellable,
                               G_CALLBACK (cancelled),
                               NULL,
                               NULL);
        return;
    }

    /* Request to enable the modem? */
    if (enable_flag) {
        g_debug ("Asynchronously enabling modem...");
        mm_modem_enable (ctx->modem,
                         ctx->cancellable,
                         (GAsyncReadyCallback)enable_ready,
                         NULL);
        return;
    }

    /* Request to disable the modem? */
    if (disable_flag) {
        g_debug ("Asynchronously disabling modem...");
        mm_modem_disable (ctx->modem,
                          ctx->cancellable,
                          (GAsyncReadyCallback)disable_ready,
                          NULL);
        return;
    }

    /* Request to full power the modem? */
    if (set_power_state_on_flag) {
        g_debug ("Asynchronously setting full power...");
        mm_modem_set_power_state (ctx->modem,
                                  MM_MODEM_POWER_STATE_ON,
                                  ctx->cancellable,
                                  (GAsyncReadyCallback)set_power_state_ready,
                                  NULL);
        return;
    }

    /* Request to low power the modem? */
    if (set_power_state_low_flag) {
        g_debug ("Asynchronously setting low power...");
        mm_modem_set_power_state (ctx->modem,
                                  MM_MODEM_POWER_STATE_LOW,
                                  ctx->cancellable,
                                  (GAsyncReadyCallback)set_power_state_ready,
                                  NULL);
        return;
    }

    /* Request to power off the modem? */
    if (set_power_state_off_flag) {
        g_debug ("Asynchronously powering off...");
        mm_modem_set_power_state (ctx->modem,
                                  MM_MODEM_POWER_STATE_OFF,
                                  ctx->cancellable,
                                  (GAsyncReadyCallback)set_power_state_ready,
                                  NULL);
        return;
    }

    /* Request to reset the modem? */
    if (reset_flag) {
        g_debug ("Asynchronously reseting modem...");
        mm_modem_reset (ctx->modem,
                        ctx->cancellable,
                        (GAsyncReadyCallback)reset_ready,
                        NULL);
        return;
    }

    /* Request to reset the modem to factory state? */
    if (factory_reset_str) {
        g_debug ("Asynchronously factory-reseting modem...");
        mm_modem_factory_reset (ctx->modem,
                                factory_reset_str,
                                ctx->cancellable,
                                (GAsyncReadyCallback)factory_reset_ready,
                                NULL);
        return;
    }

    /* Request to send a command to the modem? */
    if (command_str) {
        guint timeout;

        timeout = command_get_timeout (ctx->modem);

        g_debug ("Asynchronously sending a command to the modem (%u seconds timeout)...",
                 timeout);

        mm_modem_command (ctx->modem,
                          command_str,
                          timeout,
                          ctx->cancellable,
                          (GAsyncReadyCallback)command_ready,
                          NULL);
        return;
    }

    /* Request to list bearers? */
    if (list_bearers_flag) {
        g_debug ("Asynchronously listing bearers in modem...");
        mm_modem_list_bearers (ctx->modem,
                               ctx->cancellable,
                               (GAsyncReadyCallback)list_bearers_ready,
                               NULL);
        return;
    }

    /* Request to create a new bearer? */
    if (create_bearer_str) {
        GError *error = NULL;
        MMBearerProperties *properties;

        properties = mm_bearer_properties_new_from_string (create_bearer_str, &error);
        if (!properties) {
            g_printerr ("Error parsing properties string: '%s'\n", error->message);
            exit (EXIT_FAILURE);
        }

        g_debug ("Asynchronously creating new bearer in modem...");
        mm_modem_create_bearer (ctx->modem,
                                properties,
                                ctx->cancellable,
                                (GAsyncReadyCallback)create_bearer_ready,
                                NULL);
        g_object_unref (properties);
        return;
    }

    /* Request to delete a given bearer? */
    if (delete_bearer_str) {
        mmcli_get_bearer (ctx->connection,
                          delete_bearer_str,
                          ctx->cancellable,
                          (GAsyncReadyCallback)get_bearer_to_delete_ready,
                          NULL);
        return;
    }

    /* Request to set current capabilities in a given modem? */
    if (set_current_capabilities_str) {
        MMModemCapability current_capabilities;

        parse_current_capabilities (&current_capabilities);
        mm_modem_set_current_capabilities (ctx->modem,
                                           current_capabilities,
                                           ctx->cancellable,
                                           (GAsyncReadyCallback)set_current_capabilities_ready,
                                           NULL);
        return;
    }

    /* Request to set allowed modes in a given modem? */
    if (set_allowed_modes_str) {
        MMModemMode allowed;
        MMModemMode preferred;

        parse_modes (&allowed, &preferred);
        mm_modem_set_current_modes (ctx->modem,
                                    allowed,
                                    preferred,
                                    ctx->cancellable,
                                    (GAsyncReadyCallback)set_current_modes_ready,
                                    NULL);
        return;
    }

    /* Request to set current bands in a given modem? */
    if (set_current_bands_str) {
        MMModemBand *current_bands;
        guint n_current_bands;

        parse_current_bands (&current_bands, &n_current_bands);
        mm_modem_set_current_bands (ctx->modem,
                                    current_bands,
                                    n_current_bands,
                                    ctx->cancellable,
                                    (GAsyncReadyCallback)set_current_bands_ready,
                                    NULL);
        g_free (current_bands);
        return;
    }

    g_warn_if_reached ();
}