#include "glib/gstdio.h"
#include "gsocketcontrolmessage.h"
#include "gsocketconnection.h"
-#include "gkdbusconnection.h"
#include "gsocketoutputstream.h"
#ifdef G_OS_UNIX
#include "gunixfdmessage.h"
#include "gunixconnection.h"
+#include "gkdbusconnection.h"
#include "gunixcredentialsmessage.h"
#endif
gpointer user_data)
{
ReadKdbusData *data;
+ GSource *source;
data = g_new0 (ReadKdbusData, 1);
data->kdbus = kdbus; /*g_object_ref (socket);*/
_g_kdbus_read);
g_simple_async_result_set_check_cancellable (data->simple, cancellable);
- if (!g_kdbus_condition_check (kdbus, G_IO_IN))
- {
- GSource *source;
- data->from_mainloop = TRUE;
- source = g_kdbus_create_source (data->kdbus,
- G_IO_IN | G_IO_HUP | G_IO_ERR,
- cancellable);
- g_source_set_callback (source,
- (GSourceFunc) _g_kdbus_read_ready,
- data,
- (GDestroyNotify) read_kdbus_data_free);
- g_source_attach (source, g_main_context_get_thread_default ());
- g_source_unref (source);
- }
- else
- {
- _g_kdbus_read_ready (data->kdbus, G_IO_IN, data);
- read_kdbus_data_free (data);
- }
+ data->from_mainloop = TRUE;
+ source = g_kdbus_create_source (data->kdbus,
+ G_IO_IN | G_IO_HUP | G_IO_ERR,
+ cancellable);
+ g_source_set_callback (source,
+ (GSourceFunc) _g_kdbus_read_ready,
+ data,
+ (GDestroyNotify) read_kdbus_data_free);
+ g_source_attach (source, g_main_context_get_thread_default ());
+ g_source_unref (source);
}
static void
read_message_print_transport_debug (bytes_read, worker);
worker->read_buffer_cur_size += bytes_read;
+
+ /* TODO: [KDBUS] Sprawdzic pole read_buffer_bytes_wanted */
+ if (G_IS_KDBUS_CONNECTION (worker->stream))
+ worker->read_buffer_bytes_wanted = worker->read_buffer_cur_size;
+
if (worker->read_buffer_bytes_wanted == worker->read_buffer_cur_size)
{
/* OK, got what we asked for! */
if (G_IS_KDBUS_CONNECTION (worker->stream))
{
- //GError *error;
- //error = NULL;
-
-
_g_kdbus_read(worker->kdbus,
worker->read_buffer,
worker->read_buffer_bytes_wanted,
static gboolean
_g_dbus_worker_do_initial_read (gpointer data)
{
- //GDBusWorker *worker = data;
- //g_mutex_lock (&worker->read_lock);
- //_g_dbus_worker_do_read_unlocked (worker);
- //g_mutex_unlock (&worker->read_lock);
+ GDBusWorker *worker = data;
+ g_mutex_lock (&worker->read_lock);
+ _g_dbus_worker_do_read_unlocked (worker);
+ g_mutex_unlock (&worker->read_lock);
return FALSE;
}
GError *error;
error = NULL;
data->total_written = g_kdbus_send_message(data->worker, data->worker->kdbus, data->message, data->blob, data->blob_size, &error);
-
- if (data->total_written == data->blob_size)
- {
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- goto out;
- }
+
+ write_message_print_transport_debug (data->total_written, data);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ goto out;
}
else
{
}
/* ---------------------------------------------------------------------------------------------------- */
-GKdbus* g_dbus_worker_get_kdbus (GDBusWorker *worker)
-{
- return worker->kdbus;
-}
GDBusWorker *
_g_dbus_worker_new (GIOStream *stream,
g_print ("========================================================================\n"
"GDBus-debug:Transport:\n"
" >>>> WROTE %" G_GSIZE_FORMAT " bytes of message with serial %d and\n"
- " size %" G_GSIZE_FORMAT " from offset %" G_GSIZE_FORMAT " on a %s\n",
+ " size %" G_GSIZE_FORMAT " from offset %" G_GSIZE_FORMAT "\n",
bytes_written,
g_dbus_message_get_serial (data->message),
data->blob_size,
- data->total_written,
- g_type_name (G_TYPE_FROM_INSTANCE (g_io_stream_get_output_stream (data->worker->stream))));
+ data->total_written);
_g_dbus_debug_print_unlock ();
out:
;
g_print ("========================================================================\n"
"GDBus-debug:Transport:\n"
" <<<< READ %" G_GSIZE_FORMAT " bytes of message with serial %d and\n"
- " size %d to offset %" G_GSIZE_FORMAT " from a %s\n",
+ " size %d to offset %" G_GSIZE_FORMAT "\n",
bytes_read,
serial,
message_length,
- worker->read_buffer_cur_size,
- g_type_name (G_TYPE_FROM_INSTANCE (g_io_stream_get_input_stream (worker->stream))));
+ worker->read_buffer_cur_size);
_g_dbus_debug_print_unlock ();
out:
;