Main Page | Data Structures | File List | Data Fields | Globals

object.h

Go to the documentation of this file.
00001 /**
00002  * This file is part of alarmd
00003  *
00004  * Contact Person: David Weinehall <david.weinehall@nokia.com>
00005  *
00006  * Copyright (C) 2006 Nokia Corporation
00007  * alarmd and libalarm are free software; you can redistribute them
00008  * and/or modify them under the terms of the GNU Lesser General Public
00009  * License version 2.1 as published by the Free Software Foundation.
00010  *
00011  * alarmd and libalarm are distributed in the hope that they will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this software; if not, write to the Free
00018  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00019  * 02110-1301 USA
00020  */
00021 
00022 #ifndef _OBJECT_H_
00023 #define _OBJECT_H_
00024 
00025 #include <libxml/tree.h>
00026 #include <glib/gtypes.h>
00027 #include <glib-object.h>
00028 #include <dbus/dbus.h>
00029 
00030 #define ALARMD_TYPE_OBJECT (alarmd_object_get_type())
00031 #define ALARMD_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST((object), ALARMD_TYPE_OBJECT, AlarmdObject))
00032 #define ALARMD_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), ALARMD_TYPE_OBJECT, AlarmdObjectClass))
00033 #define ALARMD_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), ALARMD_TYPE_OBJECT))
00034 #define ALARMD_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), ALARMD_TYPE_OBJECT))
00035 #define ALARMD_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), ALARMD_TYPE_OBJECT, AlarmdObjectClass))
00036 
00037 typedef struct _AlarmdObject AlarmdObject;
00038 struct _AlarmdObject
00039 {
00040         GObject parent_instance;
00041 };
00042 
00043 typedef struct _AlarmdObjectClass AlarmdObjectClass;
00044 struct _AlarmdObjectClass
00045 {
00046         GObjectClass parent_class;
00047 
00048         void (*changed)(AlarmdObject *object);
00049         GParameter *(*get_properties)(AlarmdObject *object, guint *n_objects);
00050         GSList *(*get_saved_properties)();
00051         xmlNode *(*to_xml)(AlarmdObject *object);
00052         void (*to_dbus)(AlarmdObject *object, DBusMessageIter *iter);
00053         void (*time_changed)(AlarmdObject *object);
00054 };
00055 
00056 /**
00057  * SECTION:object
00058  * @short_description: Base class for all alarmd objects.
00059  * @see_also: AlarmdEvent, AlarmdAction, AlarmdQueue
00060  *
00061  * Base class for all objects in alarmd. Idea is to centralize the
00062  * serialization and to ease spreading the time-changed signal.
00063  **/
00064 
00065 /**
00066  * AlarmdObject::changed:
00067  * @object: The object that has changed.
00068  *
00069  * Emitted whenever an object has changed so that it should be saved.
00070  **/
00071 
00072 /**
00073  * AlarmdObject::time-changed:
00074  * @object: The #AlarmdObject which received the signal.
00075  *
00076  * Emitted whenever the system time has changed.
00077  **/
00078 
00079 GType alarmd_object_get_type(void);
00080 
00081 /**
00082  * alarmd_object_get_properties:
00083  * @object: The object whose properties should be gotten.
00084  * @n_objects: Pointer to integer that should hold the size of the returned
00085  * array.
00086  *
00087  * Gets all properties of an object that should be saved; mostly a helper
00088  * function for #alarmd_object_to_xml and #alarmd_object_to_dbus to avoid
00089  * code duplication.
00090  * Returns: An array of #GParameter.
00091  **/
00092 GParameter *alarmd_object_get_properties(AlarmdObject *object, guint *n_objects);
00093 /**
00094  * alarmd_object_get_saved_properties:
00095  * @object: The #AlarmdObject whose saved properties should be get.
00096  *
00097  * An helper function for #alarmd_object_get_properties to reduce code
00098  * duplication. Each subclass overriding this should call their parent to
00099  * get their saved properties too.
00100  * Returns: A #GSList of property names (as const char *). The names should
00101  * be owned by the appropriate class and will not be free'd.
00102  **/
00103 GSList *alarmd_object_get_saved_properties(AlarmdObject *object);
00104 
00105 /**
00106  * alarmd_object_to_xml:
00107  * @object: The #AlarmdObject that should be serialized into xml.
00108  *
00109  * Creates a xml representation of the @object.
00110  * Returns: A tree of #xmlNode describing the @object.
00111  **/
00112 xmlNode *alarmd_object_to_xml(AlarmdObject *object);
00113 
00114 /**
00115  * alarmd_object_to_dbus:
00116  * @object: The #AlarmdObject that should be serialized into dbus message.
00117  * @iter: The iter that should hould the representation of the object.
00118  *
00119  * Creates a dbus message representation of the @object.
00120  **/
00121 void alarmd_object_to_dbus(AlarmdObject *object, DBusMessageIter *iter);
00122 
00123 /**
00124  * alarmd_object_changed:
00125  * @object: The object that has changed.
00126  *
00127  * Emits #AlarmdObject::changed signal on the @object.
00128  **/
00129 void alarmd_object_changed(AlarmdObject *object);
00130 
00131 
00132 /**
00133  * alarmd_object_time_changed:
00134  * @object: The object that should receive the signal.
00135  *
00136  * Emits #AlarmdObject::time-changed signal on the @object.
00137  **/
00138 void alarmd_object_time_changed(AlarmdObject *object);
00139 
00140 /**
00141  * alarmd_gparameterv_free:
00142  * @paramv: The #GParameter array.
00143  * @n_objects: The size of the @paramv.
00144  *
00145  * Frees the @paramv array and all data associated with it.
00146  **/
00147 void alarmd_gparameterv_free(GParameter *paramv, guint n_objects);
00148 
00149 #endif /* _OBJECT_H */

Generated on Thu Dec 21 18:23:30 2006 for Alarmd by  doxygen 1.4.2