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); }
void mmcli_modem_location_run_synchronous (GDBusConnection *connection) { GError *error = NULL; /* Initialize context */ ctx = g_new0 (Context, 1); ctx->object = mmcli_get_modem_sync (connection, mmcli_get_common_modem_string (), &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 (); /* Request to get location status? */ if (status_flag) { g_debug ("Printing location status..."); print_location_status (); return; } /* 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) { gboolean result; g_debug ("Synchronously setting up location gathering..."); result = mm_modem_location_setup_sync (ctx->modem_location, build_sources_from_flags (), build_signals_location_from_flags (), NULL, &error); setup_process_reply (result, error); return; } /* Request to get location from the modem? */ if (get_3gpp_flag || get_gps_nmea_flag || get_gps_raw_flag || get_cdma_bs_flag) { MMLocation3gpp *location_3gpp = NULL; MMLocationGpsNmea *location_gps_nmea = NULL; MMLocationGpsRaw *location_gps_raw = NULL; MMLocationCdmaBs *location_cdma_bs = NULL; g_debug ("Synchronously getting location from the modem..."); mm_modem_location_get_full_sync (ctx->modem_location, get_3gpp_flag ? &location_3gpp : NULL, get_gps_nmea_flag ? &location_gps_nmea : NULL, get_gps_raw_flag ? &location_gps_raw : NULL, get_cdma_bs_flag ? &location_cdma_bs : NULL, NULL, &error); get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error); return; } /* Request to set SUPL server? */ if (set_supl_server_str) { gboolean result; g_debug ("Synchronously setting SUPL server..."); result = mm_modem_location_set_supl_server_sync (ctx->modem_location, set_supl_server_str, NULL, &error); set_supl_server_process_reply (result, error); return; } /* Request to set GPS refresh rate? */ if (set_gps_refresh_rate_str) { gboolean result; 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 ("Synchronously setting GPS refresh rate..."); result = mm_modem_location_set_gps_refresh_rate_sync (ctx->modem_location, rate, NULL, &error); set_gps_refresh_rate_process_reply (result, error); 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_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 (); }