forked from enlightenment/efl
Beginning of dbus testing. DBus needs a lot of love.
SVN revision: 24077
This commit is contained in:
parent
942012e29d
commit
ea27a9b53b
|
@ -54,6 +54,12 @@ else
|
|||
ECORE_CONFIG_LIB =
|
||||
endif
|
||||
|
||||
if BUILD_ECORE_DBUS
|
||||
ECORE_DBUS_LIB = $(top_builddir)/src/lib/ecore_dbus/libecore_dbus.la
|
||||
else
|
||||
ECORE_DBUS_LIB =
|
||||
endif
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/src/lib/ecore \
|
||||
-I$(top_srcdir)/src/lib/ecore_evas \
|
||||
|
@ -65,6 +71,7 @@ INCLUDES = \
|
|||
-I$(top_srcdir)/src/lib/ecore_ipc \
|
||||
-I$(top_srcdir)/src/lib/ecore_txt @iconv_cflags@ \
|
||||
-I$(top_srcdir)/src/lib/ecore_config \
|
||||
-I$(top_srcdir)/src/lib/ecore_dbus \
|
||||
-I$(top_builddir)/src/lib/ecore \
|
||||
-I$(top_builddir)/src/lib/ecore_evas \
|
||||
-I$(top_builddir)/src/lib/ecore_directfb \
|
||||
|
@ -75,6 +82,7 @@ INCLUDES = \
|
|||
-I$(top_builddir)/src/lib/ecore_ipc \
|
||||
-I$(top_builddir)/src/lib/ecore_txt @iconv_cflags@ \
|
||||
-I$(top_builddir)/src/lib/ecore_config \
|
||||
-I$(top_builddir)/src/lib/ecore_dbus \
|
||||
@EVAS_CFLAGS@ \
|
||||
@x_cflags@ \
|
||||
@EET_CFLAGS@ \
|
||||
|
@ -85,7 +93,8 @@ INCLUDES = \
|
|||
bin_PROGRAMS = \
|
||||
ecore_test \
|
||||
ecore_evas_test \
|
||||
ecore_config
|
||||
ecore_config \
|
||||
ecore_dbus_test
|
||||
|
||||
ecore_test_SOURCES = \
|
||||
ecore_test.c
|
||||
|
@ -157,3 +166,19 @@ ecore_config_DEPENDENCIES = \
|
|||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(ECORE_CONFIG_LIB)
|
||||
|
||||
ecore_dbus_test_SOURCES = \
|
||||
ecore_dbus_test.c \
|
||||
ecore_dbus_test.h
|
||||
|
||||
ecore_dbus_test_LDADD = \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(ECORE_DBUS_LIB)
|
||||
|
||||
ecore_dbus_test_CFLAGS = \
|
||||
$(CFLAGS) \
|
||||
$(INCLUDES)
|
||||
|
||||
ecore_dbus_test_DEPENDENCIES = \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(ECORE_DBUS_LIB)
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "ecore_dbus_test.h"
|
||||
|
||||
#ifdef BUILD_ECORE_DBUS
|
||||
|
||||
static int _ecore_dbus_event_server_add(void *udata, int ev_type, void *ev);
|
||||
static int _ecore_dbus_event_server_del(void *udata, int ev_type, void *ev);
|
||||
static int _ecore_dbus_event_server_data(void *udata, int ev_type, void *ev);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Ecore_DBus_Server *svr;
|
||||
|
||||
ecore_dbus_init();
|
||||
svr = ecore_dbus_server_connect(ECORE_DBUS_BUS_SYSTEM,
|
||||
"/var/run/dbus/system_dbus_socket", -1, NULL);
|
||||
if (!svr)
|
||||
{
|
||||
printf("Couldn't connect to dbus system server!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
Ecore_Event_Handler *handler[3];
|
||||
|
||||
printf("Connected!\n");
|
||||
|
||||
handler[i++] = ecore_event_handler_add(ECORE_DBUS_EVENT_SERVER_ADD,
|
||||
_ecore_dbus_event_server_add, NULL);
|
||||
handler[i++] = ecore_event_handler_add(ECORE_DBUS_EVENT_SERVER_DEL,
|
||||
_ecore_dbus_event_server_del, NULL);
|
||||
handler[i++] = ecore_event_handler_add(ECORE_DBUS_EVENT_SERVER_DATA,
|
||||
_ecore_dbus_event_server_data, NULL);
|
||||
|
||||
/*
|
||||
ret = ecore_dbus_message_new_method_call(svr, "org.freedesktop.DBus.Hello",
|
||||
NULL, NULL, NULL, NULL);
|
||||
*/
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
ecore_event_handler_del(handler[i]);
|
||||
|
||||
ecore_dbus_server_del(svr);
|
||||
}
|
||||
ecore_dbus_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_ecore_dbus_event_server_add(void *udata, int ev_type, void *ev)
|
||||
{
|
||||
Ecore_DBus_Event_Server_Add *event;
|
||||
int ret;
|
||||
|
||||
event = ev;
|
||||
printf("_ecore_dbus_event_server_add\n");
|
||||
ret = ecore_dbus_message_new_method_call(event->server, "org.freedesktop.DBus" /*service*/,
|
||||
"/org/freedesktop/DBus" /*path*/,
|
||||
"org.freedesktop.DBus" /*interface*/,
|
||||
"Hello" /*method*/, NULL /*fmt*/);
|
||||
printf("ret: %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_ecore_dbus_event_server_del(void *udata, int ev_type, void *ev)
|
||||
{
|
||||
Ecore_DBus_Event_Server_Del *event;
|
||||
|
||||
event = ev;
|
||||
printf("_ecore_dbus_event_server_del\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_ecore_dbus_event_server_data(void *udata, int ev_type, void *ev)
|
||||
{
|
||||
Ecore_DBus_Event_Server_Data *event;
|
||||
|
||||
event = ev;
|
||||
printf("_ecore_dbus_event_server_data\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifndef _ECORE_DBUS_TEST_H
|
||||
#define _ECORE_DBUS_TEST_H
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef BUILD_ECORE_DBUS
|
||||
#include "Ecore.h"
|
||||
#include "Ecore_DBus.h"
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -210,13 +210,15 @@ ecore_dbus_server_connect(Ecore_DBus_Type compl_type, char *name, int port,
|
|||
type = compl_type;
|
||||
switch (type)
|
||||
{
|
||||
#if 0
|
||||
case ECORE_DBUS_BUS_SESSION:
|
||||
svr->server =
|
||||
ecore_con_server_connect(ECORE_CON_LOCAL_USER | extra, name, port, svr);
|
||||
break;
|
||||
#endif
|
||||
case ECORE_DBUS_BUS_SYSTEM:
|
||||
svr->server =
|
||||
ecore_con_server_connect(ECORE_CON_LOCAL_USER | extra, name, port, svr);
|
||||
ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM | extra, name, port, svr);
|
||||
break;
|
||||
default:
|
||||
free(svr);
|
||||
|
@ -317,53 +319,56 @@ ecore_dbus_message_new_method_call(Ecore_DBus_Server *svr, char *service,
|
|||
/* header length */
|
||||
*(msg->header + 4) = msg->hlength = msg->hpos;
|
||||
/* message body */
|
||||
va_start(ap, fmt);
|
||||
while (*fmt)
|
||||
if (fmt)
|
||||
{
|
||||
switch (*fmt)
|
||||
va_start(ap, fmt);
|
||||
while (*fmt)
|
||||
{
|
||||
case ECORE_DBUS_DATA_TYPE_BYTE:
|
||||
f = _ecore_dbus_message_marshal_byte(&msg->body, &msg->bpos,
|
||||
va_arg(ap, int));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_UINT32:
|
||||
f = _ecore_dbus_message_marshal_uint32(&msg->body, &msg->bpos,
|
||||
va_arg(ap, unsigned long));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_STRING:
|
||||
f = _ecore_dbus_message_marshal_string(&msg->body, &msg->bpos,
|
||||
(char *)va_arg(ap, char *));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_OBJECT_PATH:
|
||||
f = _ecore_dbus_message_marshal_object_path(&msg->body, &msg->bpos,
|
||||
switch (*fmt)
|
||||
{
|
||||
case ECORE_DBUS_DATA_TYPE_BYTE:
|
||||
f = _ecore_dbus_message_marshal_byte(&msg->body, &msg->bpos,
|
||||
va_arg(ap, int));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_UINT32:
|
||||
f = _ecore_dbus_message_marshal_uint32(&msg->body, &msg->bpos,
|
||||
va_arg(ap, unsigned long));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_STRING:
|
||||
f = _ecore_dbus_message_marshal_string(&msg->body, &msg->bpos,
|
||||
(char *)va_arg(ap, char *));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_INT32:
|
||||
case ECORE_DBUS_DATA_TYPE_BOOLEAN:
|
||||
case ECORE_DBUS_DATA_TYPE_INT64:
|
||||
case ECORE_DBUS_DATA_TYPE_UINT64:
|
||||
case ECORE_DBUS_DATA_TYPE_DOUBLE:
|
||||
case ECORE_DBUS_DATA_TYPE_ARRAY:
|
||||
case ECORE_DBUS_DATA_TYPE_DICT_ENTRY:
|
||||
case ECORE_DBUS_DATA_TYPE_INVALID:
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_OBJECT_PATH:
|
||||
f = _ecore_dbus_message_marshal_object_path(&msg->body, &msg->bpos,
|
||||
(char *)va_arg(ap, char *));
|
||||
msg->body_fields = _ecore_list2_append(msg->body_fields, f);
|
||||
break;
|
||||
case ECORE_DBUS_DATA_TYPE_INT32:
|
||||
case ECORE_DBUS_DATA_TYPE_BOOLEAN:
|
||||
case ECORE_DBUS_DATA_TYPE_INT64:
|
||||
case ECORE_DBUS_DATA_TYPE_UINT64:
|
||||
case ECORE_DBUS_DATA_TYPE_DOUBLE:
|
||||
case ECORE_DBUS_DATA_TYPE_ARRAY:
|
||||
case ECORE_DBUS_DATA_TYPE_DICT_ENTRY:
|
||||
case ECORE_DBUS_DATA_TYPE_INVALID:
|
||||
#if 0
|
||||
default:
|
||||
default:
|
||||
#endif
|
||||
printf("[ecore_dbus] unknown/unhandled data type %c\n", *fmt);
|
||||
break;
|
||||
printf("[ecore_dbus] unknown/unhandled data type %c\n", *fmt);
|
||||
break;
|
||||
}
|
||||
fmt++;
|
||||
}
|
||||
fmt++;
|
||||
va_end(ap);
|
||||
}
|
||||
va_end(ap);
|
||||
*(unsigned int *)(msg->header + 8) = msg->blength = msg->bpos;
|
||||
/* show message */
|
||||
/*ecore_dbus_message_print(msg);
|
||||
* _ecore_dbus_message_print_raw(msg->header,msg->hlength);
|
||||
* _ecore_dbus_message_print_raw(msg->body,msg->blength); */
|
||||
* _ecore_dbus_message_print_raw(msg->header, msg->hlength);
|
||||
* _ecore_dbus_message_print_raw(msg->body, msg->blength); */
|
||||
/* send message */
|
||||
ecore_dbus_server_send(svr, (char *)msg->header, msg->hlength);
|
||||
if (msg->body)
|
||||
|
@ -1144,7 +1149,7 @@ _ecore_dbus_event_server_data(void *udata, int ev_type, void *ev)
|
|||
}
|
||||
else if (!strncmp(e->data, "DATA", 4))
|
||||
{
|
||||
printf("[ecore_dbus] requering data (unaivable)\n");
|
||||
printf("[ecore_dbus] requiring data (unavailable)\n");
|
||||
}
|
||||
else if (!strncmp(e->data, "ERROR", 5))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue