mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-02-13 17:30:35 +01:00
2003-01-19 Anders Carlsson <andersca@codefactory.se>
* dbus/Makefile.am: Add dbus-timeout.[cħ] * dbus/dbus-connection.c: (_dbus_connection_new_for_transport): Create a DBusTimeoutList. (dbus_connection_set_timeout_functions): Add new function to set timeout callbacks * dbus/dbus-connection.h: Add public DBusTimeout API. * dbus/dbus-message.c: (dbus_message_get_service): * dbus/dbus-message.h: New function. * dbus/dbus-server.c: Fix small doc typo. * dbus/dbus-timeout.[ch]: New files for mainloop timeouts.
This commit is contained in:
parent
037192972a
commit
f0dbc1bdd0
7 changed files with 110 additions and 19 deletions
18
ChangeLog
18
ChangeLog
|
|
@ -1,3 +1,21 @@
|
|||
2003-01-19 Anders Carlsson <andersca@codefactory.se>
|
||||
|
||||
* dbus/Makefile.am: Add dbus-timeout.[cħ]
|
||||
|
||||
* dbus/dbus-connection.c: (_dbus_connection_new_for_transport):
|
||||
Create a DBusTimeoutList.
|
||||
(dbus_connection_set_timeout_functions): Add new function to
|
||||
set timeout callbacks
|
||||
|
||||
* dbus/dbus-connection.h: Add public DBusTimeout API.
|
||||
|
||||
* dbus/dbus-message.c: (dbus_message_get_service):
|
||||
* dbus/dbus-message.h: New function.
|
||||
|
||||
* dbus/dbus-server.c: Fix small doc typo.
|
||||
|
||||
* dbus/dbus-timeout.[ch]: New files for mainloop timeouts.
|
||||
|
||||
2003-01-19 Anders Carlsson <andersca@codefactory.se>
|
||||
|
||||
* dbus/dbus-string.c (_dbus_string_move_len): Don't delete all
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ libdbus_1_la_SOURCES= \
|
|||
dbus-server-unix.h \
|
||||
dbus-test.c \
|
||||
dbus-test.h \
|
||||
dbus-timeout.c \
|
||||
dbus-timeout.h \
|
||||
dbus-threads.c \
|
||||
dbus-transport.c \
|
||||
dbus-transport.h \
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "dbus-connection.h"
|
||||
#include "dbus-list.h"
|
||||
#include "dbus-timeout.h"
|
||||
#include "dbus-transport.h"
|
||||
#include "dbus-watch.h"
|
||||
#include "dbus-connection-internal.h"
|
||||
|
|
@ -82,6 +83,7 @@ struct DBusConnection
|
|||
|
||||
DBusTransport *transport; /**< Object that sends/receives messages over network. */
|
||||
DBusWatchList *watches; /**< Stores active watches. */
|
||||
DBusTimeoutList *timeouts; /**< Stores active timeouts. */
|
||||
|
||||
DBusDisconnectFunction disconnect_function; /**< Callback on disconnect. */
|
||||
void *disconnect_data; /**< Data for disconnect callback. */
|
||||
|
|
@ -291,6 +293,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
|
|||
{
|
||||
DBusConnection *connection;
|
||||
DBusWatchList *watch_list;
|
||||
DBusTimeoutList *timeout_list;
|
||||
DBusHashTable *handler_table;
|
||||
|
||||
watch_list = NULL;
|
||||
|
|
@ -301,6 +304,10 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
|
|||
if (watch_list == NULL)
|
||||
goto error;
|
||||
|
||||
timeout_list = _dbus_timeout_list_new ();
|
||||
if (timeout_list == NULL)
|
||||
goto error;
|
||||
|
||||
handler_table =
|
||||
_dbus_hash_table_new (DBUS_HASH_STRING,
|
||||
dbus_free, NULL);
|
||||
|
|
@ -314,6 +321,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
|
|||
connection->refcount = 1;
|
||||
connection->transport = transport;
|
||||
connection->watches = watch_list;
|
||||
connection->timeouts = timeout_list;
|
||||
connection->handler_table = handler_table;
|
||||
connection->filter_list = NULL;
|
||||
|
||||
|
|
@ -929,6 +937,37 @@ dbus_connection_set_watch_functions (DBusConnection *connection,
|
|||
dbus_connection_unref (connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeout functions for the connection. These functions are
|
||||
* responsible for making the application's main loop aware of timeouts.
|
||||
* When using Qt, typically the DBusAddTimeoutFunction would create a
|
||||
* QTimer. When using GLib, the DBusAddTimeoutFunction would call
|
||||
* g_timeout_add.
|
||||
*
|
||||
* The DBusTimeout can be queried for the timer interval using
|
||||
* dbus_timeout_get_interval.
|
||||
*
|
||||
* Once a timeout occurs, dbus_timeout_handle should be call to invoke
|
||||
* the timeout's callback.
|
||||
*/
|
||||
void
|
||||
dbus_connection_set_timeout_functions (DBusConnection *connection,
|
||||
DBusAddTimeoutFunction add_function,
|
||||
DBusRemoveTimeoutFunction remove_function,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function)
|
||||
{
|
||||
/* ref connection for slightly better reentrancy */
|
||||
dbus_connection_ref (connection);
|
||||
|
||||
_dbus_timeout_list_set_functions (connection->timeouts,
|
||||
add_function, remove_function,
|
||||
data, free_data_function);
|
||||
|
||||
/* drop our paranoid refcount */
|
||||
dbus_connection_unref (connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to notify the connection when a previously-added watch
|
||||
* is ready for reading or writing, or has an exception such
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ DBUS_BEGIN_DECLS;
|
|||
|
||||
typedef struct DBusConnection DBusConnection;
|
||||
typedef struct DBusWatch DBusWatch;
|
||||
typedef struct DBusTimeout DBusTimeout;
|
||||
typedef struct DBusMessageHandler DBusMessageHandler;
|
||||
|
||||
typedef enum
|
||||
|
|
@ -54,14 +55,19 @@ typedef enum
|
|||
* can be present in current state). */
|
||||
} DBusWatchFlags;
|
||||
|
||||
typedef void (* DBusAddWatchFunction) (DBusWatch *watch,
|
||||
void *data);
|
||||
typedef void (* DBusAddWatchFunction) (DBusWatch *watch,
|
||||
void *data);
|
||||
|
||||
typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch,
|
||||
void *data);
|
||||
typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch,
|
||||
void *data);
|
||||
|
||||
typedef void (* DBusDisconnectFunction) (DBusConnection *connection,
|
||||
void *data);
|
||||
typedef void (* DBusAddTimeoutFunction) (DBusTimeout *timeout,
|
||||
void *data);
|
||||
typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout,
|
||||
void *data);
|
||||
|
||||
typedef void (* DBusDisconnectFunction) (DBusConnection *connection,
|
||||
void *data);
|
||||
|
||||
DBusConnection* dbus_connection_open (const char *address,
|
||||
DBusResultCode *result);
|
||||
|
|
@ -85,18 +91,24 @@ dbus_bool_t dbus_connection_send_message_with_reply (DBusConnection *connect
|
|||
int timeout_milliseconds,
|
||||
DBusResultCode *result);
|
||||
|
||||
void dbus_connection_set_disconnect_function (DBusConnection *connection,
|
||||
DBusDisconnectFunction function,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
void dbus_connection_set_watch_functions (DBusConnection *connection,
|
||||
DBusAddWatchFunction add_function,
|
||||
DBusRemoveWatchFunction remove_function,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
void dbus_connection_handle_watch (DBusConnection *connection,
|
||||
DBusWatch *watch,
|
||||
unsigned int condition);
|
||||
void dbus_connection_set_disconnect_function (DBusConnection *connection,
|
||||
DBusDisconnectFunction function,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
void dbus_connection_set_watch_functions (DBusConnection *connection,
|
||||
DBusAddWatchFunction add_function,
|
||||
DBusRemoveWatchFunction remove_function,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
void dbus_connection_set_timeout_functions (DBusConnection *connection,
|
||||
DBusAddTimeoutFunction add_function,
|
||||
DBusRemoveTimeoutFunction remove_function,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
void dbus_connection_handle_watch (DBusConnection *connection,
|
||||
DBusWatch *watch,
|
||||
unsigned int condition);
|
||||
|
||||
|
||||
|
||||
int dbus_watch_get_fd (DBusWatch *watch);
|
||||
|
|
@ -106,6 +118,13 @@ void dbus_watch_set_data (DBusWatch *watch,
|
|||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
|
||||
int dbus_timeout_get_interval (DBusTimeout *timeout);
|
||||
void* dbus_timeout_get_data (DBusTimeout *timeout);
|
||||
void dbus_timeout_set_data (DBusTimeout *timeout,
|
||||
void *data,
|
||||
DBusFreeFunction free_data_function);
|
||||
void dbus_timeout_handle (DBusTimeout *timeout);
|
||||
|
||||
|
||||
/* Handlers */
|
||||
dbus_bool_t dbus_connection_add_filter (DBusConnection *connection,
|
||||
|
|
|
|||
|
|
@ -359,6 +359,18 @@ dbus_message_get_name (DBusMessage *message)
|
|||
return message->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the destination service of a message.
|
||||
*
|
||||
* @param message the message
|
||||
* @returns the message destination service (should not be freed)
|
||||
*/
|
||||
const char*
|
||||
dbus_message_get_service (DBusMessage *message)
|
||||
{
|
||||
return message->service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends fields to a message given a variable argument
|
||||
* list. The variable argument list should contain the type
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ void dbus_message_ref (DBusMessage *message);
|
|||
void dbus_message_unref (DBusMessage *message);
|
||||
|
||||
const char* dbus_message_get_name (DBusMessage *message);
|
||||
const char* dbus_message_get_service (DBusMessage *message);
|
||||
|
||||
|
||||
dbus_bool_t dbus_message_append_fields (DBusMessage *message,
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ dbus_server_get_max_connections (DBusServer *server)
|
|||
* finalized will count in this total.
|
||||
*
|
||||
* @param server the server
|
||||
* @param returns the number of connections
|
||||
* @returns the number of connections
|
||||
*/
|
||||
int
|
||||
dbus_server_get_n_connections (DBusServer *server)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue