if(bus_address == NULL)
goto failed;
- server = fake_server(bus_address);
+ server = empty_server_init(bus_address);
if(server == NULL)
{
free(bus_address);
context->myConnection = daemon_as_client(type, bus_address, error);
if(context->myConnection == NULL)
goto failed;
-
- if(!setup_connection(context, error))
- goto failed;
}
else
{
dbus_server_free_data_slot (&server_data_slot);
+ if(context->myConnection)
+ {
+ DBusString unique_name;
+
+ bus_connections_setup_connection(context->connections, context->myConnection);
+ _dbus_string_init_const(&unique_name, ":1.1");
+ if(!bus_connection_complete(context->myConnection, &unique_name, error))
+ {
+ _dbus_verbose ("bus connection complete failed\n");
+ }
+ }
+
return context;
failed:
#include <dbus/kdbus.h>
#include <dbus/dbus-connection-internal.h>
#include <dbus/dbus-bus.h>
+#include "dispatch.h"
#include <utils.h>
#include <stdlib.h>
return bus;
}
-DBusServer* fake_server(char* address)
+DBusServer* empty_server_init(char* address)
{
return dbus_server_init_mini(address);
}
return connection;
}
-
-dbus_bool_t setup_connection(BusContext* context, DBusError* error)
-{
- //on the basis of bus_connections_setup_connection from connection.c
-
- dbus_bool_t retval = FALSE; //todo opitimize
-// DBusConnection* connection;
-
- //todo what to do with error
-
-/* connection = context->myConnection; //todo
- dbus_connection_set_route_peer_messages (connection, TRUE);
-
- if (!dbus_connection_set_watch_functions (connection,
- add_connection_watch,
- remove_connection_watch,
- toggle_connection_watch,
- connection,
- NULL))
- goto out;
-
- if (!dbus_connection_set_timeout_functions (connection,
- add_connection_timeout,
- remove_connection_timeout,
- NULL,
- connection, NULL))
- goto out;
-
- dbus_connection_set_dispatch_status_function (connection,
- dispatch_status_function,
- bus_context_get_loop (context),
- NULL);
-
- if (!bus_dispatch_add_connection (connection))
- goto out;
-
- retval = TRUE;
-
- out:
- if (!retval)
- {
- if (!dbus_connection_set_watch_functions (connection,
- NULL, NULL, NULL,
- connection,
- NULL))
- _dbus_assert_not_reached ("setting watch functions to NULL failed");
-
- if (!dbus_connection_set_timeout_functions (connection,
- NULL, NULL, NULL,
- connection,
- NULL))
- _dbus_assert_not_reached ("setting timeout functions to NULL failed");
-
-
- dbus_connection_set_dispatch_status_function (connection,
- NULL, NULL, NULL);
- }
-*/
- return retval;
-}
#include <dbus/dbus-server.h>
char* make_kdbus_bus(DBusBusType type, DBusError *error);
-DBusServer* fake_server(char* address);
+DBusServer* empty_server_init(char* address);
DBusConnection* daemon_as_client(DBusBusType type, char* address, DBusError *error);
-dbus_bool_t setup_connection(BusContext* context, DBusError* error);
-
#endif /* KDBUS_H_ */
{
pCmd = realloc(pCmd, cmd_size); //prepare memory
if(pCmd == NULL)
- return FALSE;
+ return -1;
goto again; //and try again
}
else
{
DBusMessage *reply;
- DBusMessageIter args;
+ DBusMessageIter iter, sub;
struct kdbus_cmd_name* pCmd_name;
char* pName;
if(reply == NULL)
goto out;
dbus_message_set_sender(reply, DBUS_SERVICE_DBUS);
- dbus_message_iter_init_append(reply, &args);
-
+ dbus_message_iter_init_append(reply, &iter);
+ if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &sub))
+ {
+ dbus_message_unref(reply);
+ goto out;
+ }
for (pCmd_name = pCmd->names; (uint8_t *)(pCmd_name) < (uint8_t *)(pCmd) + pCmd->size; pCmd_name = KDBUS_PART_NEXT(pCmd_name))
{
pName = pCmd_name->name;
- if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &pName))
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &pName))
{
dbus_message_unref(reply);
goto out;
}
}
- if(add_message_to_received(reply, transport->connection))
+ if (!dbus_message_iter_close_container (&iter, &sub))
{
- free(pCmd);
- return TRUE;
+ dbus_message_unref (reply);
+ goto out;
}
+
+ if(add_message_to_received(reply, transport->connection))
+ ret_value = 0;
}
out:
if(pCmd)
free(pCmd);
- return FALSE;
+ return ret_value;
}
else if(!strcmp(dbus_message_get_member(message), "GetId"))
{
MD5_CTX md5;
DBusString binary, encoded;
- ret_value = FALSE;
path = &transport->address[11]; //start of kdbus bus path
if(stat(path, &stats) < -1)
{
{
DBusMessage *reply;
- ret_value = FALSE;
reply = dbus_message_new_method_return(message);
if(reply != NULL)
{
if (!dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &info.sec_label, info.sec_label_len, DBUS_TYPE_INVALID))
dbus_message_unref(reply);
else if(add_message_to_received(reply, transport->connection))
- ret_value = TRUE;
+ ret_value = 0;
}
}
}
else
- return reply_with_error(DBUS_ERROR_UNKNOWN_METHOD, NULL, (char*)dbus_message_get_member(message), message, transport->connection);
+ return 1; //send to daemon
+// return reply_with_error(DBUS_ERROR_UNKNOWN_METHOD, NULL, (char*)dbus_message_get_member(message), message, transport->connection);
/* else if(!strcmp(dbus_message_get_member(message), "ListActivatableNames")) //todo
{