Exemplo n.º 1
0
void cpc_tasks_create_pm(cpc_task_t *task, cpc_pm_manager_t *pm_manager)
{
	CPC_ERR_MANAGE;
	gchar *path;
	GDBusConnection *connection =
		g_dbus_method_invocation_get_connection(task->invocation);
	const gchar *client_name =
		g_dbus_method_invocation_get_sender(task->invocation);

	CPC_FAIL(cpc_pm_manager_new_message(pm_manager,
						 client_name,
						 connection,
						 task->wp_message,
						 task->wp_message_len,
						 &path));

	CPC_LOGF("New Push Message object created %s", path);
	syslog(LOG_INFO, "New Push Message object created %s", path);

	g_dbus_method_invocation_return_value(
		task->invocation, g_variant_new("(o)", path));
	g_free(path);
	task->invocation = NULL;
	return;

CPC_ON_ERR:

	CPC_LOGF("Failed to create Push Message object");
	syslog(LOG_INFO, "Failed to create Push Message object");

	g_dbus_method_invocation_return_dbus_error(
		task->invocation, cpc_dbus_error_map(CPC_ERR), "");
	task->invocation = NULL;
}
Exemplo n.º 2
0
bool cpc_tasks_apply(cpc_task_t *task, cpc_pm_manager_t *pm_manager,
		     cpc_cb_t finished, void *finished_data,
		     cpc_tasks_handle_t *handle)
{
	CPC_ERR_MANAGE;
	cpc_task_data_t *callback_data;
	const gchar *client_name =
		g_dbus_method_invocation_get_sender(task->invocation);

	callback_data = g_new(cpc_task_data_t, 1);
	callback_data->finished = finished;
	callback_data->finished_data = finished_data;
	callback_data->invocation = task->invocation;

	CPC_FAIL(cpc_pm_manager_apply(pm_manager, task->path, client_name,
				      task->pin, prv_task_finished,
				      callback_data, handle));
	task->invocation = NULL;

	syslog(LOG_INFO, "Starting Apply task");
	CPC_LOGF("Starting Apply task");

	return true;

CPC_ON_ERR:

	g_free(callback_data);
	g_dbus_method_invocation_return_dbus_error(
		task->invocation, cpc_dbus_error_map(CPC_ERR), "");
	task->invocation = NULL;

	return false;
}
Exemplo n.º 3
0
static gboolean
handle_file_chooser_close (XdpFileChooser *object,
                           GDBusMethodInvocation *invocation,
                           const gchar *arg_sender,
                           const gchar *arg_app_id,
                           const gchar *arg_handle)
{
  FileDialogHandle *handle;

  handle = (FileDialogHandle *)dialog_handle_find (arg_sender, arg_app_id, arg_handle,
                                                   XDP_TYPE_FILE_CHOOSER_SKELETON);

  if (handle != NULL)
    {
      file_dialog_handle_close (handle);
      xdp_file_chooser_complete_close (object, invocation);
    }
  else
    {
      g_dbus_method_invocation_return_dbus_error (invocation,
                                                  "org.freedesktop.Flatpak.Error.NotFound",
                                                  "No such handle");
    }

  return TRUE;
}
Exemplo n.º 4
0
bool cpc_tasks_parsecp(cpc_task_t *task, cpc_cb_t finished,
		       void *finished_data, cpc_handle_t *handle)
{
	CPC_ERR_MANAGE;
	cpc_task_data_t *callback_data;

	callback_data = g_new(cpc_task_data_t, 1);
	callback_data->finished = finished;
	callback_data->finished_data = finished_data;
	callback_data->invocation = task->invocation;

	CPC_LOGF("Starting ParseCP task");
	syslog(LOG_INFO, "Starting ParseCP task");

	CPC_FAIL(cpc_provision_cp_apply(task->path, prv_task_finished,
					callback_data, handle));

	task->invocation = NULL;

	return true;

CPC_ON_ERR:

	g_free(callback_data);
	g_dbus_method_invocation_return_dbus_error(
		task->invocation, cpc_dbus_error_map(CPC_ERR), "");
	task->invocation = NULL;

	return false;
}
Exemplo n.º 5
0
/**
 * Handle @c org.bluez.GattCharacterstic1.WriteValue() method call.
 *
 * This handler is triggered when the
 * @c org.bluez.GattCharacterstic1.WriteValue() method is called by a
 * client on the BlueZ-based OIC GATT request characteristic.  In
 * particular, IoTivity request data is sent by the GATT client to the
 * GATT server through this call.  The server will retrieve the data
 * that was sent from the @a value argument.  Reassembly of any
 * request data fragments will begin here.
 *
 * @param[in] object     @c org.bluez.GattCharacteristic1 skeleton
 *                       object associated with this method call.
 * @param[in] invocation D-Bus method invocation related object used
 *                       when sending results/errors asynchronously.
 * @param[in] value      The @c GVariant containing the byte array
 *                       (ay) with th request data inside.
 * @param[in] user_data  Pointer to request
 *                       @c CAGattCharacteristic object.
 *
 * @return @c TRUE to indicate that
 *         @c org.bluez.Characteristic.WriteValue() method is
 *         implemented.
 */
static gboolean CAGattCharacteristicHandleWriteValue(
    GattCharacteristic1 * object,
    GDBusMethodInvocation * invocation,
    GVariant * value,
    gpointer user_data)
{
    /*
      This method is only trigged in a GATT server when receiving
      data sent by a GATT client, i.e. the client wrote a value to
      the server, and the server is handling that write request.
    */

    // GLib maps an octet to a guchar, which is of size 1.
    gsize len = 0;
    gconstpointer const data =
        g_variant_get_fixed_array(value, &len, 1);

    CAGattCharacteristic * const c = user_data;

    if (CAGattRecv(&c->recv_info, data, (uint32_t) len))
    {
        gatt_characteristic1_complete_write_value(object, invocation);
    }
    else
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.bluez.Error.Failed",
            "Error when handling GATT request data fragment");
    }

    return TRUE;
}
Exemplo n.º 6
0
/**
   Handle "Request"

   @user_data: priv->client_list
*/
static gboolean 
ratdb_dbus_handler_request (RatdbProxyEngine       *skeleton,
                            GDBusMethodInvocation  *invocation,
                            const gchar            *type,
                            gpointer                user_data)
{
    GHashTable *clients = (GHashTable *)user_data;
    const gchar *uuid = NULL;
    RatdbClient *client = ratdb_client_new (type);

    if (!client)
    {
        g_dbus_method_invocation_return_dbus_error (invocation,
                                                    "org.ratdb.Daemon.Error",
                                                    _("failed to create a backend"));
        return TRUE;
    }

    uuid = ratdb_client_get_uuid (client);
    /* we don't take the refcount */
    g_hash_table_insert (clients, g_strdup (uuid), client);

    /* Called successfully */
    ratdb_proxy_engine_complete_request (skeleton, invocation, uuid);
    g_debug ("Object for new client created");
    return TRUE;
}
Exemplo n.º 7
0
static void
_bus_method_call (GDBusConnection * connection,
                 const gchar * sender, const gchar * object_path, const gchar * interface,
                 const gchar * method, GVariant * params,
                 GDBusMethodInvocation * invocation, gpointer user_data)
{
    g_debug ("bus_method_call");

    GVariant * retval = NULL;
    GError * error = NULL;

    if (g_strcmp0 (method, "get_pinyin") == 0) {
        const gchar *buf = NULL;
        gchar* pinyin = NULL;
        
        g_variant_get (params, "(s)", &buf);
        pinyin = get_pinyin (buf);
        retval = g_variant_new("(s)", pinyin ? pinyin : "");
    } else if (g_strcmp0 (method, "finalize_dbus_loop") == 0) {
        finalize_dbus_loop();
    } else if (g_strcmp0 (method, "create_pinyin_trie") == 0) {
        const gchar* data = NULL;
        gchar* md5 = NULL;

        g_variant_get (params, "(s)", &data);
        md5 = create_pinyin_trie (data);
        retval = g_variant_new ("(s)", md5 ? md5 : "");
    } else if (g_strcmp0 (method, "get_ret_via_keys") == 0) {
        const gchar* keys = NULL;
        const gchar* md5 = NULL;
        gchar* str_ret = NULL;

        g_variant_get (params, "(ss)", &keys, &md5);
        str_ret = get_ret_via_keys (keys, md5);
        retval = g_variant_new ("(s)", str_ret ? str_ret : "");
    } else if (g_strcmp0 (method, "finalize_data_trie") == 0) {
        const gchar* md5 = NULL;

        g_variant_get (params, "(s)", &md5);
        finalize_data_trie (md5);
    } else {
        g_warning ("Calling method '%s' on lock and it's unknown", method);
    }

    if (error != NULL) {
        g_dbus_method_invocation_return_dbus_error (invocation,
                "com.deepin.dde.lock.Error",
                error->message);
        g_error_free (error);

    } else {
        g_dbus_method_invocation_return_value (invocation, retval);
    }
}
Exemplo n.º 8
0
/**
 * bus_installer_install_local_cb:
 */
static gboolean
bus_installer_install_local_cb (LiProxyManager *mgr_bus, GDBusMethodInvocation *context, const gchar *fname, LiHelperDaemon *helper)
{
	GError *error = NULL;
	LiInstaller *inst = NULL;
	PolkitAuthorizationResult *pres = NULL;
	PolkitSubject *subject;
	const gchar *sender;

	sender = g_dbus_method_invocation_get_sender (context);

	subject = polkit_system_bus_name_new (sender);
	pres = polkit_authority_check_authorization_sync (helper->authority,
								subject,
								"org.freedesktop.limba.install-package-local",
								NULL,
								POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
								NULL,
								&error);
	g_object_unref (subject);

	if (error != NULL) {
		g_dbus_method_invocation_take_error (context, error);
		goto out;
	}

	if (!polkit_authorization_result_get_is_authorized (pres)) {
		g_dbus_method_invocation_return_dbus_error (context, "org.freedesktop.Limba.Installer.Error.NotAuthorized",
							"Authorization failed.");
		goto out;
	}

	/* initialize our job, in case it is idling */
	if (!li_daemon_init_job (helper, mgr_bus, context))
		goto out;

	/* do the thing */
	li_daemon_job_run_install_local (helper->job, fname);

	li_proxy_manager_complete_install_local (mgr_bus, context);

 out:
	if (inst != NULL)
		g_object_unref (inst);
	if (pres != NULL)
		g_object_unref (pres);

	li_daemon_reset_timer (helper);

	return TRUE;
}
Exemplo n.º 9
0
void cpc_tasks_get_props(cpc_task_t *task, cpc_pm_manager_t *pm_manager)
{
	CPC_ERR_MANAGE;
	GVariantBuilder *vb;
	const gchar *pin_required_str;
	cpc_props_t props;
	const gchar *client_name =
		g_dbus_method_invocation_get_sender(task->invocation);

	CPC_FAIL(cpc_pm_manager_get_properties(pm_manager, task->path,
					       client_name, &props));

	pin_required_str = props.pin_required ? "Yes" : "No";

	CPC_LOGF("Pin Required %s", pin_required_str);
	CPC_LOGF("Settings %s", props.settings);
	CPC_LOGF("Sec Type %s", props.sec_type);
	CPC_LOGF("Start Sessions with %s", props.start_sessions);

	syslog(LOG_INFO, "GetProps (%s, %s, %s %s) succeeded.",
	       pin_required_str, props.settings, props.sec_type,
	       props.start_sessions);

	vb = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
	g_variant_builder_add(vb, "{ss}", "PinRequired", pin_required_str);
	g_variant_builder_add(vb, "{ss}", "Settings", props.settings);
	g_variant_builder_add(vb, "{ss}", "SecType", props.sec_type);
	g_variant_builder_add(vb, "{ss}", "StartSessionsWith",
			      props.start_sessions);
	cpc_props_free(&props);

	g_dbus_method_invocation_return_value(
		task->invocation, g_variant_new("(@a{ss})",
						g_variant_builder_end(vb)));
	g_variant_builder_unref(vb);
	task->invocation = NULL;
	return;

CPC_ON_ERR:

	CPC_LOGF("Failed to retrieve properties for %s err %u", task->path,
		 CPC_ERR);
	syslog(LOG_INFO, "Failed to retrieve properties for %s err %u",
	       task->path, CPC_ERR);

	g_dbus_method_invocation_return_dbus_error(
		task->invocation, cpc_dbus_error_map(CPC_ERR), "");
	task->invocation = NULL;
}
Exemplo n.º 10
0
/**
 * li_daemon_init_job:
 */
gboolean
li_daemon_init_job (LiHelperDaemon *helper, LiProxyManager *mgr_bus, GDBusMethodInvocation *context)
{
	gboolean ret;

	/* we don't have a job queue, so we error out in case someone tries to start
	 * multiple jobs at the same time */
	if (li_daemon_job_is_running (helper->job)) {
		g_dbus_method_invocation_return_dbus_error (context, "org.freedesktop.Limba.Manager.Error.Failed",
							"Another job is running at time, Please wait for it to complete.");
		return FALSE;
	}

	ret = li_daemon_job_prepare (helper->job, mgr_bus);
	return ret;
}
Exemplo n.º 11
0
static gboolean
handle_get_slave_bus_name (GdmDBusDisplay        *skeleton,
                           GDBusMethodInvocation *invocation,
                           GdmDisplay            *display)
{
    if (display->priv->slave_bus_name != NULL) {
        gdm_dbus_display_complete_get_slave_bus_name (skeleton, invocation,
                display->priv->slave_bus_name);
    } else {
        g_dbus_method_invocation_return_dbus_error (invocation,
                "org.gnome.DisplayManager.NotReady",
                "Slave is not yet registered");
    }

    return TRUE;
}
/**
 * g_dbus_method_invocation_return_gerror:
 * @invocation: A #GDBusMethodInvocation.
 * @error: A #GError.
 *
 * Like g_dbus_method_invocation_return_error() but takes a #GError
 * instead of the error domain, error code and message.
 *
 * This method will free @invocation, you cannot use it afterwards.
 *
 * Since: 2.26
 */
void
g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation,
                                        const GError          *error)
{
  gchar *dbus_error_name;

  g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
  g_return_if_fail (error != NULL);

  dbus_error_name = g_dbus_error_encode_gerror (error);

  g_dbus_method_invocation_return_dbus_error (invocation,
                                              dbus_error_name,
                                              error->message);
  g_free (dbus_error_name);
}
Exemplo n.º 13
0
static gboolean report_error_cb(ConnmanInterfaceAgent *interface,
								GDBusMethodInvocation *invocation,
								const char *path,
								const char *error_message,
								gpointer user_data)
{
	connman_agent_t *agent = user_data;

	if (agent->report_error_cb == NULL) {
		g_dbus_method_invocation_return_dbus_error(invocation, AGENT_ERROR_CANCELED,
			"No handler available");
	}
	else {
		agent->report_error_cb(error_message, agent->report_error_data);
	}

	return TRUE;
}
Exemplo n.º 14
0
static void
input_req_event(void *opaque, event_t *e)
{
  connman_service_t *cs = opaque;
  if(cs->cs_input_req_inv == NULL)
    return;

  if(event_is_action(e, ACTION_OK)) {

    rstr_t *username = prop_get_string(cs->cs_input_req_prop, "username", NULL);
    rstr_t *password = prop_get_string(cs->cs_input_req_prop, "password", NULL);

    GVariant *result;
    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));

    g_variant_builder_add(builder, "{sv}", "Passphrase",
			  g_variant_new_string(rstr_get(password)));

    if(cs->cs_input_req_want_identity)
      g_variant_builder_add(builder, "{sv}", "Identity",
			    g_variant_new_string(rstr_get(username)));

    result = g_variant_new("(a{sv})", builder);

    TRACE(TRACE_DEBUG, "CONNMAN", "Auth response: %s",
	  g_variant_print(result, TRUE));

    g_dbus_method_invocation_return_value(cs->cs_input_req_inv, result);

    g_variant_builder_unref(builder);
    rstr_release(username);
    rstr_release(password);
    connman_stop_input_request(cs);
  }

  if(event_is_action(e, ACTION_CANCEL)) {
    g_dbus_method_invocation_return_dbus_error(cs->cs_input_req_inv,
					       "net.connman.Agent.Error.Canceled",
					       "Canceled by user");
    connman_stop_input_request(cs);
  }

}
Exemplo n.º 15
0
static void prv_task_finished(int result, void *user_data)
{
	cpc_task_data_t *callback_data = user_data;

	if (result == CPC_ERR_NONE)
		g_dbus_method_invocation_return_value(callback_data->invocation,
						      NULL);
	else
		g_dbus_method_invocation_return_dbus_error(
			callback_data->invocation,
			cpc_dbus_error_map(result), "");

	CPC_LOGF("Async task finished with err %u", result);
	syslog(LOG_INFO, "Async task finished with err %u", result);

	callback_data->finished(result, callback_data->finished_data);

	g_free(callback_data);
}
Exemplo n.º 16
0
static gboolean 
ratdb_dbus_handler_new_table (RatdbProxyEngine      *skeleton,
                              GDBusMethodInvocation *invocation,
                              const gchar           *uuid,
                              const gchar           *name,
                              gpointer               iface_user_data,
                              gpointer               user_data)
{
    RatdbEngine *engine = ratdb_client_get_engine (ratdb_daemon_get_client (RATDB_DAEMON (user_data), uuid));
    if (ratdb_engine_new_table (engine, name, iface_user_data))
    {
        ratdb_proxy_engine_complete_new_table (skeleton, invocation);
    }
    else
    {
        g_dbus_method_invocation_return_dbus_error (invocation, "org.ratdb.Daemon.Error", _("creating new table failed"));
    }
    return TRUE;
}
Exemplo n.º 17
0
static gboolean
on_set_power_state(ControlPower *pwr,
		GDBusMethodInvocation *invocation,
		guint state,
		gpointer user_data)
{
	Control* control = object_get_control((Object*)user_data);
	if(state > 1)
	{
		g_dbus_method_invocation_return_dbus_error(invocation,
				"org.openbmc.ControlPower.Error.Failed",
				"Invalid power state");
		return TRUE;
	}
	// return from method call
	control_power_complete_set_power_state(pwr,invocation);
	if(state == control_power_get_state(pwr))
	{
		g_print("Power already at requested state: %d\n",state);
	}
	else
	{
		int error = 0;
		do {
			if(state == 1) {
				control_emit_goto_system_state(control,"HOST_POWERING_ON");
			} else {
				control_emit_goto_system_state(control,"HOST_POWERING_OFF");
			}
			error = gpio_open(&power_pin);
			if(error != GPIO_OK) { break;	}
			error = gpio_write(&power_pin,!state);
			if(error != GPIO_OK) { break;	}
			gpio_close(&power_pin);
			control_power_set_state(pwr,state);
		} while(0);
		if(error != GPIO_OK)
		{
			printf("ERROR PowerControl: GPIO set power state (rc=%d)\n",error);
		}
	}
	return TRUE;
}
Exemplo n.º 18
0
static gboolean request_input_cb(ConnmanInterfaceAgent *interface,
								 GDBusMethodInvocation *invocation,
								 const gchar *path,
								 GVariant *fields,
								 gpointer user_data)
{
	connman_agent_t *agent = user_data;
	GVariant *response = NULL;

	if (agent->request_input_cb == NULL) {
		g_dbus_method_invocation_return_dbus_error(invocation, AGENT_ERROR_CANCELED,
			"No handler available");
	}
	else {
		response = agent->request_input_cb(fields, agent->request_input_data);
		connman_interface_agent_complete_request_input(agent->interface, invocation, response);
	}

	return TRUE;
}
Exemplo n.º 19
0
static void dbus_lua_call_finished(lua_State* L,int result,void* data)
{
  GDBusMethodInvocation *invocation = (GDBusMethodInvocation*)data;
  if(result == LUA_OK)
  {
    if(lua_isnil(L, -1))
    {
      g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", ""));
    }
    else
    {
      const char *checkres = luaL_checkstring(L, -1);
      g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", checkres));
    }
  }
  else
  {
    const char *msg = luaL_checkstring(L, -1);
    g_dbus_method_invocation_return_dbus_error(invocation, "org.darktable.Error.LuaError", msg);
    dt_lua_check_print_error(L,result);
  }
}
Exemplo n.º 20
0
/*
** DBus method call: "InstanceExit" -- Called from an instance
*/
static gboolean on_handle_instance_exit(WarfacebotMngr *wbm,
                                        GDBusMethodInvocation *invocation,
                                        const gchar *BusName)
{
    g_print("Instance wants to exit: %s\n", BusName);

    if (!g_dbus_is_name(BusName))
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.freedesktop.DBus.Error.ServiceUnknown",
            "Invalid BusName");
        return FALSE;
    }

    delete_service_file(BusName);

    warfacebot_mngr_complete_instance_exit(
        wbm,
        invocation);

    return TRUE;
}
Exemplo n.º 21
0
static void handle_method_call(GDBusConnection *connection,
			       const gchar *sender,
			       const gchar *object_path,
			       const gchar *interface_name,
			       const gchar *method_name,
			       GVariant *parameters,
			       GDBusMethodInvocation *invocation,
			       gpointer user_data)
{
	printf("call method: '%s'\n", method_name);
	if (!g_strcmp0(method_name, "HelloWorld")) {
		const gchar *greeting;
		g_variant_get(parameters, "(&s)", &greeting);
		gchar *response;
		response = g_strdup_printf("You greeted me with '%s'. Thanks!", greeting);
		g_dbus_method_invocation_return_value
			(invocation, g_variant_new("(s)", response));
		g_free (response);
	} else {
		g_dbus_method_invocation_return_dbus_error(invocation,
							   "org.gtk.GDBus.Failed",
							   "Your message bus daemon does not support file descriptor passing (need D-Bus >= 1.3.0)");
		}
}
Exemplo n.º 22
0
void cpc_tasks_close_pm(cpc_task_t *task, cpc_pm_manager_t *pm_manager)
{
	CPC_ERR_MANAGE;
	const gchar *client_name =
		g_dbus_method_invocation_get_sender(task->invocation);

	CPC_FAIL(cpc_pm_manager_remove_message(pm_manager, task->path,
					       client_name));

	CPC_LOGF("Push Message object %s removed", task->path);
	syslog(LOG_INFO, "Push Message object %s removed", task->path);

	g_dbus_method_invocation_return_value(task->invocation, NULL);
	task->invocation = NULL;
	return;

CPC_ON_ERR:
	CPC_LOGF("Failed to remove Push Message Object %s", task->path);
	syslog(LOG_INFO, "Failed to remove Push Message Object %s", task->path);

	g_dbus_method_invocation_return_dbus_error(
		task->invocation, cpc_dbus_error_map(CPC_ERR), "");
	task->invocation = NULL;
}
Exemplo n.º 23
0
static void
handle_method_call (GDBusConnection       *connection,
                    const gchar           *sender,
                    const gchar           *object_path,
                    const gchar           *interface_name,
                    const gchar           *method_name,
                    GVariant              *parameters,
                    GDBusMethodInvocation *invocation,
                    gpointer               user_data)
{
  if (g_strcmp0 (method_name, "HelloWorld") == 0)
    {
      const gchar *greeting;

      g_variant_get (parameters, "(&s)", &greeting);

      if (g_strcmp0 (greeting, "Return Unregistered") == 0)
        {
          g_dbus_method_invocation_return_error (invocation,
                                                 G_IO_ERROR,
                                                 G_IO_ERROR_FAILED_HANDLED,
                                                 "As requested, here's a GError not registered (G_IO_ERROR_FAILED_HANDLED)");
        }
      else if (g_strcmp0 (greeting, "Return Registered") == 0)
        {
          g_dbus_method_invocation_return_error (invocation,
                                                 G_DBUS_ERROR,
                                                 G_DBUS_ERROR_MATCH_RULE_NOT_FOUND,
                                                 "As requested, here's a GError that is registered (G_DBUS_ERROR_MATCH_RULE_NOT_FOUND)");
        }
      else if (g_strcmp0 (greeting, "Return Raw") == 0)
        {
          g_dbus_method_invocation_return_dbus_error (invocation,
                                                      "org.gtk.GDBus.SomeErrorName",
                                                      "As requested, here's a raw D-Bus error");
        }
      else
        {
          gchar *response;
          response = g_strdup_printf ("You greeted me with '%s'. Thanks!", greeting);
          g_dbus_method_invocation_return_value (invocation,
                                                 g_variant_new ("(s)", response));
          g_free (response);
        }
    }
  else if (g_strcmp0 (method_name, "EmitSignal") == 0)
    {
      GError *local_error;
      gdouble speed_in_mph;
      gchar *speed_as_string;

      g_variant_get (parameters, "(d)", &speed_in_mph);
      speed_as_string = g_strdup_printf ("%g mph!", speed_in_mph);

      local_error = NULL;
      g_dbus_connection_emit_signal (connection,
                                     NULL,
                                     object_path,
                                     interface_name,
                                     "VelocityChanged",
                                     g_variant_new ("(ds)",
                                                    speed_in_mph,
                                                    speed_as_string),
                                     &local_error);
      g_assert_no_error (local_error);
      g_free (speed_as_string);

      g_dbus_method_invocation_return_value (invocation, NULL);
    }
  else if (g_strcmp0 (method_name, "GimmeStdout") == 0)
    {
#ifdef G_OS_UNIX
      if (g_dbus_connection_get_capabilities (connection) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING)
        {
          GDBusMessage *reply;
          GUnixFDList *fd_list;
          GError *error;

          fd_list = g_unix_fd_list_new ();
          error = NULL;
          g_unix_fd_list_append (fd_list, STDOUT_FILENO, &error);
          g_assert_no_error (error);

          reply = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
          g_dbus_message_set_unix_fd_list (reply, fd_list);

          error = NULL;
          g_dbus_connection_send_message (connection,
                                          reply,
                                          G_DBUS_SEND_MESSAGE_FLAGS_NONE,
                                          NULL, /* out_serial */
                                          &error);
          g_assert_no_error (error);

          g_object_unref (invocation);
          g_object_unref (fd_list);
          g_object_unref (reply);
        }
      else
        {
          g_dbus_method_invocation_return_dbus_error (invocation,
                                                      "org.gtk.GDBus.Failed",
                                                      "Your message bus daemon does not support file descriptor passing (need D-Bus >= 1.3.0)");
        }
#else
      g_dbus_method_invocation_return_dbus_error (invocation,
                                                  "org.gtk.GDBus.NotOnUnix",
                                                  "Your OS does not support file descriptor passing");
#endif
    }
}
Exemplo n.º 24
0
/**
 * Handle @c org.bluez.GattCharacterstic1.StopNotify() method call.
 *
 * This handler is triggered when the
 * @c org.bluez.GattCharacterstic1.StopNotify() method is called by a
 * client on the BlueZ-based OIC GATT response characteristic.  It
 * sets the @c org.bluez.GattCharacterstic1.Notifying property to
 * @c FALSE, and disables responses from the server.
 *
 * @param[in] object     @c org.bluez.GattCharacteristic1 skeleton
 *                       object associated with this method call.
 * @param[in] invocation D-Bus method invocation related object used
 *                       when sending results/errors asynchronously.
 * @param[in] user_data  Pointer to the response
 *                       @c CAGattCharacteristic object.
 *
 * @return @c TRUE to indicate that
 *         @c org.bluez.Characteristic.StopNotify() method is
 *         implemented.
 */
static gboolean CAGattCharacteristicHandleStopNotify(
    GattCharacteristic1 * object,
    GDBusMethodInvocation * invocation,
    gpointer user_data)
{
    assert(user_data != NULL);

    /**
     * @todo Does BlueZ already prevent redundant calls to
     *       @c org.bluez.GattCharacteristic1.StopNotify()?
     */
    if (!gatt_characteristic1_get_notifying(object))
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.bluez.Error.Failed",
            "Notifications were not previously enabled.");

        return TRUE;
    }

    CAGattCharacteristic * const characteristic = user_data;

    // Clear the client endpoint from the request characteristic.
    CAGattRecvInfo * const recv_info =
        &characteristic->service->request_characteristic.recv_info;

    /*
      Remove the appropriate entry from the endpoint-to-characteristic
      map so that attempts to send a response through it will fail.
    */
    CALEContext * const context = characteristic->context;
    ca_mutex_lock(context->lock);

    bool const removed =
        g_hash_table_remove(context->characteristic_map, recv_info->peer);

    ca_mutex_unlock(context->lock);

    CAGattRecvInfoDestroy(recv_info);

    /**
     * @todo Do we need to explicitly emit the @c GObject @c notify or
     *       @c org.freedesktop.Dbus.Properties.PropertiesChanged
     *       signal here?
     */
    gatt_characteristic1_set_notifying(object, FALSE);

    if (removed)
    {
        gatt_characteristic1_complete_stop_notify(object, invocation);
    }
    else
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.bluez.Error.Failed",
            "Error removing peer address information");
    }

    return TRUE;
}
Exemplo n.º 25
0
/**
 * Handle @c org.bluez.GattCharacterstic1.StartNotify() method call.
 *
 * This handler is triggered when the
 * @c org.bluez.GattCharacterstic1.StartNotify() method is called by a
 * client on the BlueZ-based OIC GATT response characteristic.  It
 * sets the @c org.bluez.GattCharacterstic1.Notifying property to
 * @c TRUE, and enables responses from the server.
 *
 * @note This handler is not available in the OIC GATT request
 *       characteristic implementation.
 *
 * @param[in] object     @c org.bluez.GattCharacteristic1 skeleton
 *                       object associated with this method call.
 * @param[in] invocation D-Bus method invocation related object used
 *                       when sending results/errors asynchronously.
 * @param[in] user_data  Pointer to the response
 *                       @c CAGattCharacteristic object.
 *
 * @return @c TRUE to indicate that
 *         @c org.bluez.Characteristic.StartNotify() method is
 *         implemented.
 */
static gboolean CAGattCharacteristicHandleStartNotify(
    GattCharacteristic1 * object,
    GDBusMethodInvocation * invocation,
    gpointer user_data)
{
    /**
     * Only allow the client to start notifications once.
     *
     * @todo Does BlueZ already prevent redundant calls to
     *       @c org.bluez.GattCharacteristic1.StartNotify()?
     */
    if (gatt_characteristic1_get_notifying(object))
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.bluez.Error.Failed",
            "Notifications are already enabled.");

        return TRUE;
    }

    // Retrieve the response characteristic information.
    CAGattCharacteristic * const characteristic = user_data;

    char * const peer =
        CAGattCharacteristicMakePeerAddress(characteristic);

    if (peer == NULL)
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.bluez.Error.Failed",
            "Error creating peer endpoint information");

        return TRUE;
    }

    /*
      Create an entry in the endpoint-to-characteristic map so that
      responses may be sent to the GATT client through the OIC GATT
      response characteristic through this BLE adapter's
      CAAdapterSendUnicastData() implementation.
     */
    CALEContext * const context = characteristic->context;

    ca_mutex_lock(context->lock);

#if GLIB_CHECK_VERSION(2,40,0)
    /*
      GLib hash table functions started returning a boolean result in
       version 2.40.x.
    */
    bool const inserted =
#endif
        g_hash_table_insert(context->characteristic_map,
                            peer,
                            characteristic);

    ca_mutex_unlock(context->lock);

#if GLIB_CHECK_VERSION(2,40,0)
    if (!inserted)
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.bluez.Error.Failed",
            "Unable to set response endpoint.");

        OICFree(peer);

        return TRUE;
    }
#endif

    /**
     * @todo Do we need to explicitly emit the @c GObject @c notify or
     *       @c org.freedesktop.Dbus.Properties.PropertiesChanged
     *       signal here?
     */
    gatt_characteristic1_set_notifying(object, TRUE);

    /*
      Set the client endpoint field in the request characteristic so
      that it may pass the appropriate endpoint object up the stack
      through the CA request/response callback once a request has been
      completely received and reassembled.
    */
    CAGattRecvInfo * const recv_info =
        &characteristic->service->request_characteristic.recv_info;

    recv_info->peer = peer;

    ca_mutex_lock(context->lock);
    recv_info->on_packet_received = context->on_server_received_data;
    recv_info->context            = context;
    ca_mutex_unlock(context->lock);

    gatt_characteristic1_complete_start_notify(object, invocation);

    return TRUE;
}
Exemplo n.º 26
0
/**
 * @brief Create function handler
 * @param[in] object
 * @param[in] invocation
 * @param[in] instance
 * @param[in] type
 * @return true if metod handled
 */
static gboolean
handle_create_function(GadgetdGadgetFunctionManager	*object,
		        GDBusMethodInvocation		*invocation,
		        const gchar			*instance,
		        const gchar			*type)
{
	gchar _cleanup_g_free_ *function_path = NULL;
	const gchar *msg = NULL;
	GadgetFunctionManager *func_manager = GADGET_FUNCTION_MANAGER(object);
	GadgetdFunctionObject *function_object;
	GadgetDaemon *daemon;
	struct gd_gadget *gadget = func_manager->gadget;
	const gchar *gadget_name = usbg_get_gadget_name(gadget->g);
	gchar _cleanup_g_free_ *instance_path = NULL;
	gchar _cleanup_g_free_ *type_path = NULL;
	struct gd_function *func = NULL;
	gint ret;

	daemon = gadget_function_manager_get_daemon(GADGET_FUNCTION_MANAGER(object));

	INFO("handled create function");

	if (gadget == NULL || gadget_name == NULL) {
		msg = "Unable to get gadget";
		goto err;
	}

	ret = make_valid_object_path_part(instance, &instance_path);
	if (ret != GD_SUCCESS) {
		msg = "Invalid instance name";
		goto err;
	}

	ret = make_valid_object_path_part(type, &type_path);
	if (ret != GD_SUCCESS) {
		msg = "Invalid type name";
		goto err;
	}

	function_path = g_strdup_printf("%s/Function/%s/%s",
					func_manager->gadget_path,
					type_path,
					instance_path);

	if (function_path == NULL || !g_variant_is_object_path(function_path)) {
		msg = "Invalid function instance or type";
		goto err;
	}

	ret = gd_create_function(gadget, type, instance, &func, &msg);
	if (ret != GD_SUCCESS)
		goto err;

	function_object = gadgetd_function_object_new(function_path, func);
	if (function_object == NULL) {
		msg = "Unable to create function object";
		goto err;
	}

	g_dbus_object_manager_server_export(gadget_daemon_get_object_manager(daemon),
					    G_DBUS_OBJECT_SKELETON(function_object));

	/* send function path*/
	g_dbus_method_invocation_return_value(invocation,
					      g_variant_new("(o)",
					      function_path));
	return TRUE;

err:
	g_dbus_method_invocation_return_dbus_error(invocation,
			func_manager_iface,
			msg);
	return TRUE;
}
Exemplo n.º 27
0
/*
** DBus method call: "InstanceReady" -- Called from an instance
**  - Create an instance interface in the manager bus
**  - Watch the instance bus
*/
static gboolean on_handle_instance_ready(WarfacebotMngr *wbm,
                                         GDBusMethodInvocation *invocation,
                                         const gchar *Nickname,
                                         const gchar *Server,
                                         const gchar *BusName)
{
    ObjectSkeleton *skeleton = NULL;
    WarfacebotMngrInstance *wbi = NULL;
    struct watch_instance *watch = NULL;

    if (!g_dbus_is_name(BusName))
    {
        g_dbus_method_invocation_return_dbus_error(
            invocation,
            "org.freedesktop.DBus.Error.ServiceUnknown",
            "Invalid BusName");
        return FALSE;
    }

    g_print("Notification from instance: %s\n", BusName);

    watch = g_new0(struct watch_instance, 1);

    watch->name = g_strdup(BusName);
    watch->path = g_strdup_printf(API_MNGR_PATH "/%03d", ++uniq_id);
    skeleton = object_skeleton_new(watch->path);

    wbi = warfacebot_mngr_instance_skeleton_new();

    warfacebot_mngr_instance_set_nickname(wbi, Nickname);
    warfacebot_mngr_instance_set_server(wbi, Server);
    warfacebot_mngr_instance_set_bus_name(wbi, BusName);
    warfacebot_mngr_instance_set_starttime(wbi, time(NULL));

    object_skeleton_set_warfacebot_mngr_instance(skeleton, wbi);

    g_dbus_object_manager_server_export(
        manager,
        G_DBUS_OBJECT_SKELETON (skeleton));

    g_object_unref(skeleton);

    create_service_file(BusName, Nickname, Server);

    watch->id = g_bus_watch_name(
        G_BUS_TYPE_SESSION,
        BusName,
        G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
        on_instance_name_appeared,
        on_instance_name_vanished,
        watch,
        NULL);

    g_print("Watching instance: %s\n", BusName);

    warfacebot_mngr_complete_instance_ready(
        wbm,
        invocation);

    return TRUE;
}
static void
handle_method_call (GDBusConnection       *connection,
                    const gchar           *sender,
                    const gchar           *object_path,
                    const gchar           *interface_name,
                    const gchar           *method_name,
                    GVariant              *parameters,
                    GDBusMethodInvocation *invocation,
                    gpointer               user_data)
{
  App *app = user_data;

  if (g_strcmp0 (method_name, "GetEvents") == 0)
    {
      GVariantBuilder builder;
      GHashTableIter hash_iter;
      CalendarAppointment *a;
      gint64 since;
      gint64 until;
      gboolean force_reload;
      gboolean window_changed;

      g_variant_get (parameters,
                     "(xxb)",
                     &since,
                     &until,
                     &force_reload);

      if (until < since)
        {
          g_dbus_method_invocation_return_dbus_error (invocation,
                                                      "org.gnome.Shell.CalendarServer.Error.Failed",
                                                      "until cannot be before since");
          goto out;
        }

      print_debug ("Handling GetEvents (since=%" G_GINT64_FORMAT ", until=%" G_GINT64_FORMAT ", force_reload=%s)",
                   since,
                   until,
                   force_reload ? "true" : "false");

      window_changed = FALSE;
      if (!(app->until == until && app->since == since))
        {
          GVariantBuilder *builder;
          GVariantBuilder *invalidated_builder;

          app->until = until;
          app->since = since;
          window_changed = TRUE;

          builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
          invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
          g_variant_builder_add (builder, "{sv}",
                                 "Until", g_variant_new_int64 (app->until));
          g_variant_builder_add (builder, "{sv}",
                                 "Since", g_variant_new_int64 (app->since));
          g_dbus_connection_emit_signal (app->connection,
                                         NULL, /* destination_bus_name */
                                         "/org/gnome/Shell/CalendarServer",
                                         "org.freedesktop.DBus.Properties",
                                         "PropertiesChanged",
                                         g_variant_new ("(sa{sv}as)",
                                                        "org.gnome.Shell.CalendarServer",
                                                        builder,
                                                        invalidated_builder),
                                         NULL); /* GError** */
        }

      /* reload events if necessary */
      if (window_changed || force_reload || app->cache_invalid)
        {
          app_load_events (app);
        }

      /* The a{sv} is used as an escape hatch in case we want to provide more
       * information in the future without breaking ABI
       */
      g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sssbxxa{sv})"));
      g_hash_table_iter_init (&hash_iter, app->appointments);
      while (g_hash_table_iter_next (&hash_iter, NULL, (gpointer) &a))
        {
          GVariantBuilder extras_builder;
          GSList *l;

          for (l = a->occurrences; l; l = l->next)
            {
              CalendarOccurrence *o = l->data;
              time_t start_time = o->start_time;
              time_t end_time   = o->end_time;

              if ((start_time >= app->since &&
                   start_time < app->until) ||
                  (start_time <= app->since &&
                  (end_time - 1) > app->since))
                {
                  g_variant_builder_init (&extras_builder, G_VARIANT_TYPE ("a{sv}"));
                  g_variant_builder_add (&builder,
                                         "(sssbxxa{sv})",
                                         a->uid,
                                         a->summary != NULL ? a->summary : "",
                                         a->description != NULL ? a->description : "",
                                         (gboolean) a->is_all_day,
                                         (gint64) start_time,
                                         (gint64) end_time,
                                         extras_builder);
                }
            }
        }
      g_dbus_method_invocation_return_value (invocation,
                                             g_variant_new ("(a(sssbxxa{sv}))", &builder));
    }
  else
    {
      g_assert_not_reached ();
    }

 out:
  ;
}
Exemplo n.º 29
0
/**
 * @brief find function by name handler
 * @param[in] object
 * @param[in] invocation
 * @param[in] function_name
 * @return true if metod handled
 */
static gboolean
handle_find_function_by_name(GadgetdGadgetFunctionManager	*object,
		      GDBusMethodInvocation			*invocation,
		      const gchar				*type,
		      const gchar				*instance)
{
	const gchar *path = NULL;
	const gchar *msg;
	gchar _cleanup_g_free_ *function_name = NULL;
	GadgetDaemon *daemon;
	GDBusObjectManager *object_manager;
	GList *objects;
	GList *l;
	struct gd_function *gd_func;
	GadgetFunctionManager *func_manager = GADGET_FUNCTION_MANAGER(object);

	INFO("find function by name handler");

	daemon = gadget_function_manager_get_daemon(GADGET_FUNCTION_MANAGER(object));
	if (daemon == NULL) {
		msg = "Failed to get daemon";
		goto out2;
	}

	object_manager = G_DBUS_OBJECT_MANAGER(gadget_daemon_get_object_manager(daemon));
	if (object_manager == NULL) {
		ERROR("Failed to get object manager");
		goto out2;
	}

	msg = "Failed to find function";
	objects = g_dbus_object_manager_get_objects(object_manager);
	for (l = objects; l != NULL; l = l->next)
	{
		GadgetdObject *gobj = GADGETD_OBJECT (l->data);
		path = g_dbus_object_get_object_path(G_DBUS_OBJECT(gobj));
		if (!GADGETD_IS_FUNCTION_OBJECT(G_DBUS_OBJECT(gobj)) ||
					!g_str_has_prefix(path, func_manager->gadget_path))
			continue;

		gd_func = gadgetd_function_object_get_function(GADGETD_FUNCTION_OBJECT(gobj));
		if (gd_func == NULL) {
			msg = "Failed to get function";
			break;
		}
		if (g_strcmp0(gd_func->type, type) == 0 && (strcmp(gd_func->instance, instance)== 0)) {
			path = g_dbus_object_get_object_path(G_DBUS_OBJECT(gobj));
			msg = NULL;
			goto out;
		}
	}

	if (path == NULL)
		msg = "Failed to find function";

	g_list_foreach(objects, (GFunc)g_object_unref, NULL);
	g_list_free(objects);

out2:
	if (msg != NULL) {
		ERROR("%s", msg);
		g_dbus_method_invocation_return_dbus_error(invocation,
				func_manager_iface,
				msg);
		return TRUE;
	}
out:
	/* send gadget path */
	g_dbus_method_invocation_return_value(invocation,
				      g_variant_new("(o)", path));

	return TRUE;
}
static void handleMethodCall(GDBusConnection       *connection,
							 const gchar           *sender,
							 const gchar           *object_path,
							 const gchar           *interface_name,
							 const gchar           *method_name,
							 GVariant              *parameters,
							 GDBusMethodInvocation *invocation,
							 gpointer               user_data)
{

	AutomotiveManager* manager = static_cast<AutomotiveManager*>(user_data);

	std::string method = method_name;

	if(method == "findProperty")
	{
		DebugOut(DebugOut::Warning)<<"org.automotive.Manager.findProperty() is deprecated.  Use org.automotive.Manager.FindObject() instead."<<endl;

		gchar* arg;

		g_variant_get(parameters,"(s)",&arg);

		std::string objectToFind = arg;

		if(objectToFind == "")
		{
			g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR,G_DBUS_ERROR_INVALID_ARGS, "Invalid argument.");
			return;
		}

		std::list<AbstractDBusInterface*> interfaces = AbstractDBusInterface::getObjectsForProperty(objectToFind);

		if(!interfaces.size())
		{
			g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.PropertyNotFound", "Object not found");
			return;
		}

		auto itr = interfaces.begin();

		g_dbus_method_invocation_return_value(invocation, g_variant_new("(o)",(*itr)->objectPath().c_str()));
		///TODO: we might need to clean up stuff there (like var)
	}

	else if(method == "FindObject")
	{
		gchar* arg;

		g_variant_get(parameters,"(s)",&arg);

		std::string objectToFind = arg;

		if(objectToFind == "")
		{
			g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR,G_DBUS_ERROR_INVALID_ARGS, "Invalid argument.");
			return;
		}

		std::list<AbstractDBusInterface*> interfaces = AbstractDBusInterface::getObjectsForProperty(objectToFind);

		if(!interfaces.size())
		{
			g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.ObjectNotFound", "Object not found");
			return;
		}

		GVariantBuilder params;
		g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);

		for(auto itr = interfaces.begin(); itr != interfaces.end(); itr++)
		{
			AbstractDBusInterface* t = *itr;
			if(!t->isSupported())
				continue;
			GVariant *newvar = g_variant_new("o",t->objectPath().c_str());
			g_variant_builder_add_value(&params, newvar);

		}

		//GVariant* var =  g_variant_builder_end(&params);

		g_dbus_method_invocation_return_value(invocation, g_variant_new("(ao)",&params));
		///TODO: we might need to clean up stuff there (like var)
	}

	else if(method == "FindObjectForZone")
	{
		gchar* arg;
		int zone;

		g_variant_get(parameters,"(si)", &arg, &zone);

		std::string propertyToFind = arg;

		if(propertyToFind == "")
		{
			g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR,G_DBUS_ERROR_INVALID_ARGS, "Invalid argument.");
			return;
		}

		std::list<AbstractDBusInterface*> interfaces = AbstractDBusInterface::getObjectsForProperty(propertyToFind);

		if(!interfaces.size())
		{
			g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.ObjectNotFound", "Property not found");
			return;
		}



		for(auto itr = interfaces.begin(); itr != interfaces.end(); itr++)
		{
			AbstractDBusInterface* t = *itr;
			if(t->zone() == (Zone::Type)zone)
			{
				g_dbus_method_invocation_return_value(invocation,g_variant_new("(o)", t->objectPath().c_str()));
				return;
			}
		}

		g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.ObjectNotFound", "Property not found");
	}

	else if (method == "ZonesForObjectName")
	{
		gchar* arg;

		g_variant_get(parameters,"(s)",&arg);

		std::string propertyToFind = arg;

		if(propertyToFind == "")
		{
			g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid argument.");
			return;
		}

		std::list<AbstractDBusInterface*> interfaces = AbstractDBusInterface::getObjectsForProperty(propertyToFind);

		if(!interfaces.size())
		{
			g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.ObjectNotFound", "Property not found");
			return;
		}

		GVariantBuilder params;
		g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);

		for(auto itr = interfaces.begin(); itr != interfaces.end(); itr++)
		{
			AbstractDBusInterface* t = *itr;
			GVariant *newvar = g_variant_new("i",t->zone());
			g_variant_builder_add_value(&params, newvar);

		}

		g_dbus_method_invocation_return_value(invocation,g_variant_new("(ai)",&params));
	}
	
	else if(method == "List")
	{
		std::list<AbstractDBusInterface*> list = AbstractDBusInterface::interfaces();

		if(!list.size())
		{
			g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.Error", "No supported objects");
			return;
		}

		GVariantBuilder builder;
		g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);


		for(auto itr = list.begin(); itr != list.end(); itr++)
		{
			if(!(*itr)->isSupported())
				continue;

			std::string objectName = (*itr)->objectName();

			g_variant_builder_add(&builder, "s", objectName.c_str());
		}


		g_dbus_method_invocation_return_value(invocation,g_variant_new("(as)",&builder));
	}

	g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR,G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method.");	
}