easydbus-core.h

Go to the documentation of this file.
00001 /*
00002  EasyDbus: DBus Binding Library
00003  Copyright (C) 2007  Daniele Rondina aka ge@@ru, geaaru@gmail.com 
00004  
00005  This program is free software; you can redistribute it and/or
00006  modify it under the terms of the GNU General Public License
00007  as published by the Free Software Foundation; either version 2
00008  of the License, or (at your option) any later version.
00009 
00010  This program is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  GNU General Public License for more details.
00014 
00015  You should have received a copy of the GNU General Public License
00016  along with this program; if not, write to the Free Software
00017  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 
00019   Filename:  easydbus-core.h
00020  
00021   Description:  
00022  
00023   Version:  0.1
00024   Created:  05/29/07 22:34:41 CEST
00025   Revision:  none
00026  
00027   Author:  Daniele Rondina aka ge@@ru (geaaru@gmail.com), 
00028   License:  GPL 2.0
00029 */
00030 
00031 #ifndef EASYDBUS_CORE_H
00032 #define EASYDBUS_CORE_H
00033 
00034 #   include "config.h"
00035 #   include <easydbus-dbus.h>
00036 #   include <easydbus-macro.h>
00037 #   include <easydbus/easydbus.h>
00038 #   include <easydbus/easydbus-object.h>
00039 #   include <easydbus-object_internal.h>
00040 
00041 #   define EASYDBUS_MATCHRULE_FOR_TYPE                "type='"
00042 #   define EASYDBUS_MATCHRULE_FOR_SINGLE_QUOTE        "'"
00043 #   define EASYDBUS_MATCHRULE_FOR_COMMA               ","
00044 #   define EASYDBUS_MATCHRULE_FOR_SENDER              "sender='"
00045 #   define EASYDBUS_MATCHRULE_FOR_INTERFACE           "interface='"
00046 #   define EASYDBUS_MATCHRULE_FOR_MEMBER              "member='"
00047 #   define EASYDBUS_MATCHRULE_FOR_PATH                "path='"
00048 #   define EASYDBUS_MATCHRULE_FOR_DESTINATION         "destination='"
00049 
00050 #   ifdef EASYDBUS_TESTING
00051 #      define EASYDBUS_INTERNAL_F_ATTR
00052 #      define EASYDBUS_HIDDEN_F_ATTR
00053 #   else
00054 #      define EASYDBUS_INTERNAL_F_ATTR  __attribute__ ((visibility("internal")))
00055 #      define EASYDBUS_HIDDEN_F_ATTR  __attribute__ ((visibility("hidden")))
00056 #   endif
00057 
00065 struct EasyDbus_container {
00067    unsigned int nel;
00069    enum el_type container_type;
00071    enum el_type elem_type;
00073    char *signature;
00075    void *p_data;
00076 };
00077 
00083 struct EasyDbus_elem {
00085    enum el_type type;
00087    struct EasyDbus_elem *next;
00089    union {
00091       short i16;
00093       unsigned short ui16;
00095       int i32;
00097       long long i64;
00099       unsigned int ui32;
00101       unsigned long long ui64;
00103       double Double;
00105       char *string;
00107       struct EasyDbus_container *p_container;
00109       char byte;
00111       char boolean;
00112    } payload;
00113 };
00114 
00120 struct EasyDbus_reply {
00122    enum event_type type;
00124    char *src_path;
00126    char *interface;
00128    char *sender;
00130    unsigned int args;
00132    struct EasyDbus_elem *first;
00133 };
00134 
00140 struct EasyDbus_method {
00142    char *name;
00144    char *path;
00146    char *destination;
00148    char *interface;
00150    unsigned int args;
00152    unsigned int retry:2;
00154    struct EasyDbus_elem *first;
00156    struct EasyDbus_reply *reply;
00157 };
00158 
00164 struct EasyDbus_signal {
00166    char *name;
00168    char *path;
00170    char *interface;
00172    char *sender;
00174    char *destination;
00176    unsigned int args;
00178    struct EasyDbus_elem *first;
00179 };
00180 
00187 struct EasyDbus_conn {
00189    int registered_ondbus:2;
00191    int received_msg;
00193    int received_signal;
00195    easydbus_error_cb_f error_cb;
00197    void *error_closure;
00199    int flags;
00201    enum easydbus_bus bus;
00203    void *watcher_closure;
00205    easydbus_watcher_add_cb_f watcher_add_cb;
00207    easydbus_watcher_remove_cb_f watcher_remove_cb;
00209    easydbus_reply_async_cb_f reply_async_cb;
00211    void *reply_async_closure;
00213    easydbus_error_message_cb_f error_message_cb;
00215    void *error_message_closure;
00217    easydbus_reply_message_cb_f reply_message_cb;
00219    void *closure;
00220 };
00221 
00222 
00232 struct EasyDbus_watcher {
00233    DBusWatch *watch;
00234    struct EasyDbus_core *core;
00235    struct EasyDbus_watcher *next;
00236 };
00237 
00245 struct EasyDbus_Pending {
00247    struct EasyDbus_core *core;
00249    EasyDbus_method *message;
00251    dbus_uint32_t message_serial;
00253    easydbus_method_async_reply_cb_f p_cb;
00255    void *closure;
00257    int timeout;
00259    DBusPendingCall *pcall;
00261    struct EasyDbus_Pending *next;
00262 };
00263 
00273 struct EasyDbus_object_box {
00275    struct EasyDbus_object core;
00277    DBusObjectPathVTable vtable;
00279    struct EasyDbus_object_box *next;
00280 };
00281 
00289 struct EasyDbus_core {
00291    struct EasyDbus_conn user_data;
00293    char *service_name;
00295    DBusConnection *conn;
00297    struct EasyDbus_object_box *objects;
00299    int n_objs;
00304    char handled_signal:2;
00306    struct EasyDbus_ext_signal *handled_ext_signals;
00311    char handled_introspect:2;
00312 
00313    //int watchers_status:6;    // enum easydbus_watch_status
00315    struct EasyDbus_watcher *watcher;
00316 
00318    struct EasyDbus_Pending *pending_msgs;
00319 };
00320 
00327 enum signature_flags {
00329    EASYDBUS_SIGNATURE_NORMAL = 0,
00331    EASYDBUS_SIGNATURE_VARIANT = 1
00332 };
00333 
00340 struct easydbus_signature_elem_stack {
00342    enum el_type type;
00344    struct easydbus_signature_elem_stack *next;
00346    struct easydbus_signature_elem_stack *prev;
00347 };
00348 
00349 struct easydbus_signature_elem_stack *
00350 easydbus_add_elem_to_stack (enum el_type,
00351                             struct easydbus_signature_elem_stack *);
00352 
00353 void 
00354 easydbus_free_elem_from_stack (struct easydbus_signature_elem_stack *);
00355 
00356 inline void 
00357 easydbus_free_elem_from_stack_list (struct easydbus_signature_elem_stack *);
00358 
00359 inline DBusMessage *
00360 create_signal_msg (struct EasyDbus_core *,
00361                    struct EasyDbus_signal *) 
00362                    EASYDBUS_INTERNAL_F_ATTR;
00363 
00364 inline DBusMessage *
00365 create_method_msg (struct EasyDbus_core *,
00366                    struct EasyDbus_method *)
00367                    EASYDBUS_INTERNAL_F_ATTR;
00368 
00369 
00370 struct EasyDbus_method *
00371 easydbus_method_build_skeleton (DBusMessage *)
00372                                 EASYDBUS_INTERNAL_F_ATTR;
00373 
00374 struct EasyDbus_signal *
00375 easydbus_signal_build_skeleton (DBusMessage *)
00376                                 EASYDBUS_INTERNAL_F_ATTR;
00377 
00378 int 
00379 easydbus_build_skeleton_data (DBusMessage *, 
00380                               enum event_type,
00381                               void *)
00382                               EASYDBUS_INTERNAL_F_ATTR;
00383 
00384 // add element to skeleton TODO: see where insert this prototype
00385 void 
00386 easydbus_elem_add_to_skeleton (enum event_type, void *,
00387                                EasyDbus_elem *)
00388                                EASYDBUS_INTERNAL_F_ATTR;
00389 
00390 DBusHandlerResult 
00391 easydbus_core_filter_func (DBusConnection *,
00392                            DBusMessage *, void *)
00393                            EASYDBUS_INTERNAL_F_ATTR;
00394 
00395 /* to control */
00396 void 
00397 close_dbus_connection (EasyDbus_conn *)
00398                        EASYDBUS_INTERNAL_F_ATTR;
00399 
00400 #endif
00401 // vim: ts=3 shiftwidth=3 expandtab

Generated on Thu Apr 10 10:00:18 2008 for EasyDbus-0.2 by  doxygen 1.5.4