telepathygabble/inc/properties-mixin.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /*
       
     2  * properties-mixin.h - Header for GabblePropertiesMixin
       
     3  * Copyright (C) 2006 Collabora Ltd.
       
     4  * 
       
     5  *   @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
       
     6  *   @author Robert McQueen <robert.mcqueen@collabora.co.uk>
       
     7  *
       
     8  * This library is free software; you can redistribute it and/or
       
     9  * modify it under the terms of the GNU Lesser General Public
       
    10  * License as published by the Free Software Foundation; either
       
    11  * version 2.1 of the License, or (at your option) any later version.
       
    12  *
       
    13  * This library is distributed in the hope that it will be useful,
       
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16  * Lesser General Public License for more details.
       
    17  *
       
    18  * You should have received a copy of the GNU Lesser General Public
       
    19  * License along with this library; if not, write to the Free Software
       
    20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    21  */
       
    22 
       
    23 #ifndef __GABBLE_PROPERTIES_MIXIN_H__
       
    24 #define __GABBLE_PROPERTIES_MIXIN_H__
       
    25 
       
    26 #include "handles.h"
       
    27 #include "handle-set.h"
       
    28 #include "util.h"
       
    29 
       
    30 G_BEGIN_DECLS
       
    31 
       
    32 struct _GabblePropertySignature {
       
    33     gchar *name;
       
    34     GType type;
       
    35 };
       
    36 
       
    37 typedef struct _GabblePropertySignature GabblePropertySignature;
       
    38 
       
    39 struct _GabbleProperty {
       
    40     GValue *value;
       
    41     guint flags;
       
    42 };
       
    43 
       
    44 typedef struct _GabbleProperty GabbleProperty;
       
    45 
       
    46 typedef struct _GabblePropertiesContext GabblePropertiesContext;
       
    47 typedef gboolean (*GabblePropertiesSetFunc) (GObject *obj, GabblePropertiesContext *ctx, GError **error);
       
    48 
       
    49 struct _GabblePropertiesMixinClass {
       
    50   const GabblePropertySignature *signatures;
       
    51   guint num_props;
       
    52 
       
    53   GabblePropertiesSetFunc set_properties;
       
    54 
       
    55   guint property_flags_changed_signal_id;
       
    56   guint properties_changed_signal_id;
       
    57 };
       
    58 
       
    59 typedef struct _GabblePropertiesMixinClass GabblePropertiesMixinClass;
       
    60 
       
    61 typedef struct _GabblePropertiesMixinPrivate GabblePropertiesMixinPrivate;
       
    62 
       
    63 struct _GabblePropertiesMixin {
       
    64     GabbleProperty *properties;
       
    65 
       
    66     GabblePropertiesMixinPrivate *priv;
       
    67 };
       
    68 
       
    69 typedef struct _GabblePropertiesMixin GabblePropertiesMixin;
       
    70 
       
    71 /* TYPE MACROS */
       
    72 #define GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK (gabble_properties_mixin_class_get_offset_quark())
       
    73 #define GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK)))
       
    74 #define GABBLE_PROPERTIES_MIXIN_CLASS(o) ((GabblePropertiesMixinClass *) gabble_mixin_offset_cast (o, GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET (o)))
       
    75 
       
    76 #define GABBLE_PROPERTIES_MIXIN_OFFSET_QUARK (gabble_properties_mixin_get_offset_quark())
       
    77 #define GABBLE_PROPERTIES_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), GABBLE_PROPERTIES_MIXIN_OFFSET_QUARK)))
       
    78 #define GABBLE_PROPERTIES_MIXIN(o) ((GabblePropertiesMixin *) gabble_mixin_offset_cast (o, GABBLE_PROPERTIES_MIXIN_OFFSET (o)))
       
    79 
       
    80 #define TP_TYPE_PROPERTY_INFO_STRUCT (dbus_g_type_get_struct ("GValueArray", \
       
    81       G_TYPE_UINT, \
       
    82       G_TYPE_STRING, \
       
    83       G_TYPE_STRING, \
       
    84       G_TYPE_UINT, \
       
    85       G_TYPE_INVALID))
       
    86 #define TP_TYPE_PROPERTY_INFO_LIST (dbus_g_type_get_collection ("GPtrArray", \
       
    87       TP_TYPE_PROPERTY_INFO_STRUCT))
       
    88 
       
    89 #define TP_TYPE_PROPERTY_VALUE_STRUCT (dbus_g_type_get_struct ("GValueArray", \
       
    90       G_TYPE_UINT, \
       
    91       G_TYPE_VALUE, \
       
    92       G_TYPE_INVALID))
       
    93 #define TP_TYPE_PROPERTY_VALUE_LIST (dbus_g_type_get_collection ("GPtrArray", \
       
    94       TP_TYPE_PROPERTY_VALUE_STRUCT))
       
    95 
       
    96 #define TP_TYPE_PROPERTY_FLAGS_STRUCT (dbus_g_type_get_struct ("GValueArray", \
       
    97       G_TYPE_UINT, \
       
    98       G_TYPE_UINT, \
       
    99       G_TYPE_INVALID))
       
   100 #define TP_TYPE_PROPERTY_FLAGS_LIST (dbus_g_type_get_collection ("GPtrArray", \
       
   101       TP_TYPE_PROPERTY_FLAGS_STRUCT))
       
   102 
       
   103 GQuark gabble_properties_mixin_class_get_offset_quark (void);
       
   104 GQuark gabble_properties_mixin_get_offset_quark (void);
       
   105 
       
   106 void gabble_properties_mixin_class_init (GObjectClass *obj_cls, glong offset, const GabblePropertySignature *signatures, guint num_properties, GabblePropertiesSetFunc set_func);
       
   107 
       
   108 void gabble_properties_mixin_init (GObject *obj, glong offset);
       
   109 void gabble_properties_mixin_finalize (GObject *obj);
       
   110 
       
   111 gboolean gabble_properties_mixin_list_properties (GObject *obj, GPtrArray **ret, GError **error);
       
   112 gboolean gabble_properties_mixin_get_properties (GObject *obj, const GArray *properties, GPtrArray **ret, GError **error);
       
   113 void gabble_properties_mixin_set_properties (GObject *obj, const GPtrArray *properties, DBusGMethodInvocation *context);
       
   114 
       
   115 gboolean gabble_properties_mixin_has_property (GObject *obj, const gchar *name, guint *property);
       
   116 
       
   117 gboolean gabble_properties_context_has (GabblePropertiesContext *ctx, guint property);
       
   118 gboolean gabble_properties_context_has_other_than (GabblePropertiesContext *ctx, guint property);
       
   119 const GValue *gabble_properties_context_get (GabblePropertiesContext *ctx, guint property);
       
   120 guint gabble_properties_context_get_value_count (GabblePropertiesContext *ctx);
       
   121 void gabble_properties_context_remove (GabblePropertiesContext *ctx, guint property);
       
   122 void gabble_properties_context_return (GabblePropertiesContext *ctx, GError *error);
       
   123 gboolean gabble_properties_context_return_if_done (GabblePropertiesContext *ctx);
       
   124 
       
   125 void gabble_properties_mixin_change_value (GObject *obj, guint prop_id, const GValue *new_value, GArray **props);
       
   126 void gabble_properties_mixin_change_flags (GObject *obj, guint prop_id, TpPropertyFlags add, TpPropertyFlags remove, GArray **props);
       
   127 void gabble_properties_mixin_emit_changed (GObject *obj, GArray **props);
       
   128 void gabble_properties_mixin_emit_flags (GObject *obj, GArray **props);
       
   129 
       
   130 gboolean gabble_properties_mixin_is_readable (GObject *obj, guint prop_id);
       
   131 gboolean gabble_properties_mixin_is_writable (GObject *obj, guint prop_id);
       
   132 
       
   133 G_END_DECLS
       
   134 
       
   135 #endif /* #ifndef __GABBLE_PROPERTIES_MIXIN_H__ */