diff options
author | Søren Sandmann Pedersen <ssp@localhost.(none)> | 2008-10-10 20:45:40 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@localhost.(none)> | 2008-10-10 20:45:40 -0400 |
commit | 7b8b09f2a3108653b31476c60032301854014513 (patch) | |
tree | 00a7d0a2bcdf853b96f39fc7cdeb981168be3ffc | |
parent | 2befa55b0eefdfa6bf243c536b71d2875f0e005b (diff) |
Put dbw functions into nul namespace
-rw-r--r-- | dbw-example.c | 76 | ||||
-rw-r--r-- | dbw.c | 40 | ||||
-rw-r--r-- | libnul.h | 94 |
3 files changed, 105 insertions, 105 deletions
diff --git a/dbw-example.c b/dbw-example.c index cf63372..0dc245d 100644 --- a/dbw-example.c +++ b/dbw-example.c @@ -5,7 +5,7 @@ /* This may be a better way of doing it */ /* Better: * - * dbw_return + * nul_dbus_return */ static gboolean @@ -15,7 +15,7 @@ on_do_stuff (DbwContext *context, int32_t birnan, uint32_t fish, gpointer data) x = g_strdup_printf ("asdf frasdf %d", fish); - dbw_return (context, "Birnan was", x); + nul_dbus_return (context, "Birnan was", x); g_free (x); @@ -55,29 +55,29 @@ load_image (gpointer data, const char *image, int *result) static DbwService * make_service1 (void) { - return dbw_session_service ( + return nul_dbus_session_service ( "com.ssp.whatever", - dbw_object ( + nul_dbus_object ( "/com/ssp/whatever/birnan/emfle", "object_info", - dbw_interface ( + nul_dbus_interface ( "com.ssp.interface", - dbw_method ( + nul_dbus_method ( "do_stuff", (DbwFunction)on_do_stuff, - dbw_parameter_in ("birnan", dbw_type_int32()), - dbw_parameter_in ("fish", dbw_type_uint32()), - dbw_parameter_out ("emfle", dbw_type_string()), - dbw_parameter_out ("str", dbw_type_string()), + nul_dbus_parameter_in ("birnan", nul_dbus_type_int32()), + nul_dbus_parameter_in ("fish", nul_dbus_type_uint32()), + nul_dbus_parameter_out ("emfle", nul_dbus_type_string()), + nul_dbus_parameter_out ("str", nul_dbus_type_string()), NULL), - dbw_method ( + nul_dbus_method ( "another_method", (DbwFunction)on_another_method, - dbw_parameter_in ("n_times", dbw_type_uint32()), + nul_dbus_parameter_in ("n_times", nul_dbus_type_uint32()), NULL), NULL), @@ -90,21 +90,21 @@ make_service1 (void) static DbwService * make_service2 (void) { - return dbw_session_service ( + return nul_dbus_session_service ( "org.gnome.siv", - dbw_object ( + nul_dbus_object ( "/org/gnome/siv", NULL, - dbw_interface ( + nul_dbus_interface ( "org.gnome.siv", - dbw_method ( + nul_dbus_method ( "load_image", (DbwFunction)load_image, - dbw_parameter_in ("image", dbw_type_string()), - dbw_parameter_out ("result", dbw_type_int32()), + nul_dbus_parameter_in ("image", nul_dbus_type_string()), + nul_dbus_parameter_out ("result", nul_dbus_type_int32()), NULL), NULL), @@ -128,7 +128,7 @@ on_reply (int result, const GError *err, DbwService *service) else g_print ("An error occurred\n"); - dbw_invoke (service, + nul_dbus_invoke (service, "/com/ssp/whatever/birnan/emfle/com.ssp.interface.do_stuff", (DbwFunction)on_do_stuff_reply, NULL, 100, 200); @@ -147,13 +147,13 @@ invokes (gpointer data) for (i = 0; i < 30000; ++i) { #if 0 - dbw_service_stop (service); - dbw_service_start (service); - dbw_service_stop (service); - dbw_service_start (service); + nul_dbus_service_stop (service); + nul_dbus_service_start (service); + nul_dbus_service_stop (service); + nul_dbus_service_start (service); #endif - dbw_invoke (service2, + nul_dbus_invoke (service2, "/org/gnome/siv/org.gnome.siv.load_image", (DbwFunction)on_reply, service, "LOLCAT.PNG"); @@ -170,12 +170,12 @@ main () service = make_service1 (); service2 = make_service2 (); - if (!dbw_service_start (service2)) + if (!nul_dbus_service_start (service2)) { g_print ("siv already exists, asking it to load the images instead\n"); } - if (!dbw_service_start (service)) + if (!nul_dbus_service_start (service)) { g_print ("Couldn't start the service\n"); } @@ -192,25 +192,25 @@ main () void bah() { - DbwService *service = dbw_session_service ( + DbwService *service = nul_dbus_session_service ( "org.gnome.ScreenSaver", - dbw_object ( + nul_dbus_object ( "/", - dbw_interface ( + nul_dbus_interface ( "org.gnome.ScreenSaver", - dbw_method ( + nul_dbus_method ( "Throttle", NULL, NULL, - dbw_parameter_in ("application", dbw_type_string()), - dbw_parameter_in ("reason", dbw_type_string()), - dbw_parameter_out ("cookie", dbw_type_uint32()), + nul_dbus_parameter_in ("application", nul_dbus_type_string()), + nul_dbus_parameter_in ("reason", nul_dbus_type_string()), + nul_dbus_parameter_out ("cookie", nul_dbus_type_uint32()), NULL), - dbw_signal ( + nul_dbus_signal ( "ActiveChanged", - dbw_parameter_in ("new_value", dbw_type_bool()), + nul_dbus_parameter_in ("new_value", nul_dbus_type_bool()), NULL), NULL), @@ -219,15 +219,15 @@ bah() NULL); - dbw_invoke (service, "/org.gnome.ScreenSaver.Throttle", reponse, NULL, + nul_dbus_invoke (service, "/org.gnome.ScreenSaver.Throttle", reponse, NULL, "MyApplication", "None of your business"); - if (!dbw_invoke_wait (service, "/org.gnome.ScreenSaver.Throttle", 1000, &err, + if (!nul_dbus_invoke_wait (service, "/org.gnome.ScreenSaver.Throttle", 1000, &err, "MyApplication", "None of your business", &cookie)) { g_print ("timeout\n"); } - dbw_connect (service, "/org.gnome.ScreenSaver.ActiveChanged", on_active_changed, data); + nul_dbus_connect (service, "/org.gnome.ScreenSaver.ActiveChanged", on_active_changed, data); } #endif @@ -512,7 +512,7 @@ encode_message (DBusMessage *message, * passed in by the user. Maybe we should just make the * user idle_free it. * - * Even better actually: Have a dbw_return (...) that + * Even better actually: Have a nul_dbus_return (...) that * the user is expected to call. */ g_free (args[i].v_pointer); @@ -723,7 +723,7 @@ make_service (const char *name, } DbwService * -dbw_session_service (const char *name, +nul_dbus_session_service (const char *name, DbwObject *object1, ...) { @@ -740,7 +740,7 @@ dbw_session_service (const char *name, } gboolean -dbw_service_start (DbwService *service) +nul_dbus_service_start (DbwService *service) { DBusError err = DBUS_ERROR_INIT; int i; @@ -801,7 +801,7 @@ dbw_service_start (DbwService *service) } void -dbw_service_stop (DbwService *service) +nul_dbus_service_stop (DbwService *service) { int i; @@ -822,7 +822,7 @@ dbw_service_stop (DbwService *service) } DbwObject * -dbw_object (const char *name, +nul_dbus_object (const char *name, gpointer data, DbwInterface *interface1, ...) @@ -843,14 +843,14 @@ dbw_object (const char *name, * still add it here so that introspection can treat the introspection * interface as any other interface */ - g_ptr_array_add (object->interfaces, dbw_interface ( + g_ptr_array_add (object->interfaces, nul_dbus_interface ( "org.freedesktop.DBus.Introspectable", - dbw_method ( + nul_dbus_method ( "Introspect", (DbwFunction)NULL, - dbw_parameter_out ( + nul_dbus_parameter_out ( "data", - dbw_type_string()), + nul_dbus_type_string()), NULL), NULL)); @@ -858,7 +858,7 @@ dbw_object (const char *name, } DbwInterface * -dbw_interface (const char *name, +nul_dbus_interface (const char *name, DbwMember *member1, ...) { @@ -893,7 +893,7 @@ type_copy (const DbwType *type) } static nul_type_t -invoke_type_from_dbw_type (DbwType *t) +invoke_type_from_nul_dbus_type (DbwType *t) { switch (t->type) { @@ -925,7 +925,7 @@ make_fun_def (DbwMember *member) if (par->out) types[i] = NUL_TYPE_POINTER; else - types[i] = invoke_type_from_dbw_type (par->type); + types[i] = invoke_type_from_nul_dbus_type (par->type); } return nul_fun_def_new (NUL_TYPE_INT, @@ -947,7 +947,7 @@ make_reply_fun (DbwMember *member) DbwParameter *par = member->parameters->pdata[i]; if (par->out) - types[n++] = invoke_type_from_dbw_type (par->type); + types[n++] = invoke_type_from_nul_dbus_type (par->type); } types[n++] = NUL_TYPE_POINTER; /* data */ @@ -957,7 +957,7 @@ make_reply_fun (DbwMember *member) } DbwMember * -dbw_method (const char *name, +nul_dbus_method (const char *name, DbwFunction function, DbwParameter *parameter1, ...) @@ -1016,14 +1016,14 @@ make_parameter (const char *name, } DbwParameter * -dbw_parameter_in (const char *name, +nul_dbus_parameter_in (const char *name, const DbwType *type) { return make_parameter (name, type, FALSE); } DbwParameter * -dbw_parameter_out (const char *name, +nul_dbus_parameter_out (const char *name, const DbwType *type) { return make_parameter (name, type, TRUE); @@ -1040,19 +1040,19 @@ make_type (nul_type_t t) } const DbwType * -dbw_type_int32 (void) +nul_dbus_type_int32 (void) { return make_type (INT32); } const DbwType * -dbw_type_uint32 (void) +nul_dbus_type_uint32 (void) { return make_type (UINT32); } const DbwType * -dbw_type_string (void) +nul_dbus_type_string (void) { return make_type (STRING); } @@ -1179,7 +1179,7 @@ find_member (DbwInterface *interface, const char *name) } void -dbw_invoke (DbwService *service, +nul_dbus_invoke (DbwService *service, const char *method_desc, DbwFunction callback, gpointer data, @@ -30,7 +30,7 @@ typedef union int16_t v_int16; uint8_t v_uint8; int8_t v_int8; - + unsigned int v_uint; int v_int; unsigned short v_ushort; @@ -53,12 +53,12 @@ typedef enum NUL_TYPE_INT16, NUL_TYPE_UINT8, NUL_TYPE_INT8, - + NUL_TYPE_UINT, NUL_TYPE_INT, NUL_TYPE_USHORT, NUL_TYPE_SHORT, - + NUL_TYPE_UCHAR, NUL_TYPE_SCHAR, NUL_TYPE_CHAR, @@ -68,7 +68,7 @@ typedef enum NUL_TYPE_DOUBLE, NUL_TYPE_FLOAT, - + NUL_TYPE_VOID } nul_type_t; @@ -91,24 +91,24 @@ void nul_fun_def_free (nul_fun_def_t *fun); typedef void (* WatchCallback) (gpointer data); void nul_fd_add_watch (int fd, - gpointer data); -gpointer nul_fd_get_data (int fd); -void nul_fd_set_data (int fd, - gpointer data); -void nul_fd_set_read_callback (int fd, + gpointer data); +gpointer nul_fd_get_data (int fd); +void nul_fd_set_data (int fd, + gpointer data); +void nul_fd_set_read_callback (int fd, WatchCallback read_cb); -void nul_fd_set_write_callback (int fd, +void nul_fd_set_write_callback (int fd, WatchCallback write_cb); -void nul_fd_set_hangup_callback (int fd, +void nul_fd_set_hangup_callback (int fd, WatchCallback hangup_cb); -void nul_fd_set_error_callback (int fd, +void nul_fd_set_error_callback (int fd, WatchCallback error_cb); -void nul_fd_set_priority_callback (int fd, +void nul_fd_set_priority_callback (int fd, WatchCallback priority_cb); -void nul_fd_set_poll_handler (int fd, +void nul_fd_set_poll_handler (int fd, WatchCallback poll_handler); -void nul_fd_remove_watch (int fd); -gboolean nul_fd_is_watched (int fd); +void nul_fd_remove_watch (int fd); +gboolean nul_fd_is_watched (int fd); /* Implementing a service */ @@ -123,45 +123,45 @@ typedef struct DbwArg DbwArg; /* Return TRUE for handled, FALSE for not handled */ typedef gboolean (* DbwFunction) (); -DbwService * dbw_session_service (const char *name, - DbwObject *object1, - ...); -DbwObject * dbw_object (const char *name, - gpointer data, - DbwInterface *interface1, - ...); -DbwInterface *dbw_interface (const char *name, - DbwMember *member1, - ...); -DbwMember * dbw_method (const char *name, - DbwFunction function, - DbwParameter *parameter1, - ...); -DbwParameter *dbw_parameter_in (const char *name, - const DbwType *type); -DbwParameter *dbw_parameter_out (const char *name, - const DbwType *type); -gboolean dbw_service_start (DbwService *service); -void dbw_service_stop (DbwService *service); +DbwService * nul_dbus_session_service (const char *name, + DbwObject *object1, + ...); +DbwObject * nul_dbus_object (const char *name, + gpointer data, + DbwInterface *interface1, + ...); +DbwInterface *nul_dbus_interface (const char *name, + DbwMember *member1, + ...); +DbwMember * nul_dbus_method (const char *name, + DbwFunction function, + DbwParameter *parameter1, + ...); +DbwParameter *nul_dbus_parameter_in (const char *name, + const DbwType *type); +DbwParameter *nul_dbus_parameter_out (const char *name, + const DbwType *type); +gboolean nul_dbus_service_start (DbwService *service); +void nul_dbus_service_stop (DbwService *service); /* The returned values here are automatically freed at idle. You * must copy them if you want to keep them around */ -const DbwType * dbw_type_int32 (void); -const DbwType * dbw_type_uint32 (void); -const DbwType * dbw_type_string (void); +const DbwType * nul_dbus_type_int32 (void); +const DbwType * nul_dbus_type_uint32 (void); +const DbwType * nul_dbus_type_string (void); /* Using a service */ typedef struct DbwProxy DbwProxy; -DbwProxy *dbw_proxy_new_session_service (const char *bus_name, - const char *object, - const char *interface); +DbwProxy *nul_dbus_proxy_new_session_service (const char *bus_name, + const char *object, + const char *interface); -void dbw_invoke (DbwService *service, - const char *method_desc, - DbwFunction callback, - gpointer data, - ...); +void nul_dbus_invoke (DbwService *service, + const char *method_desc, + DbwFunction callback, + gpointer data, + ...); #endif |