static void
set_time_async (SetTimeCallbackData *data)
{
        DBusGConnection *bus;
        DBusGProxy      *proxy;
	GError          *err = NULL;

        bus = get_system_bus (&err);
        if (bus == NULL) {
		if (err) {
			if (data->callback)
				data->callback (data->data, err);
			g_clear_error (&err);
		}
		return;
	}

	proxy = dbus_g_proxy_new_for_name (bus,
					   "org.gnome.SettingsDaemon.DateTimeMechanism",
					   "/",
					   "org.gnome.SettingsDaemon.DateTimeMechanism");

	data->ref_count++;
	if (strcmp (data->call, "SetTime") == 0)
		dbus_g_proxy_begin_call_with_timeout (proxy,
						      "SetTime",
						      set_time_notify,
						      data, free_data,
						      INT_MAX,
						      /* parameters: */
						      G_TYPE_INT64, data->time,
						      G_TYPE_INVALID,
						      /* return values: */
						      G_TYPE_INVALID);
	else if (strcmp (data->call, "SetTimezone") == 0)
		dbus_g_proxy_begin_call_with_timeout (proxy,
						      "SetTimezone",
						      set_time_notify,
						      data, free_data,
						      INT_MAX,
						      /* parameters: */
						      G_TYPE_STRING, data->tz,
						      G_TYPE_INVALID,
						      /* return values: */
						      G_TYPE_INVALID);
	else if (strcmp (data->call, "SetUsingNtp") == 0)
		dbus_g_proxy_begin_call_with_timeout (proxy,
						      "SetUsingNtp",
						      set_time_notify,
						      data, free_data,
						      INT_MAX,
						      /* parameters: */
						      G_TYPE_BOOLEAN, data->using_ntp,
						      G_TYPE_INVALID,
						      /* return values: */
						      G_TYPE_INVALID);
}
Example #2
0
static void method_call(DBusGProxy *proxy, const char *method, const char *path)
{
	if (proxy == NULL)
		return;

	g_print("%s ( %s, %s )\n", method, dbus_g_proxy_get_path(proxy), path);

	if (path == NULL) {
		if (dbus_g_proxy_begin_call_with_timeout(proxy,
					method, method_callback, NULL, NULL,
					120 * 1000, G_TYPE_INVALID) == FALSE) {
			g_print("Can't call method %s\n", method);
			g_object_unref(proxy);
			return;
		}
	} else {
		if (dbus_g_proxy_begin_call(proxy, method, method_callback,
				NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, path,
						G_TYPE_INVALID) == FALSE) {
			g_print("Can't call method %s (%s)\n", method, path);
			g_object_unref(proxy);
			return;
		}
	}
}
Example #3
0
gpointer
nm_firewall_manager_add_or_change_zone (NMFirewallManager *self,
                                        const char *iface,
                                        const char *zone,
                                        gboolean add, /* TRUE == add, FALSE == change */
                                        FwAddToZoneFunc callback,
                                        gpointer user_data)
{
	NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self);
	CBInfo *info;

	if (priv->running == FALSE) {
		nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change skipped (not running)", iface);
		callback (NULL, user_data);
		return NULL;
	}

	info = g_malloc0 (sizeof (*info));
	info->iface = g_strdup (iface);
	info->callback = callback;
	info->user_data = user_data;

	nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s", iface, add ? "add" : "change", zone);
	return dbus_g_proxy_begin_call_with_timeout (priv->proxy,
	                                             add ? "addInterface" : "changeZone",
	                                             add_or_change_cb,
	                                             info,
	                                             (GDestroyNotify) cb_info_free,
	                                             10000,      /* timeout */
	                                             G_TYPE_STRING, zone ? zone : "",
	                                             G_TYPE_STRING, iface,
	                                             G_TYPE_INVALID);
}
Example #4
0
gpointer
nm_firewall_manager_remove_from_zone (NMFirewallManager *self,
                                      const char *iface,
                                      const char *zone)
{
	NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self);
	CBInfo *info;

	if (priv->running == FALSE) {
		nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove skipped (not running)", iface);
		return NULL;
	}

	info = g_malloc0 (sizeof (*info));
	info->iface = g_strdup (iface);

	nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove -> %s", iface, zone );
	return dbus_g_proxy_begin_call_with_timeout (priv->proxy,
	                                             "removeInterface",
	                                             remove_cb,
	                                             info,
	                                             (GDestroyNotify) cb_info_free,
	                                             10000,      /* timeout */
	                                             G_TYPE_STRING, zone ? zone : "",
	                                             G_TYPE_STRING, iface,
	                                             G_TYPE_INVALID);
}
static gpointer
agent_new_save_delete (NMSecretAgent *self,
                       NMConnection *connection,
                       NMConnectionSerializationFlags flags,
                       const char *method,
                       NMSecretAgentCallback callback,
                       gpointer callback_data)
{
	NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
	GVariant *dict;
	GHashTable *hash;
	Request *r;
	const char *cpath = nm_connection_get_path (connection);

	dict = nm_connection_to_dbus (connection, flags);
	hash = nm_utils_connection_dict_to_hash (dict);
	g_variant_unref (dict);

	r = request_new (self, cpath, NULL, callback, callback_data);
	r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
	                                                method,
	                                                agent_save_delete_cb,
	                                                r,
	                                                NULL,
	                                                10000, /* 10 seconds */
	                                                DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
	                                                DBUS_TYPE_G_OBJECT_PATH, cpath,
	                                                G_TYPE_INVALID);
	g_hash_table_insert (priv->requests, r->call, r);

	g_hash_table_destroy (hash);
	return r->call;
}
Example #6
0
gboolean
cm_service_connect (CmService *service)
{
  CmServicePrivate *priv = service->priv;
  GError *error = NULL;
  DBusGProxyCall *call;

  if (priv->connected)
    return TRUE;

  /* 
   * We use an unusually long timeout since this dbus method
   * will not return until there is an error or till connman
   * has an IP address for the connection.
   */
  call = dbus_g_proxy_begin_call_with_timeout (priv->proxy, 
					       "Connect",
					       service_connect_call_notify, 
					       service, 
					       NULL,
					       120000,
					       G_TYPE_INVALID);
  if (!call)
  {
    g_debug ("Connect failed: %s\n", error ? error->message : "Unknown");
    g_error_free (error);
    return FALSE;
  }

  return TRUE;
}
NMFirewallPendingCall
nm_firewall_manager_remove_from_zone (NMFirewallManager *self,
                                      const char *iface,
                                      const char *zone)
{
	NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self);
	CBInfo *info;

	if (priv->running == FALSE) {
		nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove skipped (not running)", iface);
		return PENDING_CALL_DUMMY;
	}

	info = _cb_info_create (self, iface, NULL, NULL);

	nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove -> %s%s%s [%u]", iface,
	                           zone?"\"":"", zone ? zone : "*", zone?"\"":"", info->id);
	info->dbus_call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
	                                                        "removeInterface",
	                                                        remove_cb,
	                                                        info,
	                                                        (GDestroyNotify) _cb_info_free,
	                                                        10000,      /* timeout */
	                                                        G_TYPE_STRING, zone ? zone : "",
	                                                        G_TYPE_STRING, iface,
	                                                        G_TYPE_INVALID);
	return PENDING_CALL_FROM_INFO (info);
}
static TpProxyPendingCall * hev_cli_authentication_tls_certificate_call_reject(TpProxy *proxy,
			gint timeout_ms, const GPtrArray *in_rejections,
			hev_cli_authentication_tls_certificate_callback_for_reject callback,
			gpointer user_data, GDestroyNotify destroy, GObject *weak_object)
{
	GError *error = NULL;
	GQuark interface = TP_IFACE_QUARK_AUTHENTICATION_TLS_CERTIFICATE;
	DBusGProxy *iface = NULL;
    TpProxyPendingCall *data = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	iface = tp_proxy_borrow_interface_by_id(proxy, interface,
				&error);
	if(NULL == iface)
	{
		if(NULL != callback)
		  callback(proxy, error, user_data, weak_object);

		if(NULL != destroy)
		  destroy(user_data);

		g_error_free(error);
		return NULL;
	}

	if(NULL == callback)
	{
		dbus_g_proxy_call_no_reply(iface, "Reject",
			(dbus_g_type_get_collection("GPtrArray",
				(dbus_g_type_get_struct("GValueArray",
					G_TYPE_UINT, G_TYPE_STRING,
					(dbus_g_type_get_map("GHashTable",
						G_TYPE_STRING, G_TYPE_VALUE)),
					G_TYPE_INVALID)))),
			in_rejections, G_TYPE_INVALID);
		return NULL;
	}

	data = tp_proxy_pending_call_v0_new(proxy, interface,
				"Reject", iface,
				hev_cli_authentication_tls_certificate_invoke_callback_reject,
				G_CALLBACK(callback), user_data, destroy, weak_object, FALSE);
	tp_proxy_pending_call_v0_take_pending_call(data, dbus_g_proxy_begin_call_with_timeout(iface,
					"Reject", hev_cli_authentication_tls_certificate_collect_callback_reject,
					data, tp_proxy_pending_call_v0_completed, timeout_ms,
					(dbus_g_type_get_collection("GPtrArray",
						(dbus_g_type_get_struct("GValueArray", G_TYPE_UINT, G_TYPE_STRING,
							(dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)),
							G_TYPE_INVALID)))), in_rejections, G_TYPE_INVALID));

	return data;
}
static NMActStageReturn
real_act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
{
	NMActRequest *req;
	NMConnection *connection;
	const char *setting_name;
	GPtrArray *hints = NULL;
	const char *hint1 = NULL, *hint2 = NULL;
	guint32 tries;

	req = nm_device_get_act_request (device);
	g_assert (req);
	connection = nm_act_request_get_connection (req);
	g_assert (connection);

	setting_name = nm_connection_need_secrets (connection, &hints);
	if (!setting_name) {
		GHashTable *properties;

		properties = create_connect_properties (connection);
		dbus_g_proxy_begin_call_with_timeout (nm_modem_get_proxy (NM_MODEM (device), MM_DBUS_INTERFACE_MODEM_SIMPLE),
											  "Connect", stage1_prepare_done,
											  device, NULL, 120000,
											  DBUS_TYPE_G_MAP_OF_VARIANT, properties,
											  G_TYPE_INVALID);

		return NM_ACT_STAGE_RETURN_POSTPONE;
	}

	if (hints) {
		if (hints->len > 0)
			hint1 = g_ptr_array_index (hints, 0);
		if (hints->len > 1)
			hint2 = g_ptr_array_index (hints, 1);
	}

	nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);

	tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), GSM_SECRETS_TRIES));
	nm_act_request_get_secrets (req,
	                            setting_name,
	                            tries ? TRUE : FALSE,
	                            SECRETS_CALLER_GSM,
	                            hint1,
	                            hint2);
	g_object_set_data (G_OBJECT (connection), GSM_SECRETS_TRIES, GUINT_TO_POINTER (++tries));

	if (hints)
		g_ptr_array_free (hints, TRUE);

	return NM_ACT_STAGE_RETURN_POSTPONE;
}
Example #10
0
static void
do_connect (NMModemGsm *self)
{
	NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self);
	DBusGProxy *proxy;

	proxy = nm_modem_generic_get_proxy (NM_MODEM_GENERIC (self), MM_OLD_DBUS_INTERFACE_MODEM_SIMPLE);
	priv->call = dbus_g_proxy_begin_call_with_timeout (proxy,
	                                                   "Connect", stage1_prepare_done,
	                                                   self, NULL, 120000,
	                                                   DBUS_TYPE_G_MAP_OF_VARIANT, priv->connect_properties,
	                                                   G_TYPE_INVALID);
}
static void
set_time_async (SetTimeCallbackData *data)
{
        DBusGConnection *bus;
        DBusGProxy      *proxy;

        bus = get_system_bus ();
        if (bus == NULL)
                return;

	proxy = dbus_g_proxy_new_for_name (bus,
					   "org.mate.SettingsDaemon.DateTimeMechanism",
					   "/",
					   "org.mate.SettingsDaemon.DateTimeMechanism");

	data->ref_count++;
	if (strcmp (data->call, "SetTime") == 0)
		dbus_g_proxy_begin_call_with_timeout (proxy, 
						      "SetTime",
						      set_time_notify,
						      data, free_data,
						      INT_MAX,
						      /* parameters: */
						      G_TYPE_INT64, data->time,
						      G_TYPE_INVALID,
						      /* return values: */
						      G_TYPE_INVALID);
	else 
		dbus_g_proxy_begin_call_with_timeout (proxy, 
						      "SetTimezone",
						      set_time_notify,
						      data, free_data,
						      INT_MAX,
						      /* parameters: */
						      G_TYPE_STRING, data->filename,
						      G_TYPE_INVALID,
						      /* return values: */
						      G_TYPE_INVALID);
}
Example #12
0
static void
do_enable (NMModemGsm *self)
{
	DBusGProxy *proxy;

	g_return_if_fail (self != NULL);
	g_return_if_fail (NM_IS_MODEM_GSM (self));

	proxy = nm_modem_get_proxy (NM_MODEM (self), MM_DBUS_INTERFACE_MODEM);
	dbus_g_proxy_begin_call_with_timeout (proxy,
	                                      "Enable", stage1_enable_done,
	                                      self, NULL, 20000,
	                                      G_TYPE_BOOLEAN, TRUE,
	                                      G_TYPE_INVALID);
}
gconstpointer
nm_secret_agent_get_secrets (NMSecretAgent *self,
                             NMConnection *connection,
                             const char *setting_name,
                             const char **hints,
                             NMSecretAgentGetSecretsFlags flags,
                             NMSecretAgentCallback callback,
                             gpointer callback_data)
{
	NMSecretAgentPrivate *priv;
	GVariant *dict;
	GHashTable *hash;
	Request *r;

	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (connection != NULL, NULL);
	g_return_val_if_fail (setting_name != NULL, NULL);

	priv = NM_SECRET_AGENT_GET_PRIVATE (self);
	g_return_val_if_fail (priv->proxy != NULL, NULL);

	dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
	hash = nm_utils_connection_dict_to_hash (dict);
	g_variant_unref (dict);

	/* Mask off the private flags if present */
	flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM;
	flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS;

	r = request_new (self, nm_connection_get_path (connection), setting_name, callback, callback_data);
	r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
	                                                "GetSecrets",
	                                                get_callback,
	                                                r,
	                                                NULL,
	                                                120000, /* 120 seconds */
	                                                DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
	                                                DBUS_TYPE_G_OBJECT_PATH, nm_connection_get_path (connection),
	                                                G_TYPE_STRING, setting_name,
	                                                G_TYPE_STRV, hints,
	                                                G_TYPE_UINT, flags,
	                                                G_TYPE_INVALID);
	g_hash_table_insert (priv->requests, r->call, r);

	g_hash_table_destroy (hash);
	return r->call;
}
int main()
{
	DBusGConnection *connection;
	GError *error;
	DBusGProxy *proxy;
	DBusGProxyCall* call;
	
	gint res;
	gint res1 = 0;
	
	g_type_init ();
	
	error = NULL;
	connection = dbus_g_bus_get (DBUS_BUS_SESSION,
	                           &error);
	if (connection == NULL)
	{
		std_log(LOG_FILENAME_LINE, "Failed to open connection to bus: %s\n",
	              error->message);
	  g_error_free (error);
	  create_xml(1);
	  exit (1);
	}
	
	proxy = dbus_g_proxy_new_for_name (connection,
	        "com.example.DBusGlibObject1",
	        "/com/example/DBusGlibObject1",
	        "com.example.DBusGlibObject1");
	
	call = dbus_g_proxy_begin_call_with_timeout(proxy, "Simple_method", simple_method_reply_handler, &res1, NULL, 10000, G_TYPE_INT, 5, G_TYPE_INVALID, G_TYPE_INT, &res, G_TYPE_INVALID);
	
	mainLoop = g_main_loop_new(NULL,FALSE);
	g_main_loop_run(mainLoop);
		
	std_log(LOG_FILENAME_LINE, "res = %d, res1 = %d", res, res1);
	if(res1 != 9090)
		{
		std_log(LOG_FILENAME_LINE, "return value is not matching.");
		create_xml(1);
		return 1;
		}
	
	dbus_g_connection_unref(connection);
	std_log(LOG_FILENAME_LINE, "Test Successful");
	create_xml(0);
	return 0;
}
Example #15
0
/* do_enable() is used as a GSourceFunc, hence the gboolean return */
static gboolean
do_enable (NMModemGsm *self)
{
	DBusGProxy *proxy;

	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (NM_IS_MODEM_GSM (self), FALSE);

	NM_MODEM_GSM_GET_PRIVATE (self)->enable_delay_id = 0;
	proxy = nm_modem_generic_get_proxy (NM_MODEM_GENERIC (self), MM_OLD_DBUS_INTERFACE_MODEM);
	dbus_g_proxy_begin_call_with_timeout (proxy,
	                                      "Enable", stage1_enable_done,
	                                      self, NULL, 20000,
	                                      G_TYPE_BOOLEAN, TRUE,
	                                      G_TYPE_INVALID);
	return FALSE;
}
DBusGProxyCall*
_SSO_AuthSession_process_async_timeout (DBusGProxy *proxy, 
					const GHashTable* IN_sessionDataVa, 
					const char * IN_mechanism, 
					SSO_AuthSession_process_reply callback, 
					gpointer userdata, 
					int timeout)

{
  DBusGAsyncData *stuff;
  stuff = g_slice_new (DBusGAsyncData);
  stuff->cb = G_CALLBACK (callback);
  stuff->userdata = userdata;
  return dbus_g_proxy_begin_call_with_timeout (proxy, "process", 
          SSO_AuthSession_process_async_callback, stuff, 
          _dbus_glib_async_data_free, timeout, 
          dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), 
          IN_sessionDataVa, G_TYPE_STRING, IN_mechanism, G_TYPE_INVALID);
}
Example #17
0
gconstpointer
nm_secret_agent_get_secrets (NMSecretAgent *self,
                             NMConnection *connection,
                             const char *setting_name,
                             const char *hint,
                             NMSettingsGetSecretsFlags flags,
                             NMSecretAgentCallback callback,
                             gpointer callback_data)
{
    NMSecretAgentPrivate *priv;
    GHashTable *hash;
    const char *hints[2] = { hint, NULL };
    Request *r;

    g_return_val_if_fail (self != NULL, NULL);
    g_return_val_if_fail (connection != NULL, NULL);
    g_return_val_if_fail (setting_name != NULL, NULL);

    priv = NM_SECRET_AGENT_GET_PRIVATE (self);

    hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);

    /* Mask off the private ONLY_SYSTEM flag if present */
    flags &= ~NM_SETTINGS_GET_SECRETS_FLAG_ONLY_SYSTEM;

    r = request_new (self, nm_connection_get_path (connection), setting_name, callback, callback_data);
    r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
              "GetSecrets",
              get_callback,
              r,
              NULL,
              120000, /* 120 seconds */
              DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
              DBUS_TYPE_G_OBJECT_PATH, nm_connection_get_path (connection),
              G_TYPE_STRING, setting_name,
              G_TYPE_STRV, hints,
              G_TYPE_UINT, flags,
              G_TYPE_INVALID);
    g_hash_table_insert (priv->requests, r->call, r);

    g_hash_table_destroy (hash);
    return r->call;
}
NMFirewallPendingCall
nm_firewall_manager_add_or_change_zone (NMFirewallManager *self,
                                        const char *iface,
                                        const char *zone,
                                        gboolean add, /* TRUE == add, FALSE == change */
                                        FwAddToZoneFunc callback,
                                        gpointer user_data)
{
	NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self);
	CBInfo *info;

	if (priv->running == FALSE) {
		if (callback) {
			info = _cb_info_create (self, iface, callback, user_data);
			info->idle_id = g_idle_add (add_or_change_idle_cb, info);
			nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s%s%s [%u] (not running, simulate success)", iface, add ? "add" : "change",
			            zone?"\"":"", zone ? zone : "default", zone?"\"":"", info->id);
			return PENDING_CALL_FROM_INFO (info);
		} else {
			nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change skipped (not running)", iface);
			return PENDING_CALL_DUMMY;
		}
	}

	info = _cb_info_create (self, iface, callback, user_data);

	nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s%s%s [%u]", iface, add ? "add" : "change",
	                           zone?"\"":"", zone ? zone : "default", zone?"\"":"", info->id);
	info->dbus_call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
	                                                        add ? "addInterface" : "changeZone",
	                                                        add_or_change_cb,
	                                                        info,
	                                                        (GDestroyNotify) _cb_info_free,
	                                                        10000,      /* timeout */
	                                                        G_TYPE_STRING, zone ? zone : "",
	                                                        G_TYPE_STRING, iface,
	                                                        G_TYPE_INVALID);
	return PENDING_CALL_FROM_INFO (info);
}
static void
refresh_can_do (const gchar *action, CanDoFunc callback)
{
        DBusGConnection *bus;
        DBusGProxy      *proxy;

        bus = get_system_bus ();
        if (bus == NULL)
                return;

	proxy = dbus_g_proxy_new_for_name (bus,
					   "org.mate.SettingsDaemon.DateTimeMechanism",
					   "/",
					   "org.mate.SettingsDaemon.DateTimeMechanism");

	dbus_g_proxy_begin_call_with_timeout (proxy,
					      action,
					      notify_can_do,
					      callback, NULL,
					      INT_MAX,
					      G_TYPE_INVALID);
}
Example #20
0
static void
handle_enable_pin_required (NMModemGsm *self)
{
	NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self);
	const char *pin = NULL;
	GValue *value;
	DBusGProxy *proxy;

	/* See if we have a PIN already */
	value = g_hash_table_lookup (priv->connect_properties, "pin");
	if (value && G_VALUE_HOLDS_STRING (value))
		pin = g_value_get_string (value);

	/* If we do, send it */
	if (pin) {
		proxy = nm_modem_generic_get_proxy (NM_MODEM_GENERIC (self), MM_OLD_DBUS_INTERFACE_MODEM_GSM_CARD);
		dbus_g_proxy_begin_call_with_timeout (proxy,
		                                      "SendPin", stage1_pin_done,
		                                      self, NULL, 10000,
		                                      G_TYPE_STRING, pin,
		                                      G_TYPE_INVALID);
	} else
		ask_for_pin (self, FALSE);
}
static void
dun_start (NmaBtDevice *self)
{
	NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
	gboolean have_mm = FALSE, have_mm1 = TRUE;

	g_message ("%s: starting DUN device discovery...", __func__);

	_set_status (self, _("Detecting phone configuration..."));

	/* ModemManager stuff */
	priv->mm_proxy = dbus_g_proxy_new_for_name (priv->bus,
	                                            MM_SERVICE,
	                                            MM_PATH,
	                                            MM_INTERFACE);
	g_assert (priv->mm_proxy);
	have_mm = _name_has_owner (priv->bus, MM_SERVICE);

	dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
	                                   G_TYPE_NONE,
	                                   G_TYPE_BOXED,
	                                   G_TYPE_INVALID);
	dbus_g_proxy_add_signal (priv->mm_proxy, "DeviceAdded",
	                         DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->mm_proxy, "DeviceAdded",
								 G_CALLBACK (modem_added), self,
								 NULL);

	dbus_g_proxy_add_signal (priv->mm_proxy, "DeviceRemoved",
	                         DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->mm_proxy, "DeviceRemoved",
								 G_CALLBACK (modem_removed), self,
								 NULL);

#if WITH_MODEM_MANAGER_1
	/* ModemManager1 stuff */
	{
		priv->dbus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
		if (priv->dbus_connection) {
			priv->modem_manager_1 = mm_manager_new_sync (priv->dbus_connection,
			                                             G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
			                                             NULL,
			                                             NULL);
			if (priv->modem_manager_1) {
				g_signal_connect (priv->modem_manager_1,
				                  "object-added",
				                  G_CALLBACK (modem_object_added),
				                  self);
				g_signal_connect (priv->modem_manager_1,
				                  "object-removed",
				                  G_CALLBACK (modem_object_removed),
				                  self);
			}
		}

		have_mm1 = !!priv->modem_manager_1;
	}
#endif

	/* Ensure at least one of ModemManager or ModemManager1 are around */
	if (!have_mm && !have_mm1) {
		dun_error (self, __func__, NULL, _("ModemManager is not running"));
		return;
	}

	/* Bluez */
	priv->dun_proxy = dbus_g_proxy_new_for_name (priv->bus,
	                                             BLUEZ_SERVICE,
	                                             priv->object_path,
	                                             BLUEZ_SERIAL_INTERFACE);
	g_assert (priv->dun_proxy);

	priv->dun_timeout_id = g_timeout_add_seconds (45, dun_timeout_cb, self);

	g_message ("%s: calling Connect...", __func__);

	/* Watch for BT device property changes */
	dbus_g_object_register_marshaller (_nma_marshal_VOID__STRING_BOXED,
	                                   G_TYPE_NONE,
	                                   G_TYPE_STRING, G_TYPE_VALUE,
	                                   G_TYPE_INVALID);
	dbus_g_proxy_add_signal (priv->dun_proxy, "PropertyChanged",
	                         G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->dun_proxy, "PropertyChanged",
	                             G_CALLBACK (dun_property_changed), self, NULL);

	/* Request a connection to the device and get the port */
	dbus_g_proxy_begin_call_with_timeout (priv->dun_proxy, "Connect",
	                                      dun_connect_cb,
	                                      self,
	                                      NULL,
	                                      20000,
	                                      G_TYPE_STRING, "dun",
	                                      G_TYPE_INVALID);

	g_message ("%s: waiting for Connect success...", __func__);
}
Example #22
0
static NMActStageReturn
real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
{
	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
	NMActRequest *req;
	NMDBusManager *dbus_mgr;
	DBusGConnection *g_connection;
	gboolean dun = FALSE;

	req = nm_device_get_act_request (device);
	g_assert (req);

	priv->bt_type = get_connection_bt_type (nm_act_request_get_connection (req));
	if (priv->bt_type == NM_BT_CAPABILITY_NONE) {
		// FIXME: set a reason code
		return NM_ACT_STAGE_RETURN_FAILURE;
	}

	dbus_mgr = nm_dbus_manager_get ();
	g_connection = nm_dbus_manager_get_connection (dbus_mgr);
	g_object_unref (dbus_mgr);

	if (priv->bt_type == NM_BT_CAPABILITY_DUN)
		dun = TRUE;
	else if (priv->bt_type == NM_BT_CAPABILITY_NAP)
		dun = FALSE;
	else
		g_assert_not_reached ();

	priv->dev_proxy = dbus_g_proxy_new_for_name (g_connection,
	                                               BLUEZ_SERVICE,
	                                               nm_device_get_udi (device),
	                                               BLUEZ_DEVICE_INTERFACE);
	if (!priv->dev_proxy) {
		// FIXME: set a reason code
		return NM_ACT_STAGE_RETURN_FAILURE;
	}

	/* Watch for BT device property changes */
	dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_BOXED,
	                                   G_TYPE_NONE,
	                                   G_TYPE_STRING, G_TYPE_VALUE,
	                                   G_TYPE_INVALID);
	dbus_g_proxy_add_signal (priv->dev_proxy, "PropertyChanged",
	                         G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->dev_proxy, "PropertyChanged",
	                             G_CALLBACK (bluez_property_changed), device, NULL);

	priv->type_proxy = dbus_g_proxy_new_for_name (g_connection,
	                                              BLUEZ_SERVICE,
	                                              nm_device_get_udi (device),
	                                              dun ? BLUEZ_SERIAL_INTERFACE : BLUEZ_NETWORK_INTERFACE);
	if (!priv->type_proxy) {
		// FIXME: set a reason code
		return NM_ACT_STAGE_RETURN_FAILURE;
	}

	nm_log_dbg (LOGD_BT, "(%s): requesting connection to the device",
	            nm_device_get_iface (device));

	/* Connect to the BT device */
	dbus_g_proxy_begin_call_with_timeout (priv->type_proxy, "Connect",
	                                      bluez_connect_cb,
	                                      device,
	                                      NULL,
	                                      20000,
	                                      G_TYPE_STRING, dun ? BLUETOOTH_DUN_UUID : BLUETOOTH_NAP_UUID,
	                                      G_TYPE_INVALID);

	if (priv->timeout_id)
		g_source_remove (priv->timeout_id);
	priv->timeout_id = g_timeout_add_seconds (30, bt_connect_timeout, device);

	return NM_ACT_STAGE_RETURN_POSTPONE;
}
Example #23
0
static void
dun_start (PluginInfo *info)
{
	GError *error = NULL;
	GtkTreeIter iter;

	g_message ("%s: starting DUN device discovery...", __func__);

	/* Set up dbus */
	info->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
	if (error || !info->bus) {
		dun_error (info, __func__, error, _("could not connect to the system bus."));
		g_clear_error (&error);
		goto out;
	}

	gtk_label_set_text (GTK_LABEL (info->label), _("Detecting phone configuration..."));

	/* Start the spinner */
	if (!info->spinner) {
		info->spinner = nma_bling_spinner_new ();
		gtk_box_pack_start (GTK_BOX (info->hbox), info->spinner, FALSE, FALSE, 6);
	}
	nma_bling_spinner_start (BMA_BLING_SPINNER (info->spinner));
	gtk_widget_show_all (info->hbox);

	gtk_widget_set_sensitive (info->dun_button, FALSE);

	/* ModemManager stuff */
	info->mm_proxy = dbus_g_proxy_new_for_name (info->bus,
	                                            MM_SERVICE,
	                                            MM_PATH,
	                                            MM_INTERFACE);
	g_assert (info->mm_proxy);

	dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
	                                   G_TYPE_NONE,
	                                   G_TYPE_BOXED,
	                                   G_TYPE_INVALID);
	dbus_g_proxy_add_signal (info->mm_proxy, "DeviceAdded",
	                         DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (info->mm_proxy, "DeviceAdded",
								 G_CALLBACK (modem_added), info,
								 NULL);

	dbus_g_proxy_add_signal (info->mm_proxy, "DeviceRemoved",
	                         DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (info->mm_proxy, "DeviceRemoved",
								 G_CALLBACK (modem_removed), info,
								 NULL);

	/* Get the device we're looking for */
	info->dun_proxy = NULL;
	if (get_device_iter (info->btmodel, info->bdaddr, &iter))
		gtk_tree_model_get (info->btmodel, &iter, BLUETOOTH_COLUMN_PROXY, &info->dun_proxy, -1);

	if (info->dun_proxy) {
		info->dun_timeout_id = g_timeout_add_seconds (45, dun_timeout_cb, info);

		dbus_g_proxy_set_interface (info->dun_proxy, BLUEZ_SERIAL_INTERFACE);

		g_message ("%s: calling Connect...", __func__);

		/* Watch for BT device property changes */
		dbus_g_object_register_marshaller (nma_marshal_VOID__STRING_BOXED,
		                                   G_TYPE_NONE,
		                                   G_TYPE_STRING, G_TYPE_VALUE,
		                                   G_TYPE_INVALID);
		dbus_g_proxy_add_signal (info->dun_proxy, "PropertyChanged",
		                         G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
		dbus_g_proxy_connect_signal (info->dun_proxy, "PropertyChanged",
		                             G_CALLBACK (dun_property_changed), info, NULL);

		/* Request a connection to the device and get the port */
		dbus_g_proxy_begin_call_with_timeout (info->dun_proxy, "Connect",
		                                      dun_connect_cb,
		                                      info,
		                                      NULL,
		                                      20000,
		                                      G_TYPE_STRING, "dun",
		                                      G_TYPE_INVALID);
	} else
		dun_error (info, __func__, error, _("could not find the Bluetooth device."));

out:
	g_message ("%s: finished", __func__);
}