示例#1
0
/**
 * D-Bus callback for the ALS disabling method call
 *
 * @param msg The D-Bus message
 * @return TRUE
 */
static gboolean als_disable_req_dbus_cb(DBusMessage *const msg)
{
	const char *sender;

	gssize retval;

	if( !(sender = dbus_message_get_sender(msg)) )
		goto EXIT;

	mce_log(LL_DEBUG, "Received ALS disable request from %s", sender);

	retval = mce_dbus_owner_monitor_remove(sender,
					       &ext_als_enablers);

	if (retval == -1) {
		mce_log(LL_INFO, "Failed to remove name owner monitoring"
			" for `%s'",sender);
		goto EXIT;
	}

	rethink_als_status();

EXIT:
	if( !dbus_message_get_no_reply(msg) ) {
		DBusMessage *reply = dbus_new_method_reply(msg);
		dbus_send_message(reply), reply = 0;
	}

	return TRUE;
}
示例#2
0
/** D-Bus callback for the MCE_CPU_KEEPALIVE_WAKEUP_REQ method call
 *
 * @param msg  The D-Bus message
 *
 * @return TRUE on success, FALSE on failure
 */
static
gboolean
cka_dbus_handle_wakeup_cb(DBusMessage *const msg)
{
  gboolean success = FALSE;

  const char *sender =  0;

  if( !(sender = dbus_message_get_sender(msg)) )
  {
    goto EXIT;
  }

  mce_log(LL_NOTICE, "got keepalive wakeup from %s",
          mce_dbus_get_name_owner_ident(sender));

  cka_clients_handle_wakeup(sender);

  success = TRUE;

EXIT:
  cka_dbusutil_reply_bool(msg, success);

  return success;
}
示例#3
0
static DBusMessage *remove_proxy(DBusConnection *conn,
				DBusMessage *msg, void *data)
{
	struct serial_adapter *adapter = data;
	struct serial_proxy *prx;
	const char *path, *sender;
	GSList *l;

	if (!dbus_message_get_args(msg, NULL,
				DBUS_TYPE_STRING, &path,
				DBUS_TYPE_INVALID))
		return NULL;

	l = g_slist_find_custom(adapter->proxies, path, proxy_pathcmp);
	if (!l)
		return does_not_exist(msg, "Invalid proxy path");

	prx = l->data;

	sender = dbus_message_get_sender(msg);
	if (g_strcmp0(prx->owner, sender) != 0)
		return failed(msg, "Permission denied");

	unregister_proxy(prx);

	return dbus_message_new_method_return(msg);
}
示例#4
0
文件: manager.c 项目: Fiend90/obex
static DBusMessage *unregister_agent(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	const char *path, *sender;

	if (!agent)
		return agent_does_not_exist(msg);

	if (!dbus_message_get_args(msg, NULL,
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID))
		return invalid_args(msg);

	if (strcmp(agent->path, path) != 0)
		return agent_does_not_exist(msg);

	sender = dbus_message_get_sender(msg);
	if (strcmp(agent->bus_name, sender) != 0)
		return not_authorized(msg);

	g_dbus_remove_watch(conn, agent->watch_id);

	agent_free(agent);
	agent = NULL;

	DBG("Agent unregistered");

	return dbus_message_new_method_return(msg);
}
static DBusMessage *unregister_advertisement(DBusConnection *conn,
						DBusMessage *msg,
						void *user_data)
{
	struct btd_advertising *manager = user_data;
	DBusMessageIter args;
	struct advertisement *ad;
	struct dbus_obj_match match;

	DBG("UnregisterAdvertisement");

	if (!dbus_message_iter_init(msg, &args))
		return btd_error_invalid_args(msg);

	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
		return btd_error_invalid_args(msg);

	dbus_message_iter_get_basic(&args, &match.path);

	match.owner = dbus_message_get_sender(msg);

	ad = queue_find(manager->ads, match_advertisement, &match);
	if (!ad)
		return btd_error_does_not_exist(msg);

	advertisement_remove(ad);

	return dbus_message_new_method_return(msg);
}
示例#6
0
文件: server.c 项目: heinervdm/bluez
static DBusMessage *register_server(DBusConnection *conn,
                                    DBusMessage *msg, void *data)
{
    struct network_server *ns = data;
    DBusMessage *reply;
    const char *uuid, *bridge;

    if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &uuid,
                               DBUS_TYPE_STRING, &bridge, DBUS_TYPE_INVALID))
        return NULL;

    if (g_strcmp0(uuid, "nap"))
        return btd_error_failed(msg, "Invalid UUID");

    if (ns->record_id)
        return btd_error_already_exists(msg);

    reply = dbus_message_new_method_return(msg);
    if (!reply)
        return NULL;

    ns->record_id = register_server_record(ns);
    if (!ns->record_id)
        return btd_error_failed(msg, "SDP record registration failed");

    g_free(ns->bridge);
    ns->bridge = g_strdup(bridge);

    ns->watch_id = g_dbus_add_disconnect_watch(conn,
                   dbus_message_get_sender(msg),
                   server_disconnect, ns, NULL);

    return reply;
}
示例#7
0
int __connman_session_destroy(DBusMessage *msg)
{
	const char *owner, *session_path;
	struct connman_session *session;

	owner = dbus_message_get_sender(msg);

	DBG("owner %s", owner);

	dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &session_path,
							DBUS_TYPE_INVALID);
	if (session_path == NULL)
		return -EINVAL;

	session = g_hash_table_lookup(session_hash, session_path);
	if (session == NULL)
		return -EINVAL;

	if (g_strcmp0(owner, session->owner) != 0)
		return -EACCES;

	connman_session_destroy(session);

	return 0;
}
static DBusMessage *
service_introspect (GkdSecretService *self,
                    DBusMessage *message)
{
	GPtrArray *names;
	DBusMessage *reply;
	ServiceClient *client;
	const gchar *caller;
	const gchar *path;
	GHashTableIter iter;

	names = g_ptr_array_new_with_free_func (g_free);
	gkd_secret_objects_foreach_collection (self->objects, message,
	                                       on_each_path_append_to_array,
	                                       names);

	/* Lookup all sessions and prompts for this client */
	caller = dbus_message_get_sender (message);
	if (caller != NULL) {
		client = g_hash_table_lookup (self->clients, caller);
		if (client != NULL) {
			g_hash_table_iter_init (&iter, client->dispatch);
			while (g_hash_table_iter_next (&iter, (gpointer *)&path, NULL))
				g_ptr_array_add (names, g_strdup (path));
		}
	}

	g_ptr_array_add (names, NULL);

	reply = gkd_dbus_introspect_handle (message, gkd_secret_introspect_service,
	                                    (const gchar **)names->pdata);

	g_ptr_array_unref (names);
	return reply;
}
示例#9
0
static DBusMessage *remove_session(DBusConnection *connection,
				DBusMessage *message, void *user_data)
{
	struct obc_session *session;
	const char *sender, *path;

	if (dbus_message_get_args(message, NULL,
			DBUS_TYPE_OBJECT_PATH, &path,
			DBUS_TYPE_INVALID) == FALSE)
		return g_dbus_create_error(message,
				ERROR_INTERFACE ".InvalidArguments", NULL);

	session = find_session(path);
	if (session == NULL)
		return g_dbus_create_error(message,
				ERROR_INTERFACE ".InvalidArguments", NULL);

	sender = dbus_message_get_sender(message);
	if (g_str_equal(sender, obc_session_get_owner(session)) == FALSE)
		return g_dbus_create_error(message,
				ERROR_INTERFACE ".NotAuthorized",
				"Not Authorized");

	release_session(session);

	return dbus_message_new_method_return(message);
}
示例#10
0
static DBusMessage*
service_method_change_lock (GkdSecretService *self, DBusMessage *message)
{
	GkdSecretChange *change;
	DBusMessage *reply;
	const char *caller;
	const gchar *path;
	GckObject *collection;

	caller = dbus_message_get_sender (message);
	if (!dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
		return NULL;

	/* Make sure it exists */
	collection = gkd_secret_objects_lookup_collection (self->objects, caller, path);
	if (!collection)
		return dbus_message_new_error (message, SECRET_ERROR_NO_SUCH_OBJECT,
		                               "The collection does not exist");
	g_object_unref (collection);

	change = gkd_secret_change_new (self, caller, path);
	path = gkd_secret_dispatch_get_object_path (GKD_SECRET_DISPATCH (change));
	gkd_secret_service_publish_dispatch (self, caller,
	                                     GKD_SECRET_DISPATCH (change));

	reply = dbus_message_new_method_return (message);
	dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);

	g_object_unref (change);
	return reply;
}
示例#11
0
static DBusMessage*
service_method_read_alias (GkdSecretService *self, DBusMessage *message)
{
	DBusMessage *reply;
	const char *alias;
	gchar *path = NULL;
	const gchar *identifier;
	GckObject  *collection = NULL;

	if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &alias, DBUS_TYPE_INVALID))
		return NULL;

	identifier = gkd_secret_service_get_alias (self, alias);
	if (identifier)
		path = gkd_secret_util_build_path (SECRET_COLLECTION_PREFIX, identifier, -1);

	/* Make sure it actually exists */
	if (path)
		collection = gkd_secret_objects_lookup_collection (self->objects,
		                                                   dbus_message_get_sender (message), path);
	if (collection == NULL) {
		g_free (path);
		path = NULL;
	} else {
		g_object_unref (collection);
	}

	reply = dbus_message_new_method_return (message);
	if (path == NULL)
		path = g_strdup ("/");
	dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
	g_free (path);

	return reply;
}
示例#12
0
文件: service.c 项目: intgr/bluez
static DBusMessage *cancel_authorization(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	DBusMessage *reply;
	struct service_adapter *serv_adapter = data;
	struct pending_auth *auth;
	const gchar *sender;

	sender = dbus_message_get_sender(msg);

	auth = find_pending_by_sender(serv_adapter, sender);
	if (auth == NULL)
		return btd_error_does_not_exist(msg);

	btd_cancel_authorization(auth->id);

	reply = btd_error_not_authorized(auth->msg);
	dbus_message_unref(auth->msg);
	g_dbus_send_message(btd_get_dbus_connection(), reply);

	serv_adapter->pending_list = g_slist_remove(serv_adapter->pending_list,
									auth);
	g_free(auth);

	auth = next_pending(serv_adapter);
	if (auth == NULL)
		goto done;

	auth->id = btd_request_authorization(get_address(serv_adapter),
							&auth->dst, auth->uuid,
							auth_cb, serv_adapter);

done:
	return dbus_message_new_method_return(msg);
}
示例#13
0
文件: service.c 项目: intgr/bluez
static DBusMessage *add_service_record(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	struct service_adapter *serv_adapter = data;
	DBusMessage *reply;
	const char *sender, *record;
	dbus_uint32_t handle;
	int err;

	if (dbus_message_get_args(msg, NULL,
			DBUS_TYPE_STRING, &record, DBUS_TYPE_INVALID) == FALSE)
		return btd_error_invalid_args(msg);

	sender = dbus_message_get_sender(msg);
	err = add_xml_record(sender, serv_adapter, record, &handle);
	if (err < 0)
		return btd_error_failed(msg, strerror(-err));

	reply = dbus_message_new_method_return(msg);
	if (!reply)
		return NULL;

	dbus_message_append_args(reply, DBUS_TYPE_UINT32, &handle,
							DBUS_TYPE_INVALID);

	return reply;
}
示例#14
0
文件: service.c 项目: intgr/bluez
static DBusMessage *update_xml_record(DBusMessage *msg,
					struct service_adapter *serv_adapter)
{
	struct record_data *user_record;
	sdp_record_t *sdp_record;
	const char *record;
	dbus_uint32_t handle;
	int len;

	if (dbus_message_get_args(msg, NULL,
				DBUS_TYPE_UINT32, &handle,
				DBUS_TYPE_STRING, &record,
				DBUS_TYPE_INVALID) == FALSE)
		return btd_error_invalid_args(msg);

	len = (record ? strlen(record) : 0);
	if (len == 0)
		return btd_error_invalid_args(msg);

	user_record = find_record(serv_adapter, handle,
				dbus_message_get_sender(msg));
	if (!user_record)
		return btd_error_not_available(msg);

	sdp_record = sdp_xml_parse_record(record, len);
	if (!sdp_record) {
		error("Parsing of XML service record failed");
		return btd_error_failed(msg,
					"Parsing of XML service record failed");
	}

	return update_record(msg, serv_adapter, handle, sdp_record);
}
static DBusMessage *register_watcher(DBusConnection *conn, DBusMessage *msg,
								void *data)
{
	struct heartrate_adapter *hradapter = data;
	struct watcher *watcher;
	const char *sender = dbus_message_get_sender(msg);
	char *path;

	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
							DBUS_TYPE_INVALID))
		return btd_error_invalid_args(msg);

	watcher = find_watcher(hradapter->watchers, sender, path);
	if (watcher != NULL)
		return btd_error_already_exists(msg);

	watcher = g_new0(struct watcher, 1);
	watcher->hradapter = hradapter;
	watcher->id = g_dbus_add_disconnect_watch(conn, sender, watcher_exit_cb,
						watcher, destroy_watcher);
	watcher->srv = g_strdup(sender);
	watcher->path = g_strdup(path);

	if (g_slist_length(hradapter->watchers) == 0)
		g_slist_foreach(hradapter->devices, enable_measurement, 0);

	hradapter->watchers = g_slist_prepend(hradapter->watchers, watcher);

	DBG("heartrate watcher [%s] registered", path);

	return dbus_message_new_method_return(msg);
}
示例#16
0
文件: session.c 项目: Commers/obexd
static DBusMessage *release_agent(DBusConnection *connection,
				DBusMessage *message, void *user_data)
{
	struct session_data *session = user_data;
	struct agent_data *agent = session->agent;
	const gchar *sender;
	gchar *path;

	if (dbus_message_get_args(message, NULL,
					DBUS_TYPE_OBJECT_PATH, &path,
					DBUS_TYPE_INVALID) == FALSE)
		return g_dbus_create_error(message,
				"org.openobex.Error.InvalidArguments",
				"Invalid arguments in method call");

	sender = dbus_message_get_sender(message);

	if (agent == NULL || g_str_equal(sender, agent->name) == FALSE ||
				g_str_equal(path, agent->path) == FALSE)
		return g_dbus_create_error(message,
				"org.openobex.Error.NotAuthorized",
				"Not Authorized");

	agent_free(session);

	return dbus_message_new_method_return(message);
}
static DBusMessage *unregister_watcher(DBusConnection *conn, DBusMessage *msg,
								void *data)
{
	struct heartrate_adapter *hradapter = data;
	struct watcher *watcher;
	const char *sender = dbus_message_get_sender(msg);
	char *path;

	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
							DBUS_TYPE_INVALID))
		return btd_error_invalid_args(msg);

	watcher = find_watcher(hradapter->watchers, sender, path);
	if (watcher == NULL)
		return btd_error_does_not_exist(msg);

	hradapter->watchers = g_slist_remove(hradapter->watchers, watcher);
	g_dbus_remove_watch(conn, watcher->id);

	if (g_slist_length(hradapter->watchers) == 0)
		g_slist_foreach(hradapter->devices, disable_measurement, 0);

	DBG("heartrate watcher [%s] unregistered", path);

	return dbus_message_new_method_return(msg);
}
static DBusMessage*
service_method_open_session (GkdSecretService *self, DBusMessage *message)
{
	GkdSecretSession *session;
	ServiceClient *client;
	DBusMessage *reply = NULL;
	const gchar *caller;
	const gchar *path;

	if (!dbus_message_has_signature (message, "sv"))
		return NULL;

	caller = dbus_message_get_sender (message);

	/* Now we can create a session with this information */
	session = gkd_secret_session_new (self, caller);
	reply = gkd_secret_session_handle_open (session, message);

	if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN) {
		/* Take ownership of the session */
		client = g_hash_table_lookup (self->clients, caller);
		g_return_val_if_fail (client, NULL);
		path = gkd_secret_dispatch_get_object_path (GKD_SECRET_DISPATCH (session));
		g_return_val_if_fail (!g_hash_table_lookup (client->sessions, path), NULL);
		g_hash_table_replace (client->sessions, (gpointer)path, session);

	} else {
		g_object_unref (session);
	}

	return reply;
}
示例#19
0
static DBusHandlerResult
default_message_filter
(   DBusConnection     *connection,
    DBusMessage        *message,
    void               *p
)
{
    DBusConnectionState *cs = p;
    uint32_t type  =dbus_message_get_type( message ),
             serial  =dbus_message_get_serial( message );
    uint8_t  reply =dbus_message_get_no_reply( message )==0;
    const char
    *path =    dbus_message_get_path( message ),
     *dest =    dbus_message_get_destination( message ),
      *member =  dbus_message_get_member( message ),
       *interface=dbus_message_get_interface( message ),
        *sender   =dbus_message_get_sender( message ),
         *signature=dbus_message_get_signature( message );
    connection = connection;
    if(cs->mf)
        return
            (*(cs->mf))( cs, type, reply, serial, dest, path, member, interface, 0L,
                         sender, signature, message, 0L, 0L, 0L, cs->def_mf_obj
                       ) ;
    return HANDLED;
}
static DBusMessage*
service_method_change_lock (GkdSecretService *self, DBusMessage *message)
{
	GkdSecretChange *change;
	ServiceClient *client;
	DBusMessage *reply;
	const char *caller;
	const gchar *path;
	GP11Object *collection;

	caller = dbus_message_get_sender (message);
	if (!dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
		return NULL;

	/* Make sure it exists */
	collection = gkd_secret_objects_lookup_collection (self->objects, caller, path);
	if (!collection)
		return dbus_message_new_error (message, SECRET_ERROR_NO_SUCH_OBJECT,
		                               "The collection does not exist");
	g_object_unref (collection);

	change = gkd_secret_change_new (self, caller, path);
	client = g_hash_table_lookup (self->clients, caller);
	g_return_val_if_fail (client, NULL);
	path = gkd_secret_dispatch_get_object_path (GKD_SECRET_DISPATCH (change));
	g_hash_table_replace (client->prompts, (gpointer)path, g_object_ref (change));

	reply = dbus_message_new_method_return (message);
	dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);

	g_object_unref (change);
	return reply;
}
示例#21
0
文件: manager.c 项目: Fiend90/obex
static DBusMessage *register_agent(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	const char *path, *sender;

	if (agent)
		return agent_already_exists(msg);

	if (!dbus_message_get_args(msg, NULL,
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID))
		return invalid_args(msg);

	sender = dbus_message_get_sender(msg);
	agent = g_new0(struct agent, 1);
	agent->bus_name = g_strdup(sender);
	agent->path = g_strdup(path);

	agent->watch_id = g_dbus_add_disconnect_watch(conn, sender,
					agent_disconnected, NULL, NULL);

	DBG("Agent registered");

	return dbus_message_new_method_return(msg);
}
示例#22
0
文件: agent.c 项目: ghent360/bluez
static DBusMessage *register_agent(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	struct agent *agent;
	const char *sender, *path, *capability;
	uint8_t cap;

	sender = dbus_message_get_sender(msg);

	agent = g_hash_table_lookup(agent_list, sender);
	if (agent)
		return btd_error_already_exists(msg);

	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
						DBUS_TYPE_STRING, &capability,
						DBUS_TYPE_INVALID) == FALSE)
		return btd_error_invalid_args(msg);

	cap = parse_io_capability(capability);
	if (cap == IO_CAPABILITY_INVALID)
		return btd_error_invalid_args(msg);

	agent = agent_create(sender, path, cap);
	if (!agent)
		return btd_error_invalid_args(msg);

	DBG("agent %s", agent->owner);

	g_hash_table_replace(agent_list, agent->owner, agent);

	return dbus_message_new_method_return(msg);
}
示例#23
0
文件: inactivity.c 项目: g7/mce
/**
 * D-Bus callback for the remove activity callback method call
 *
 * @param msg The D-Bus message
 * @return TRUE on success, FALSE on failure
 */
static gboolean remove_activity_callback_dbus_cb(DBusMessage *const msg)
{
	dbus_bool_t no_reply = dbus_message_get_no_reply(msg);
	const gchar *sender = dbus_message_get_sender(msg);
	gboolean status = FALSE;

	if (sender == NULL) {
		mce_log(LL_ERR,
			"Received invalid remove activity callback request "
			"(sender == NULL)");
		goto EXIT;
	}

	mce_log(LL_DEVEL, "Received remove activity callback request from %s",
		mce_dbus_get_name_owner_ident(sender));

	status = TRUE;

	remove_activity_cb(sender);

EXIT:
	if (no_reply == FALSE) {
		DBusMessage *reply = dbus_new_method_reply(msg);

		status = dbus_send_message(reply);
	} else {
		status = TRUE;
	}

	return status;
}
示例#24
0
文件: agent.c 项目: ghent360/bluez
static DBusMessage *unregister_agent(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	struct agent *agent;
	const char *sender, *path;

	sender = dbus_message_get_sender(msg);

	agent = g_hash_table_lookup(agent_list, sender);
	if (!agent)
		return btd_error_does_not_exist(msg);

	DBG("agent %s", agent->owner);

	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
						DBUS_TYPE_INVALID) == FALSE)
		return btd_error_invalid_args(msg);

	if (g_str_equal(path, agent->path) == FALSE)
		return btd_error_does_not_exist(msg);

	agent_disconnect(conn, agent);

	return dbus_message_new_method_return(msg);
}
示例#25
0
文件: stk.c 项目: yongsu/oFono
static DBusMessage *stk_register_agent(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	struct ofono_stk *stk = data;
	const char *agent_path;

	if (stk->default_agent)
		return __ofono_error_busy(msg);

	if (dbus_message_get_args(msg, NULL,
					DBUS_TYPE_OBJECT_PATH, &agent_path,
					DBUS_TYPE_INVALID) == FALSE)
		return __ofono_error_invalid_args(msg);

	if (!__ofono_dbus_valid_object_path(agent_path))
		return __ofono_error_invalid_format(msg);

	stk->default_agent = stk_agent_new(agent_path,
						dbus_message_get_sender(msg),
						FALSE);
	if (!stk->default_agent)
		return __ofono_error_failed(msg);

	stk_agent_set_removed_notify(stk->default_agent,
					default_agent_notify, stk);

	if (!stk->session_agent)
		stk->current_agent = stk->default_agent;

	return dbus_message_new_method_return(msg);
}
示例#26
0
static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg,
					void *data)
{
	struct media_adapter *adapter = data;
	struct media_player *mp;
	DBusMessageIter args;
	const char *sender, *path;
	int err;

	sender = dbus_message_get_sender(msg);

	dbus_message_iter_init(msg, &args);

	dbus_message_iter_get_basic(&args, &path);
	dbus_message_iter_next(&args);

	if (media_adapter_find_player(adapter, sender, path) != NULL)
		return btd_error_already_exists(msg);

	mp = media_player_create(adapter, sender, path, &err);
	if (mp == NULL) {
		if (err == -EPROTONOSUPPORT)
			return btd_error_not_supported(msg);
		else
			return btd_error_invalid_args(msg);
	}

	if (parse_player_properties(mp, &args) == FALSE) {
		media_player_destroy(mp);
		return btd_error_invalid_args(msg);
	}

	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
示例#27
0
文件: peer.c 项目: jasonabele/connman
static const char *get_dbus_sender(struct connman_peer *peer)
{
	if (!peer->pending)
		return NULL;

	return dbus_message_get_sender(peer->pending);
}
示例#28
0
static DBusMessage *
impl_Embedded (DBusConnection *bus,
                    DBusMessage *message,
                    void *user_data)
{
  AtkObject *object = (AtkObject *) user_data;
  char *path;
  gchar *id;

  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID))
    {
      return droute_invalid_arguments_error (message);
    }
  id = g_strconcat (dbus_message_get_sender (message), ":", path, NULL);
  g_object_set_data_full (G_OBJECT (object), "dbus-plug-parent", id, (GDestroyNotify)g_free);

  if (ATK_IS_COMPONENT (object))
    {
      AtkComponent *component = ATK_COMPONENT (object);
      AtkComponentIface *iface = ATK_COMPONENT_GET_IFACE (component);
      iface->get_extents = atspi_plug_component_get_extents;
      iface->get_size = atspi_plug_component_get_size;
      iface->get_position = atspi_plug_component_get_position;
    }

  /* Retrieve some info about the children, if they exist, when
     embedding the plug to ensure the a11y subtree is generated.
     https://bugzilla.gnome.org/show_bug.cgi?id=663876 */
  atk_object_get_n_accessible_children (object);

  return dbus_message_new_method_return (message);
}
示例#29
0
/** D-Bus message filter for handling NameOwnerChanged signals
 *
 * @param con       dbus connection
 * @param msg       message to be acted upon
 * @param user_data (not used)
 *
 * @return DBUS_HANDLER_RESULT_NOT_YET_HANDLED (other filters see the msg too)
 */
static
DBusHandlerResult
cpu_keepalive_dbus_filter_cb(DBusConnection *con, DBusMessage *msg,
			     void *user_data)
{
  (void)user_data;

  DBusHandlerResult res = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

  const char *sender = 0;
  const char *object = 0;

  const char *name = 0;
  const char *prev = 0;
  const char *curr = 0;

  DBusError err = DBUS_ERROR_INIT;

  if( con != systembus )
  {
    goto EXIT;
  }

  if( !dbus_message_is_signal(msg, DBUS_INTERFACE_DBUS, "NameOwnerChanged") )
  {
    goto EXIT;
  }

  sender = dbus_message_get_sender(msg);
  if( strcmp(sender, DBUS_SERVICE_DBUS) )
  {
    goto EXIT;
  }

  object = dbus_message_get_path(msg);
  if( strcmp(object, DBUS_PATH_DBUS) )
  {
    goto EXIT;
  }

  if( !dbus_message_get_args(msg, &err,
			     DBUS_TYPE_STRING, &name,
			     DBUS_TYPE_STRING, &prev,
			     DBUS_TYPE_STRING, &curr,
			     DBUS_TYPE_INVALID) )
  {
    mce_log(LL_WARN, "%s: %s", err.name, err.message);
    goto EXIT;
  }

  if( !*curr )
  {
    mce_log(LL_INFO, "name lost owner: %s", name);
    cpu_keepalive_remove_client(name);
  }

EXIT:
  dbus_error_free(&err);
  return res;
}
示例#30
0
static DBusHandlerResult message_filter(DBusConnection *connection,
					DBusMessage *message, void *user_data)
{
	GDBusClient *client = user_data;
	const char *sender, *path, *interface;

	if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	sender = dbus_message_get_sender(message);
	if (sender == NULL)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	path = dbus_message_get_path(message);
	interface = dbus_message_get_interface(message);

	if (g_str_has_prefix(path, client->base_path) == FALSE)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	if (g_str_equal(interface, DBUS_INTERFACE_PROPERTIES) == TRUE)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	if (client->signal_func)
		client->signal_func(connection, message, client->signal_data);

	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}