sssd_dbus_server.c revision 8b8210c79b297b87e56d068e8839f7fe6755ab15
/*
SSSD
Service monitor - D-BUS features
Copyright (C) Stephen Gallagher 2008
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "events.h"
#include "dbus/sssd_dbus.h"
#include "dbus/sssd_dbus_private.h"
/* Types */
struct sbus_srv_ctx {
/*
* sd_ctx here describes the object path that will be
* presented to all clients of this server. Additional
* connection-specific paths can be specified by the
* init_fn, which is called every time a new connection
* is established.
* There should only be one global object path (for
* simplicity's sake)
*/
struct event_context *ev;
struct sbus_method_ctx *sd_ctx;
};
struct sbus_srv_watch_ctx {
int fd;
struct sbus_srv_ctx *top;
};
struct dbus_srv_timeout_ctx {
struct timed_event *te;
struct sbus_srv_ctx *top;
};
static int sbus_server_destructor(void **server);
/*
* dbus_server_read_write_handler
* Callback for D-BUS to handle messages on a file-descriptor
*/
{
struct sbus_srv_watch_ctx *svw_ctx;
if (flags & EVENT_FD_READ) {
}
if (flags & EVENT_FD_WRITE) {
}
}
/*
* add_server_watch
* Set up hooks into the libevents mainloop for
* D-BUS to add file descriptor-based events
*/
{
unsigned int flags;
unsigned int event_flags;
struct sbus_srv_ctx *dt_ctx;
struct sbus_srv_watch_ctx *svw_ctx;
if (!dbus_watch_get_enabled(watch)) {
return FALSE;
}
event_flags = 0;
if (flags & DBUS_WATCH_READABLE) {
}
if (flags & DBUS_WATCH_WRITABLE) {
}
DEBUG(2,("%lX: %d, %d=%s\n", watch, svw_ctx->fd, event_flags, event_flags==EVENT_FD_READ?"READ":"WRITE"));
svw_ctx);
/* Save the event to the watch object so it can be removed later */
return TRUE;
}
/*
* server_watch_toggled
* an event in the mainloop
*/
{
if (dbus_watch_get_enabled(watch)) {
} else {
}
}
struct timed_event *te,
{
struct dbus_srv_timeout_ctx *svt_ctx;
}
/*
* add_server_timeout
* Hook for D-BUS to add time-based events to the mainloop
*/
{
struct sbus_srv_ctx *dt_ctx;
struct dbus_srv_timeout_ctx *svt_ctx;
if (!dbus_timeout_get_enabled(timeout))
return TRUE;
/* Save the event to the watch object so it can be removed later */
return TRUE;
}
/*
* server_timeout_toggled
* event
*/
{
if (dbus_timeout_get_enabled(timeout)) {
} else {
}
}
/*
* new_connection_callback
* Actions to be run upon each new client connection
* Must either perform dbus_connection_ref() on the
* new connection or else close the connection with
* dbus_connection_close()
*/
void *data)
{
struct sbus_srv_ctx *dst_ctx;
struct sbus_conn_ctx *dct_ctx;
struct sbus_method_ctx *iter;
/*DBusObjectPathVTable *connection_vtable;*/
int ret;
DEBUG(0,("Entering.\n"));
return;
}
if (ret != 0) {
DEBUG(0,("Closing connection (failed setup)"));
return;
}
/* Set up global methods */
}
/*
* Initialize connection-specific features
* This may set a more detailed destructor, but
* the default destructor will always be chained
* to handle connection cleanup.
* This function (or its callbacks) should also
* set up connection-specific methods.
*/
}
/*
* dbus_new_server
* Set up a D-BUS server, integrate with the event loop
* for handling file descriptor and timed events
*/
int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, const char *address, sbus_server_conn_init_fn init_fn)
{
struct sbus_srv_ctx *dst_ctx;
/* Set up D-BUS server */
if (!dbus_server) {
DEBUG(0,("dbus_server_listen failed! (name=%s, message=%s)\n",
return EIO;
}
if (!dst_ctx) {
return ENOMEM;
}
/* Set up D-BUS new connection handler */
/* Set up DBusWatch functions */
if (!dbret) {
DEBUG(0, ("Error setting up D-BUS server watch functions"));
return EIO;
}
/* Set up DBusTimeout functions */
if (!dbret) {
DEBUG(0,("Error setting up D-BUS server timeout functions"));
return EIO;
}
return EOK;
}
static int sbus_server_destructor(void **server) {
return 0;
}