Ejemplo n.º 1
0
void g_dbus_client_unref(GDBusClient *client)
{
	unsigned int i;

	if (client == NULL)
		return;

	if (__sync_sub_and_fetch(&client->ref_count, 1) > 0)
		return;

	if (client->pending_call != NULL) {
		dbus_pending_call_cancel(client->pending_call);
		dbus_pending_call_unref(client->pending_call);
	}

	if (client->get_objects_call != NULL) {
		dbus_pending_call_cancel(client->get_objects_call);
		dbus_pending_call_unref(client->get_objects_call);
	}

	for (i = 0; i < client->match_rules->len; i++) {
		modify_match(client->dbus_conn, "RemoveMatch",
				g_ptr_array_index(client->match_rules, i));
	}

	g_ptr_array_free(client->match_rules, TRUE);

	dbus_connection_remove_filter(client->dbus_conn,
						message_filter, client);

	g_list_free_full(client->proxy_list, proxy_free);

	/*
	 * Don't call disconn_func twice if disconnection
	 * was previously reported.
	 */
	if (client->disconn_func && client->connected)
		client->disconn_func(client->dbus_conn, client->disconn_data);

	g_dbus_remove_watch(client->dbus_conn, client->watch);
	g_dbus_remove_watch(client->dbus_conn, client->added_watch);
	g_dbus_remove_watch(client->dbus_conn, client->removed_watch);

	dbus_connection_unref(client->dbus_conn);

	g_free(client->service_name);
	g_free(client->base_path);
	g_free(client->root_path);

	g_free(client);
}
Ejemplo n.º 2
0
static void wicd_interface_cb(DBusPendingCall *pending, void *user_data)
{
	struct connline_context *context = user_data;
	char **properties = NULL;
	struct wicd_dbus *wicd;
	DBusMessageIter arg;
	DBusMessage *reply;
	const char *iface;

	if (dbus_pending_call_get_completed(pending) == FALSE)
		return;

	wicd = context->backend_data;
	wicd->call = NULL;

	reply = dbus_pending_call_steal_reply(pending);
	if (reply == NULL)
		goto error;

	if (dbus_message_iter_init(reply, &arg) == FALSE)
		goto error;

	if (connline_dbus_get_basic(&arg, DBUS_TYPE_STRING, &iface) != 0)
		goto error;

	properties = insert_into_property_list(properties, "bearer",
				connline_bearer_to_string(wicd->bearer));

	properties = insert_into_property_list(properties, "interface", iface);

	properties = insert_into_property_list(properties,
						"address", wicd->ip);

	if (properties != NULL)
		__connline_call_property_callback(context, properties);

	dbus_message_unref(reply);
	dbus_pending_call_unref(pending);

	return;

error:
	if (reply != NULL)
		dbus_message_unref(reply);

	dbus_pending_call_unref(pending);

	wicd_backend_data_cleanup(context);
	__connline_call_error_callback(context, false);
}
static gboolean
operation_unref (gpointer data)
{
	GkrOperation *op = data;
	g_assert (op);

	if (!g_atomic_int_dec_and_test (&op->refs))
		return FALSE;

	if (op->pending) {
		dbus_pending_call_cancel (op->pending);
		dbus_pending_call_unref (op->pending);
		op->pending = NULL;
	}

	operation_clear_callbacks (op);

	if (op->conn) {
		dbus_connection_unref (op->conn);
		op->conn = NULL;
	}

	g_slice_free (GkrOperation, op);
	return TRUE;
}
Ejemplo n.º 4
0
/**
 * send data for dbus method call
 */
static int networkmanager_dbus_send(DBusMessage** msg, DBusConnection* dbus_connection)
{
	DBusPendingCall* pending;
	int success;

	// send dbus message
	// -1 is the default time out. Other time outs can be configured in milli seconds.
	success = dbus_connection_send_with_reply(dbus_connection, *msg, &pending, -1);
	if(!success)
	{
		printf("networkmanager_dbus_send dbus send error\n");
		return 0;
	}
	if(pending == NULL)
	{
		printf ("networkmanager_dbus_send dbus calling error\n");
		return 0;
	}

	dbus_connection_flush(dbus_connection);
	dbus_message_unref(*msg);
	dbus_pending_call_block(pending);
	*msg = dbus_pending_call_steal_reply(pending);
	dbus_pending_call_unref(pending);

	if(*msg == NULL)
		return 0;

	return 1;
}
Ejemplo n.º 5
0
static gboolean modify_match(DBusConnection *conn, const char *member,
							const char *rule)
{
	DBusMessage *msg;
	DBusPendingCall *call;

	msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
					DBUS_INTERFACE_DBUS, member);
	if (msg == NULL)
		return FALSE;

	dbus_message_append_args(msg, DBUS_TYPE_STRING, &rule,
						DBUS_TYPE_INVALID);

	if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) {
		dbus_message_unref(msg);
		return FALSE;
	}

	dbus_pending_call_set_notify(call, modify_match_reply, NULL, NULL);
	dbus_pending_call_unref(call);

	dbus_message_unref(msg);

	return TRUE;
}
Ejemplo n.º 6
0
static int get_calls(struct modem_data *modem)
{
	DBusMessage *msg;
	DBusPendingCall *call;

	msg = dbus_message_new_method_call(OFONO_SERVICE, modem->path,
				OFONO_CALLMANAGER_INTERFACE, "GetCalls");
	if (msg == NULL)
		return -ENOMEM;

	dbus_message_set_auto_start(msg, FALSE);

	g_print("getting calls (%s)\n", modem->path);

	if (dbus_connection_send_with_reply(modem->conn, msg,
						&call, -1) == FALSE) {
		dbus_message_unref(msg);
		return -EIO;
	}

	dbus_message_unref(msg);

	if (call == NULL)
		return -EINVAL;

	dbus_pending_call_set_notify(call, get_calls_reply, modem, NULL);

	dbus_pending_call_unref(call);

	return 0;
}
Ejemplo n.º 7
0
void
nsNetworkManagerListener::RegisterWithConnection(DBusConnection* connection) {
  DBusError error;
  dbus_error_init(&error);
  
  dbus_bus_add_match(connection,
                     "type='signal',"
                     "interface='" NM_DBUS_INTERFACE "',"
                     "sender='" NM_DBUS_SERVICE "',"
                     "path='" NM_DBUS_PATH "'", &error);
  mOK = !dbus_error_is_set(&error);
  dbus_error_free(&error);
  if (!mOK)
    return;
  
  DBusMessage* msg =
    dbus_message_new_method_call(NM_DBUS_SERVICE, NM_DBUS_PATH,
                                 NM_DBUS_INTERFACE, "state");
  if (!msg) {
    mOK = PR_FALSE;
    return;
  }
  
  DBusPendingCall* reply = mDBUS->SendWithReply(this, msg);
  if (!reply) {
    mOK = PR_FALSE;
    return;
  }

  dbus_pending_call_set_notify(reply, NetworkStatusNotify, this, NULL);
  dbus_pending_call_unref(reply);
}
Ejemplo n.º 8
0
/**
 * mafw_proxy_renderer_playback_cb:
 * @pending_call: A DBusPendingCall that is the reply for a playback call
 * @user_data:    AsyncParams*
 *
 * Receives the resulting DBus reply message for a playback call and calls
 * the assigned callback function to pass the actual result to the UI layer.
 */
static void mafw_proxy_renderer_playback_cb(DBusPendingCall *pending_call,
					 gpointer user_data)
{
	AsyncParams *ap;
	DBusMessage *reply;
	GError *error;

	ap = (AsyncParams*) user_data;
	g_assert(ap != NULL);

	reply = dbus_pending_call_steal_reply(pending_call);
	error = mafw_dbus_is_error(reply, MAFW_RENDERER_ERROR);

	if (error == NULL) {
		if (ap->callback)
			((MafwRendererPlaybackCB) ap->callback)
				(ap->renderer, ap->user_data, NULL);
	} else {
		if (ap->callback)
			((MafwRendererPlaybackCB) ap->callback)
				(ap->renderer, ap->user_data, error);
		g_error_free(error);
	}

	dbus_message_unref(reply);
	dbus_pending_call_unref(pending_call);
}
Ejemplo n.º 9
0
Archivo: dbus.c Proyecto: rzr/connman
static void get_connection_unix_user_reply(DBusPendingCall *call,
						void *user_data)
{
	struct callback_data *data = user_data;
	connman_dbus_get_connection_unix_user_cb_t cb = data->cb;
	DBusMessageIter iter;
	DBusMessage *reply;
	int err = 0;
	unsigned int uid;

	reply = dbus_pending_call_steal_reply(call);

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		DBG("Failed to retrieve UID");
		err = -EIO;
		goto done;
	}

	if (!dbus_message_has_signature(reply, "u")) {
		DBG("Message signature is wrong");
		err = -EINVAL;
		goto done;
	}

	dbus_message_iter_init(reply, &iter);
	dbus_message_iter_get_basic(&iter, &uid);

done:
	(*cb)(uid, data->user_data, err);

	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 10
0
static void property_get_reply(DBusPendingCall *call, void *user_data)
{
	struct property_get_data *data = user_data;
	DBusMessage *reply;
	DBusMessageIter iter;

	reply = dbus_pending_call_steal_reply(call);

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
		goto done;

	if (dbus_message_iter_init(reply, &iter) == FALSE)
		goto done;

	if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) {
		DBusMessageIter variant;

		dbus_message_iter_recurse(&iter, &variant);

		if (data->function != NULL)
			data->function(NULL, &variant, data->user_data);
	}
done:
	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 11
0
/** Initiate asynchronous connman properties query
 *
 * @return TRUE if the method call was initiated, or FALSE in case of errors
 */
static gboolean xconnman_get_properties(void)
{
	gboolean         res  = FALSE;
	DBusMessage     *req  = 0;
	DBusPendingCall *pc   = 0;

	if( !(req = dbus_message_new_method_call(CONNMAN_SERVICE,
						 CONNMAN_OBJECT_PATH,
						 CONNMAN_INTERFACE,
						 CONNMAN_GET_PROPERTIES_REQ)) )
		goto EXIT;

	if( !dbus_connection_send_with_reply(connman_bus, req, &pc, -1) )
		goto EXIT;

	if( !dbus_pending_call_set_notify(pc, xconnman_get_properties_cb, 0, 0) )
		goto EXIT;

	// success
	res = TRUE;

EXIT:
	if( pc )  dbus_pending_call_unref(pc);
	if( req ) dbus_message_unref(req);

	return res;
}
Ejemplo n.º 12
0
static void
_libnm_glib_nm_state_cb (DBusPendingCall *pcall, void *user_data)
{
	DBusMessage *		reply;
	libnm_glib_ctx *	ctx = (libnm_glib_ctx *) user_data;
	NMState			nm_state;

	g_return_if_fail (pcall != NULL);
	g_return_if_fail (ctx != NULL);

	if (!(reply = dbus_pending_call_steal_reply (pcall)))
		goto out;

	if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
	{
		DBusError err;

		dbus_error_init (&err);
		dbus_set_error_from_message (&err, reply);
		fprintf (stderr, "%s: dbus returned an error.\n  (%s) %s\n", __func__, err.name, err.message);
		dbus_error_free (&err);
		dbus_message_unref (reply);
		goto out;
	}

	if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID))
		_libnm_glib_update_state (ctx, nm_state);

	dbus_message_unref (reply);

out:
	dbus_pending_call_unref (pcall);
}
Ejemplo n.º 13
0
static void property_get_all_reply(DBusPendingCall *call, void *user_data)
{
	struct property_get_data *data = user_data;
	DBusMessage *reply;
	DBusMessageIter iter;

	reply = dbus_pending_call_steal_reply(call);

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
		goto done;

	if (dbus_message_iter_init(reply, &iter) == FALSE)
		goto done;

	supplicant_dbus_property_foreach(&iter, data->function,
							data->user_data);

	if (data->function != NULL)
		data->function(NULL, NULL, data->user_data);

done:
	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 14
0
Archivo: scan.c Proyecto: jolin90/dbus
static DBusMessage *excute_method_a(DBusConnection *conn, DBusMessage* msg)
{
    DBusPendingCall* pending;

    if (NULL == msg) {
        printf("Message NULL\n");
        return NULL;
    }

    if (!dbus_connection_send_with_reply(conn, msg, &pending, -1))
    {
        printf("Out Of Memory!");
        return NULL;
    }

    if (NULL == pending) {
        printf("Pending Call Null");
        return NULL;
    }

    dbus_connection_flush(conn);
    dbus_message_unref(msg);

    dbus_pending_call_block(pending);
    msg = dbus_pending_call_steal_reply(pending);
    if (NULL == msg) {
        printf("Reply Null\n");
    }
    dbus_pending_call_unref(pending);

    return msg;
}
Ejemplo n.º 15
0
static void disconnect_reply(DBusPendingCall *call, void *user_data)
{
	DBusMessage *reply;
	DBusError error;

	if (dbus_pending_call_get_completed(call) == FALSE)
		return;

	DBG("user %p", user_data);

	reply = dbus_pending_call_steal_reply(call);

	dbus_error_init(&error);

	if (dbus_set_error_from_message(&error, reply) == TRUE) {
		connman_error("%s", error.message);
		dbus_error_free(&error);
		goto done;
	}

done:
	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 16
0
static void remove_connection_reply(DBusPendingCall *call, void *user_data)
{
	DBusMessage *reply;
	DBusError error;

	if (dbus_pending_call_get_completed(call) == FALSE)
		return;

	DBG("");

	reply = dbus_pending_call_steal_reply(call);

	dbus_error_init(&error);

	if (dbus_set_error_from_message(&error, reply) == TRUE) {
		/*
		 * If the returned error is NotFound, it means that we
		 * have actually removed the provider in vpnd already.
		 */
		if (dbus_error_has_name(&error, CONNMAN_ERROR_INTERFACE
						".NotFound") == FALSE)
			connman_error("%s", error.message);

		dbus_error_free(&error);
	}

	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 17
0
void FcitxNotificationItemRegister(FcitxNotificationItem* notificationitem)
{
    if (!notificationitem->serviceName) {
        FcitxLog(ERROR, "This should not happen, please report bug.");
        return;
    }

    DBusMessage *message =
        dbus_message_new_method_call(NOTIFICATION_WATCHER_DBUS_ADDR,
                                     NOTIFICATION_WATCHER_DBUS_OBJ,
                                     NOTIFICATION_WATCHER_DBUS_IFACE,
                                     "RegisterStatusNotifierItem");
    dbus_message_append_args(message,
                             DBUS_TYPE_STRING, &notificationitem->serviceName,
                             DBUS_TYPE_INVALID);

    DBusPendingCall *call = NULL;
    dbus_bool_t reply =
        dbus_connection_send_with_reply(notificationitem->conn, message,
                                        &call, DBUS_TIMEOUT_USE_DEFAULT);
    dbus_message_unref(message);
    if (reply == TRUE) {
        dbus_pending_call_set_notify(call,
                                     FcitxNotificationItemRegisterSuccess,
                                     notificationitem,
                                     NULL);
        dbus_pending_call_unref(call);
    }
}
Ejemplo n.º 18
0
/** Initiate asynchronous connman service name ownership query
 *
 * @return TRUE if the method call was initiated, or FALSE in case of errors
 */
static gboolean xconnman_check_service(void)
{
	gboolean         res  = FALSE;
	DBusMessage     *req  = 0;
	DBusPendingCall *pc   = 0;
	const char      *name = CONNMAN_SERVICE;

	if( !(req = dbus_message_new_method_call(DBUS_SERVICE_DBUS,
					   DBUS_PATH_DBUS,
					   DBUS_INTERFACE_DBUS,
					   "GetNameOwner")) )
		goto EXIT;

	if( !dbus_message_append_args(req,
				      DBUS_TYPE_STRING, &name,
				      DBUS_TYPE_INVALID) )
		goto EXIT;

	if( !dbus_connection_send_with_reply(connman_bus, req, &pc, -1) )
		goto EXIT;

	if( !dbus_pending_call_set_notify(pc, xconnman_check_service_cb, 0, 0) )
		goto EXIT;

	// success
	res = TRUE;

EXIT:
	if( pc )  dbus_pending_call_unref(pc);
	if( req ) dbus_message_unref(req);

	return res;
}
Ejemplo n.º 19
0
static void register_external_service(gpointer a, gpointer b)
{
	DBusConnection *conn = b;
	const char *path = a;
	DBusMessage *msg;
	DBusPendingCall *call;
	DBusMessageIter iter, dict;

	msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
					GATT_MGR_IFACE, "RegisterService");
	if (!msg) {
		printf("Couldn't allocate D-Bus message\n");
		return;
	}

	dbus_message_iter_init_append(msg, &iter);

	dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);

	/* TODO: Add options dictionary */

	dbus_message_iter_close_container(&iter, &dict);

	if (!g_dbus_send_message_with_reply(conn, msg, &call, -1)) {
		dbus_message_unref(msg);
		return;
	}

	dbus_pending_call_set_notify(call, register_external_service_reply,
								NULL, NULL);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 20
0
static void finalize_call(DBusPendingCall *call)
{
	if (!dbus_pending_call_get_completed(call))
		dbus_pending_call_cancel(call);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 21
0
static void set_get_position_cb(DBusPendingCall *pending_call,
				gpointer user_data)
{
	AsyncParams *ap;
	DBusMessage *reply;
	GError *error;

	ap = (AsyncParams*) user_data;
	g_assert(ap != NULL);

	reply = dbus_pending_call_steal_reply(pending_call);
	error = mafw_dbus_is_error(reply, MAFW_RENDERER_ERROR);
	if (error == NULL) {

		guint seconds = 0;
		mafw_dbus_parse(reply, DBUS_TYPE_UINT32, &seconds);
		if (ap->callback != NULL)
			((MafwRendererPositionCB) ap->callback)(ap->renderer,
							    seconds,
							    ap->user_data,
							    NULL);
	} else {

		if (ap->callback != NULL)
			((MafwRendererPositionCB) ap->callback)(ap->renderer,
							    0,
							    ap->user_data,
							    error);
		g_error_free(error);
	}

	dbus_message_unref(reply);
	dbus_pending_call_unref(pending_call);
}
Ejemplo n.º 22
0
static void get_managed_objects_reply(DBusPendingCall *call, void *user_data)
{
	GDBusClient *client = user_data;
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	DBusError error;

	g_dbus_client_ref(client);

	dbus_error_init(&error);

	if (dbus_set_error_from_message(&error, reply) == TRUE) {
		dbus_error_free(&error);
		goto done;
	}

	parse_managed_objects(client, reply);

done:
	if (client->ready)
		client->ready(client, client->ready_data);

	dbus_message_unref(reply);

	dbus_pending_call_unref(client->get_objects_call);
	client->get_objects_call = NULL;

	g_dbus_client_unref(client);
}
Ejemplo n.º 23
0
Archivo: dbus.c Proyecto: rzr/connman
static void selinux_get_context_reply(DBusPendingCall *call, void *user_data)
{
	struct callback_data *data = user_data;
	connman_dbus_get_context_cb_t cb = data->cb;
	DBusMessage *reply;
	unsigned char *context = NULL;
	int err = 0;

	reply = dbus_pending_call_steal_reply(call);

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		DBG("Failed to retrieve SELinux context");
		err = -EIO;
		goto done;
	}

	if (!dbus_message_has_signature(reply, "ay")) {
		DBG("Message signature is wrong");
		err = -EINVAL;
		goto done;
	}

	context = parse_context(reply);

done:
	(*cb)(context, data->user_data, err);

	g_free(context);

	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Ejemplo n.º 24
0
static void agent_receive_message(DBusPendingCall *call, void *user_data)
{
	struct connman_agent *queue_data = user_data;
	DBusMessage *reply;
	int err;

	DBG("waiting for %p received %p", agent_request, queue_data);

	if (agent_request != queue_data) {
		connman_error("Agent callback expected %p got %p",
				agent_request, queue_data);
		return;
	}

	reply = dbus_pending_call_steal_reply(call);
	dbus_pending_call_unref(call);
	queue_data->call = NULL;

	if (dbus_message_is_error(reply,
			"org.freedesktop.DBus.Error.Timeout") == TRUE ||
			dbus_message_is_error(reply,
			"org.freedesktop.DBus.Error.TimedOut") == TRUE) {
		agent_send_cancel(queue_data->user_context);
	}

	queue_data->callback(reply, queue_data->user_data);
	dbus_message_unref(reply);

	agent_data_free(queue_data);
	agent_request = NULL;

	err = agent_send_next_request();
	if (err < 0)
		DBG("send next request failed (%s/%d)", strerror(-err), -err);
}
Ejemplo n.º 25
0
static int get_modems(DBusConnection *conn)
{
	DBusMessage *msg;
	DBusPendingCall *call;

	msg = dbus_message_new_method_call(OFONO_SERVICE, "/",
					OFONO_MANAGER_INTERFACE, "GetModems");
	if (msg == NULL)
		return -ENOMEM;

	dbus_message_set_auto_start(msg, FALSE);

	g_print("getting modems\n");

	if (dbus_connection_send_with_reply(conn, msg, &call, -1) == FALSE) {
		dbus_message_unref(msg);
		return -EIO;
	}

	dbus_message_unref(msg);

	if (call == NULL)
		return -EINVAL;

	dbus_pending_call_set_notify(call, get_modems_reply, conn, NULL);

	dbus_pending_call_unref(call);

	return 0;
}
Ejemplo n.º 26
0
void _dbus_reply_notify_handler(DBusPendingCall *pending, void *user_data)
{
	bridge_request_t *self = (bridge_request_t*)user_data;

	bridge_request_call_dbus_json(self, dbus_pending_call_steal_reply(pending));
	dbus_pending_call_unref(pending);
}
Ejemplo n.º 27
0
static int add_record(const char *path, const char *xml,
			struct bluetooth_service *service)
{
	DBusMessage *msg;
	DBusPendingCall *call;
	int ret = 0;

	msg = dbus_message_new_method_call("org.bluez", path,
					"org.bluez.Service", "AddRecord");

	dbus_message_append_args(msg, DBUS_TYPE_STRING, &xml,
			DBUS_TYPE_INVALID);

	if (dbus_connection_send_with_reply(connection,
				msg, &call, -1) == FALSE) {
		ret = -1;
		goto failed;
	}

	dbus_pending_call_set_notify(call, add_record_reply, service, NULL);
	dbus_pending_call_unref(call);

failed:
	dbus_message_unref(msg);
	return ret;
}
Ejemplo n.º 28
0
static void recv_dbus_reply(DBusPendingCall *pending, void *user_data)
{
    DBusMessage *msg;
    char        *reply;

    MRP_UNUSED(user_data);

    if ((msg = dbus_pending_call_steal_reply(pending)) != NULL) {
        if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING,
                                  &reply, DBUS_TYPE_INVALID)) {
            info("DBUS test: got reply #%d '%s'", dbus_test.nack, reply);
            dbus_test.nack++;
        }

        dbus_message_unref(msg);
    }

    dbus_pending_call_unref(pending);

    if (dbus_test.nack >= cfg.ndbus_method) {
        char dummy[256];

        cfg.nrunning--;

        /* block until the client is done */
        if (read(dbus_test.pipe[0], dummy, sizeof(dummy)) < 0) {
            /* just ignore it... */
        }
    }
}
Ejemplo n.º 29
0
static void
systemd_daemon_reload_complete(DBusPendingCall *pending, void *user_data)
{
    DBusError error;
    DBusMessage *reply = NULL;
    unsigned int reload_count = GPOINTER_TO_UINT(user_data);

    dbus_error_init(&error);
    if(pending) {
        reply = dbus_pending_call_steal_reply(pending);
    }

    if(pcmk_dbus_find_error("Reload", pending, reply, &error)) {
        crm_err("Could not issue systemd reload %d: %s", reload_count, error.message);

    } else {
        crm_trace("Reload %d complete", reload_count);
    }

    if(pending) {
        dbus_pending_call_unref(pending);
    }
    if(reply) {
        dbus_message_unref(reply);
    }
}
Ejemplo n.º 30
0
static void get_all_properties(GDBusProxy *proxy)
{
	GDBusClient *client = proxy->client;
	const char *service_name = client->service_name;
	DBusMessage *msg;
	DBusPendingCall *call;

	msg = dbus_message_new_method_call(service_name, proxy->obj_path,
					DBUS_INTERFACE_PROPERTIES, "GetAll");
	if (msg == NULL)
		return;

	dbus_message_append_args(msg, DBUS_TYPE_STRING, &proxy->interface,
							DBUS_TYPE_INVALID);

	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
							&call, -1) == FALSE) {
		dbus_message_unref(msg);
		return;
	}

	g_dbus_client_ref(client);

	dbus_pending_call_set_notify(call, get_all_properties_reply,
							proxy, NULL);
	dbus_pending_call_unref(call);

	dbus_message_unref(msg);
}