Changeset 16574
- Timestamp:
- 06/10/08 18:13:42 (4 months ago)
- Files:
-
- trunk/midgard/core/midgard/src/midgard_blob.c (modified) (8 diffs)
- trunk/midgard/core/midgard/src/midgard_blob.h (modified) (5 diffs)
- trunk/midgard/core/midgard/src/midgard_dbus.h (modified) (1 diff)
- trunk/midgard/core/midgard/src/midgard_error.c (modified) (6 diffs)
- trunk/midgard/core/midgard/src/midgard_error.h (modified) (3 diffs)
- trunk/midgard/core/midgard/src/midgard_metadata.c (modified) (1 diff)
- trunk/midgard/core/midgard/src/midgard_metadata.h (modified) (2 diffs)
- trunk/midgard/core/midgard/src/midgard_object_attachment.h (modified) (1 diff)
- trunk/midgard/core/midgard/src/midgard_object_class.c (modified) (10 diffs)
- trunk/midgard/core/midgard/src/midgard_object_class.h (modified) (2 diffs)
- trunk/midgard/core/midgard/src/midgard_replicator.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midgard/core/midgard/src/midgard_blob.c
r15807 r16574 1 1 /* 2 * Copyright (C) 2006, 2007,2008 Piotr Pokora <piotrek.pokora@gmail.com>2 * Copyright (C) 2006, 2007, 2008 Piotr Pokora <piotrek.pokora@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it … … 116 116 } 117 117 118 119 /* Instatiate new Midgard Blob. */ 118 /** 119 * midgard_blob_new: 120 * @attachment: #MgdObject of MIDGARD_TYPE_ATTACHMENT type. 121 * 122 * Instatiate new Midgard Blob object for the given midgard_attachment object. 123 * This is almost the same constructor as g_object_new, but unlike that one, 124 * midgard_blob_new requires MgdObject (midgard_attachment) object's pointer. 125 * 126 * This constructor defines new relative path for attachment, if midgard_attachment 127 * is associated with midgard_blob and its location is empty. 128 * In any other case, location is not changed. 129 * 130 * Returns: newly instatiated #MidgardBlob object or %NULL on failure 131 */ 120 132 MidgardBlob *midgard_blob_new(MgdObject *attachment) 121 133 { … … 161 173 } 162 174 163 /* Returns file's content. */ 175 /** 176 * midgard_blob_read_content: 177 * @self: MidgardBlob self instance 178 * @bytes_read: number of bytes read 179 * 180 * Returned content should be freed when no longer needed. 181 * @bytes_read holds size of returned content. 182 * 183 * This function should be used to get content of small files. 184 * For large and huge ones midgard_blob_get_handler should be used 185 * to get file handle. 186 * 187 * Returns: content of the file, or %NULL on failure 188 */ 164 189 gchar *midgard_blob_read_content(MidgardBlob *self, gsize *bytes_read) 165 190 { … … 250 275 } 251 276 252 /* Write given content to a file */ 277 /** 278 * midgard_blob_write_content: 279 * @self: #MidgardBlob self instance. 280 * @content: content which should be written to file. 281 * 282 * Write given @content to a file. 283 * 284 * Returns: %TRUE if content has been written to file, %FALSE otherwise. 285 */ 253 286 gboolean midgard_blob_write_content(MidgardBlob *self, const gchar *content) 254 287 { … … 297 330 } 298 331 299 /* Get GIOChannel */ 332 /** 333 * midgard_blob_get_handler: 334 * @self: #MidgardBlob instance 335 * 336 * \return GIOChannel 337 * 338 * The main idea is to get file handler. On C level it returns 339 * GIOChannel, but language bindings could return typical file handler 340 * or anything else which is needed for particular language. 341 * 342 * Returned channel is owned by midgard_blob and should not be freed 343 * or unreferenced. 344 */ 300 345 GIOChannel *midgard_blob_get_handler(MidgardBlob *self) 301 346 { … … 312 357 } 313 358 314 /* Get absolute path of a file */ 359 /** 360 * midgard_blob_get_path: 361 * @self: #MidgardBlob instance 362 * 363 * Returned path is owned by midgard_blob and should not be freed. 364 * It basically contains blobdir and relative file's location. 365 * 366 * Returns: absolute path or %NULL if path is not set yet. 367 */ 315 368 const gchar *midgard_blob_get_path(MidgardBlob *self) 316 369 { … … 327 380 } 328 381 329 /* Check if file exists */ 382 /** 383 * midgard_blob_exists: 384 * @self: #MidgardBlob instance 385 * 386 * Check if file associated with midgard_blob exists. 387 * This function will also return FALSE, if file is not yet associated. 388 * 389 * Returns: %TRUE if file exists, %FALSE otherwise 390 */ 330 391 gboolean midgard_blob_exists(MidgardBlob *self) 331 392 { … … 353 414 } 354 415 355 /* Delete file associated wtih MidgardBlob instance. */ 416 /** 417 * midgard_blob_remove_file: 418 * @self: #MidgardBlob self instance. 419 * 420 * Deletes a file which is associated with blob and located at 421 * attachment's location which is initialized for blob. 422 * #midgard_blob_exists should be invoked if file may be already 423 * deleted, for example when one file is shared among many attachments. 424 * 425 * Returns: %TRUE on success, %FALSE otherwise 426 */ 356 427 gboolean midgard_blob_remove_file(MidgardBlob *self) 357 428 { trunk/midgard/core/midgard/src/midgard_blob.h
r15473 r16574 1 1 /* 2 * Copyright (C) 2006, 2008 Piotr Pokora <piotr .pokora@infoglob.pl>2 * Copyright (C) 2006, 2008 Piotr Pokora <piotrek.pokora@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it … … 29 29 */ 30 30 31 32 31 #include "midgard_connection.h" 33 32 #include "midgard_object.h" … … 52 51 typedef struct _MidgardBlobPrivate MidgardBlobPrivate; 53 52 54 /**55 * \ingroup midgard_blob56 *57 * MidgardObjectClass structure.58 */59 53 struct MidgardBlobClass { 60 54 GObjectClass parent; … … 68 62 }; 69 63 70 /**71 * \ingroup midgard_blob72 *73 * MidgardObject structure74 */75 64 struct MidgardBlob { 76 65 GObject parent; … … 79 68 }; 80 69 81 /** 82 * \ingroup midgard_blob 83 * 84 * Returns Midgard Blob Gtype value. 85 * Registers this type unless already registered. 86 */ 87 extern GType 88 midgard_blob_get_type(void); 89 90 /** 91 * \ingroup midgard_blob 92 * 93 * Instatiate new Midgard Blob. 94 * 95 * \param attachment , MidgardObject of MIDGARD_TYPE_ATTACHMENT type. 96 * 97 * \return MidgardBlob, newly instatiated MidgardBlob object. 98 * 99 * Instatiate new Midgard Blob object for the given midgard_attachment object. 100 * This is almost the same constructor as g_object_new, but unlike that one, 101 * midgard_object_new requires MgdObject object's pointer. 102 * 103 * This constructor defines new relative path for attachment, if midgard_attachment 104 * is associated with midgard_blob and its location is empty. 105 * In any other case, location is not changed. 106 */ 107 extern MidgardBlob * 108 midgard_blob_new(MgdObject *attachment); 109 110 /** 111 * \ingroup midgard_blob 112 * 113 * Returns content of the file. 114 * 115 * \param self, MidgardBlob self instance 116 * \param bytes_read, number of bytes read 117 * 118 * \return file's content or NULL. 119 * 120 * Returned content should be freed when no longer needed. 121 * \c bytes_read returned content's size. It should be used if content 122 * is passed to function which requires its size. In such case, there's 123 * no need to count content size once again. 124 * 125 * This function should be used to get content of small files. 126 * For large and huge ones midgard_blob_get_handler should be used 127 * to get file handle. 128 */ 129 extern gchar * 130 midgard_blob_read_content(MidgardBlob *self, gsize *bytes_read); 131 132 /** 133 * \ingroup midgard_blob 134 * 135 * Write given content to a file. 136 * 137 * \param self, MidgardBlob self instance. 138 * \param content, content which should be written to file. 139 * 140 * \return TRUE if content has been written to file, FALSE otherwise. 141 */ 142 extern gboolean 143 midgard_blob_write_content(MidgardBlob *self, 144 const gchar *content); 145 146 /** 147 * \ingroup midgard_blob 148 * 149 * Get GIOChannel 150 * 151 * \param self, MidgardBlob instance 152 * 153 * \return GIOChannel 154 * 155 * The main idea is to get file handler. On C level it returns 156 * GIOChannel, but language bindings could return typical file handler 157 * or anything else which is needed for particular language. 158 * 159 * Returned channel is owned by midgard_blob and should not be freed 160 * or unreferenced. 161 */ 162 extern GIOChannel *midgard_blob_get_handler(MidgardBlob *self); 163 164 /** 165 * \ingroup midgard_blob 166 * 167 * Get absolute path of a file 168 * 169 * \param self, MidgardBlob instance 170 * 171 * \return absolute path or NULL in case of failure 172 * 173 * Returned path is owned by midgard_blob and should not be freed. 174 * It basically contains blobdir and relative file's location. 175 */ 176 extern const gchar *midgard_blob_get_path(MidgardBlob *self); 177 178 /** 179 * \ingroup midgard_blob 180 * 181 * Check if file exists 182 * 183 * \param self, MidgardBlob instance 184 * \return TRUE if file exists, FALSE otherwise 185 * 186 * Check if file associated with midgard_blob exists. 187 * This function will also return FALSE, if file is not yet 188 * associated. 189 */ 190 extern gboolean midgard_blob_exists(MidgardBlob *self); 191 192 /** 193 * \ingroup midgard_blob 194 * 195 * Delete file associated wtih MidgardBlob instance. 196 * 197 * \param self, MidgardBlob self instance. 198 * 199 * \return TRUE on success, FALSE otherwise 200 * 201 * Deletes a file which is associated with blob and located 202 * in attachment's location which is initialized for blob. 203 * midgard_blob_exists should be invoked if file may be already 204 * deleted, for example when one file is shared among many attachments. 205 */ 206 extern gboolean midgard_blob_remove_file(MidgardBlob *self); 70 GType midgard_blob_get_type(void); 71 MidgardBlob *midgard_blob_new(MgdObject *attachment); 72 gchar *midgard_blob_read_content(MidgardBlob *self, gsize *bytes_read); 73 gboolean midgard_blob_write_content(MidgardBlob *self, const gchar *content); 74 GIOChannel *midgard_blob_get_handler(MidgardBlob *self); 75 const gchar *midgard_blob_get_path(MidgardBlob *self); 76 gboolean midgard_blob_exists(MidgardBlob *self); 77 gboolean midgard_blob_remove_file(MidgardBlob *self); 207 78 208 79 G_END_DECLS 209 210 80 #endif /* _MIDGARD_BLOB_H */ trunk/midgard/core/midgard/src/midgard_dbus.h
r16468 r16574 61 61 }; 62 62 63 externGType midgard_dbus_get_type(void);63 GType midgard_dbus_get_type(void); 64 64 65 extern MidgardDbus *midgard_dbus_new(MidgardConnection *mgd, const gchar *path); 66 67 extern void midgard_dbus_send(MidgardConnection *mgd, const gchar *path, const gchar *message); 68 69 extern const gchar *midgard_dbus_get_message(MidgardDbus *self); 70 71 extern const gchar *midgard_dbus_get_name(void); 65 MidgardDbus *midgard_dbus_new(MidgardConnection *mgd, const gchar *path); 66 void midgard_dbus_send(MidgardConnection *mgd, const gchar *path, const gchar *message); 67 const gchar *midgard_dbus_get_message(MidgardDbus *self); 68 const gchar *midgard_dbus_get_name(void); 72 69 73 70 G_END_DECLS trunk/midgard/core/midgard/src/midgard_error.c
r16260 r16574 1 1 /* 2 * Copyright (C) 2006 Piotr Pokora <piotr .pokora@infoglob.pl>2 * Copyright (C) 2006 Piotr Pokora <piotrek.pokora@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it … … 23 23 #include <unistd.h> 24 24 25 /** 26 * midgard_error_generic: 27 * 28 * GQuark for Midgard Error. It's used by Midgard Error implementation, and 29 * probably not needed to use by any application. 30 * 31 * Returns: MGD_GENERIC_ERROR GQuark 32 */ 25 33 GQuark midgard_error_generic(void) 26 34 { … … 31 39 } 32 40 41 /** 42 * midgard_error_string: 43 * @domain, GQuark which represents MidgardError domain. 44 * @errcode, MidgardErrorGeneric enum value. 45 * 46 * Get error message for the given error code. 47 * 48 * Returns: error messages which is owned by midgard-core and should not be freed. 49 */ 33 50 const gchar *midgard_error_string(GQuark domain, gint errcode) 34 51 { … … 156 173 } 157 174 175 /** 176 * midgard_set_error: 177 * @mgd: #MidgardConnection instance 178 * @domain: GQuark which represents MidgardError domain 179 * @errcode: #MidgardErrorGeneric enum value 180 * @msg: a message which should be appended to string represented by errcode 181 * @...: message argument list ( if required ) 182 * 183 * This function sets internal error constant, and creates new error message. 184 * User defined message is appended to internal one. 185 * Any message created by application ( and its corresponding constant ) are destroyed 186 * and reset to MGD_ERR_OK when any API function is invoked. 187 * Second @domain parameter is optional , and can be safely defined as NULL for 188 * MGD_GENERIC_ERROR domain. 189 * 190 * <strong> Example: </strong> 191 * @code 192 * 193 * void set_wrong_property(MidgardConnection *mgd, gchar *prop) 194 * { 195 * midgard_set_error(mgd, NULL, 196 * MGD_ERR_INVALID_PROPERTY_VALUE, 197 * "My application doesn't accept %s property", 198 * prop); 199 * } 200 * @endcode 201 */ 158 202 void midgard_set_error( 159 203 MidgardConnection *mgd, GQuark domain, gint errcode, const gchar *msg, ...) … … 196 240 } 197 241 198 /* Default function for log messages. */ 242 /** 243 * midgard_error_default_log: 244 * @domain: domain for the given log message 245 * @level: GLogLevelFlags 246 * @msg: log message 247 * @ptr: pointer to structure which holds loglevel 248 * 249 * @ptr pointer may be a pointer to #MidgardConnection or #MidgardTypeHolder 250 * structure. This function checks pointer type using MIDGARD_IS_CONNECTION 251 * convention macro. Next midgard_connection_get_loglevel is called to get loglevel. 252 * If MidgardConnection check fails , a typecast to MidgardTypeHolder is made. 253 * In this case, level member is used to get loglevel. 254 * 255 * You are responsible to correctly set MidgardConnection or MidgardTypeHolder 256 * before passing ptr argument. The main approach is to follow configuration's 257 * loglevel even if MidgardConnection pointer is not yet available. 258 * 259 * @see #midgard_connection_set_loglevel to set log level. 260 */ 199 261 void midgard_error_default_log(const gchar *domain, GLogLevelFlags level, 200 262 const gchar *msg, gpointer ptr) … … 295 357 } 296 358 297 /* Get GLogLevelFlags value from loglevel string */ 359 360 /** 361 * midgard_error_parse_loglevel: 362 * @levelstring: string which should be parsed 363 * 364 * This function returns level registered in GLib. 365 * 366 * Returns: #GLogLevelFlags or -1 on failure 367 */ 298 368 gint midgard_error_parse_loglevel(const gchar *levelstring) 299 369 { trunk/midgard/core/midgard/src/midgard_error.h
r16187 r16574 1 1 /* 2 * Copyright (C) 2006 Piotr Pokora <piotr .pokora@infoglob.pl>2 * Copyright (C) 2006 Piotr Pokora <piotrek.pokora@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it … … 70 70 }MgdErrorGeneric; 71 71 72 /** 73 * \ingroup midgard_error 74 * 75 * GQuark for Midgard Error. It's used by Midgard Error implementation, and 76 * probably is not needed to use by any application. 77 * 78 * \return MGD_GENERIC_ERROR GQuark 79 */ 80 extern GQuark midgard_error_generic(void); 81 82 /** 83 * \ingroup midgard_error 84 * 85 * Get error message for the given error code. 86 * 87 * \param domain , GQuark which represents MidgardError domain. 88 * \param errcode, MidgardErrorGeneric enum value. 89 * 90 * \return error messages which is owned by midgard-core and should not be freed. 91 */ 92 extern const gchar *midgard_error_string(GQuark domain, gint errcode); 93 94 /** 95 * \ingroup midgard_error 96 * 97 * Sets internal error constant and error message. 98 * 99 * \param mgd, MidgardConnection instance 100 * \param domain, GQuark which represents MidgardError domain 101 * \param errcode, MidgardErrorGeneric enum value 102 * \param msg, a message which should be appended to string represented by errcode 103 * \param ..., message argument list ( if required ) 104 * 105 * This function sets internal error constant, and creates new error message. 106 * User defined message is appended to internal one. 107 * Any message created by application ( and its corresponding constant ) are destroyed 108 * and reset to MGD_ERR_OK when any API function is invoked. 109 * Second \c domain parameter is optional , and can be safely defined as NULL for 110 * MGD_GENERIC_ERROR domain. 111 * 112 * <strong> Example: </strong> 113 * @code 114 * 115 * void set_wrong_property(MidgardConnection *mgd, gchar *prop) 116 * { 117 * midgard_set_error(mgd, NULL, 118 * MGD_ERR_INVALID_PROPERTY_VALUE, 119 * "My application doesn't accept %s property", 120 * prop); 121 * } 122 * @endcode 123 */ 124 extern void midgard_set_error( 72 GQuark midgard_error_generic(void); 73 const gchar *midgard_error_string(GQuark domain, gint errcode); 74 void midgard_set_error( 125 75 MidgardConnection *mgd, GQuark domain, 126 76 gint errcode, const gchar *msg, ...); 77 void midgard_error_default_log(const gchar *domain, GLogLevelFlags level, 78 const gchar *msg, gpointer ptr); 79 gint midgard_error_parse_loglevel(const gchar *levelstring); 127 80 128 /**129 * \ingroup midgard_error130 *131 * Default function for log messages.132 *133 * \param domain, domain for the given log message134 * \param level, GLogLevelFlags135 * \param msg, log message136 * \param ptr, pointer to structure which holds loglevel137 *138 * \c ptr pointer may be a pointer to MidgardConnection or MidgardTypeHolder139 * structure. This function checks pointer type using MIDGARD_IS_CONNECTION140 * convention macro. Next midgard_connection_get_loglevel is called to get loglevel.141 * If MidgardConnection check fails , a typecast to MidgardTypeHolder is made.142 * In this case, level member is used to get loglevel.143 *144 * You are responsible to correctly set MidgardConnection or MidgardTypeHolder145 * before passing ptr argument. The main approach is to follow configuration's146 * loglevel even if MidgardConnection pointer is not yet available.147 *148 * Use midgard_connection_set_loglevel to set log level.149 *150 */151 extern void midgard_error_default_log(const gchar *domain, GLogLevelFlags level,152 const gchar *msg, gpointer ptr);153 154 /**155 * \ingroup midgard_error156 *157 * Get GLogLevelFlags value from loglevel string.158 *159 * \param levelstring, string which should be parsed160 *161 * \return GLogLevelFlags or -1 on failure162 *163 */164 extern gint midgard_error_parse_loglevel(const gchar *levelstring);165 166 /**167 * \ingroup midgard_error168 *169 * #define MIDGARD_ERRNO_SET(mgd, errcode)170 *171 * A simplified macro to set default error172 */173 81 174 82 #define MIDGARD_ERRNO_SET(str, errcode) \ … … 180 88 g_signal_emit_by_name(str, "error"); 181 89 182 183 extern void mgd_info(const gchar *format, ...); 90 void mgd_info(const gchar *format, ...); 184 91 185 92 G_END_DECLS trunk/midgard/core/midgard/src/midgard_metadata.c
r16346 r16574 184 184 } 185 185 186 /** 187 * midgard_metadata_new: 188 * @object: #MgdObject for which metadata is created 189 * 190 * Creates new midgard_metadata instance for the given MgdObject instance. 191 * 192 * Do not use #g_object_new as metadata constructor. MgdObject pointer is internally 193 * assigned as a pointer to midgard object for which particular metadata object 194 * instance was created. 195 * 196 * Midgard Metadata object has two "kinds" of properties. 197 * The first one is settable ( and overwritten ) only by metadata implementation. 198 * The second one is freely settable by application. In this case midgard core 199 * keep value of such property "as is". There is no change or update made for such 200 * property even if its value hasn't been changed by application. 201 * 202 * Do not free MidgardMetadata object's memory as it is automatically 203 * freed when particular object's instance memory is freed. 204 * 205 * Returns: newly allocated midgard_metadata instance 206 */ 186 207 MidgardMetadata *midgard_metadata_new(MgdObject *object) 187 208 { trunk/midgard/core/midgard/src/midgard_metadata.h
r15473 r16574 48 48 MIDGARD_TYPE_METADATA, MidgardMetadataClass)) 49 49 50 /**51 * \ingroup midgard_metadata52 *53 * Returns the MidgardMetadata value type.54 * Registers the type as a fundamental GType unless already registered.55 */56 50 GType midgard_metadata_get_type (void); 57 51 58 /**59 * \ingroup midgard_metadata60 *61 * Midgard Metadata Class structure.62 *63 */64 52 struct MidgardMetadataClass { 65 53 GObjectClass parent; … … 73 61 }; 74 62 75 /**76 * \ingroup midgard_metadata77 *78 * Private Midgard Metadata structure.79 */80 63 typedef struct _MidgardMetadataPrivate MidgardMetadataPrivate; 81 64 82 /**83 * \ingroup midgard_metadata84 *85 * Midgard Metadata object structure.86 */87 65 struct MidgardMetadata { 88 GObject parent; 66 GObject parent; 89 67 MidgardDBObjectPrivate *dbpriv; 90 68 MidgardMetadataPrivate *priv; 91 69 }; 92 70 93 /*94 * \ingroup midgard_metadata95 *96 * Creates new midgard_metadata instance for the given MgdObject instance.97 *98 * \param[in] klass MidgardObjectClass pointer99 *100 * \return newly allocated MidgardMetadata object101 *102 * Function g_object_new may be used as well as object's constructor however103 * it's recommended to use this constructor. MgdObject pointer is internally104 * assigned as a pointer to midgard object for which particular metadata object105 * instance was created.106 *107 * Midgard Metadata object has two "kinds" of properties.108 * The first one is settable ( and overwritten ) only by metadata implementation.109 * The second one is freely settable by application. In this case midgard core110 * keep value of such property "as is". There is no change or update made for such111 * property even if its value hasn't been changed by application.112 *113 * Properties of an object:114 *115 * - creator116 * Holds a string value with midgard_person object guid.117 * This property can not be overwritten by application.118 * It is set once when particular schema object's record(s) is created.119 * - created120 * Holds an ISO date value ( stored in UTC ).121 * This property can not be overwritten by application.122 * It is set once when particular schema object's record(s) is created.123 * - revisor124 * Holds a string value with midgard_person object guid.125 * This property can not be overwritten by application.126 * It is set when update method is invoked for particular schema object.127 * - revised128 * Holds an ISO date value ( stored in UTC ).129 * This property can not be overwritten by application.130 * It is set when update method is invoked for particular schema object.131 * - revision132 * Holds unsigned integer value with revision number.133 * This property can not be overwritten by application.134 * It is set ( increased by one ) when update method is invoked for135 * particular schema object.136 * - locker137 * Holds a string value with midgard_person object guid.138 * This property can be set by application.139 * - locked140 * Holds an ISO date value ( stored in UTC ).141 * This property can be set by application.142 * - approver143 * Holds a string value with midgard_person object guid.144 * This property can be set by application.145 * - approved146 * Holds an ISO date value ( stored in UTC ).147 * This property can be set by application.148 * - author149 * Holds a string value with midgard_person object guid.150 * This property can be set by application.151 * - owner152 * Holds a string value with midgard_person object guid.153 * This property can be set by application.154 * - schedulestart155 * Holds an ISO date value ( stored in UTC ).156 * This property can be set by application.157 * - scheduleend158 * Holds an ISO date value ( stored in UTC ).159 * This property can be set by application.160 * - hidden161 * Holds boolean value.162 * This property can be set by application.163 * - navnoentry164 * Holds boolean value.165 * This property can be set by application.166 * - size167 * Holds unsigned integer value of object's size ( in bytes ).168 * This property can not be set by application.169 * Object's size may vary depending on database storage and its optimized170 * for MySQL database engine now. When object is midgard_attachment type171 * then size is file size + object's database record size.172 * - published173 * Holds an ISO date value ( stored in UTC ).174 * This property can be set by application.175 *176 * There is no need to free MidgardMetadata object's memory as it is automatically177 * freed when particular object's instance memory is freed.178 *179 */180 71 MidgardMetadata *midgard_metadata_new(MgdObject *object); 181 72 182 /*183 * \ingroup midgard_metadata184 *185 * Returns MidgardObjectClass pointer.186 *187 * \param object MidgardMetadata instance188 *189 * \return MidgardObjectClass which the given MidgardMetadata object was created for.190 *191 */192 MidgardObjectClass *midgard_metadata_get_class(MidgardMetadata *object);193 194 73 #endif /* MIDGARD_METADATA_H */ trunk/midgard/core/midgard/src/midgard_object_attachment.h
r15808 r16574 22 22 G_BEGIN_DECLS 23 23 24 extern MgdObject **midgard_object_list_attachments(MgdObject *self); 25 26 extern MgdObject *midgard_object_create_attachment(MgdObject *self, 24 MgdObject **midgard_object_list_attachments(MgdObject *self); 25 MgdObject *midgard_object_create_attachment(MgdObject *self, 27 26 const gchar *name, const gchar *title, const gchar *mimetype); 28 29 extern gboolean midgard_object_delete_attachments(MgdObject *self, 27 gboolean midgard_object_delete_attachments(MgdObject *self, 30 28 guint n_params, const GParameter *parameters); 31 32 extern gboolean midgard_object_purge_attachments(MgdObject *self, 29 gboolean midgard_object_purge_attachments(MgdObject *self, 33 30 gboolean delete_blob, guint n_params, const GParameter *parameters); 34 35 extern MgdObject **midgard_object_find_attachments(MgdObject *self, 31 MgdObject **midgard_object_find_attachments(MgdObject *self, 36 32 guint n_params, const GParameter *parameters); 37 38 33 G_END_DECLS 39 34 trunk/midgard/core/midgard/src/midgard_object_class.c
r15473 r16574 1 1 /* 2 * Copyright (C) 2005 Piotr Pokora <piotr.pokora@infoglob.pl>2 * Copyright (C) 2005, 2008 Piotr Pokora <piotrek.pokora@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it … … 15 15 * along with this program; if not, write to the Free Software 16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * */17 */ 18 18 19 19 #include "midgard_object_class.h" … … 32 32 _midgard_core_class_get_type_attr(MIDGARD_DBOBJECT_CLASS(__klass)) 33 33 34 /* Returns the name of object's primary property. */35 34 const gchar *midgard_object_class_get_primary_property( 36 35 MidgardObjectClass *klass) … … 42 41 } 43 42 44 /* Returns the name of object's parent property. */ 43 44 /** 45 * midgard_object_class_get_property_parent: 46 * @klass: #MidgardObjectClass 47 * 48 * Returned string is a pointer to object's parent property, and you should not 49 * free it. Parent property is a property which holds value of field which points to 50 * parent object's identifier. Parent property always points to object's 51 * identifier which is not the same type as given MidgardObjectClass klass. 52 * 53 * This is static method. 54 * NULL is returned if parent property is not found. 55 * 56 * Returns: the name of object's parent property or %NULL. 57 */ 45 58 const gchar *midgard_object_class_get_property_parent( 46 59 MidgardObjectClass *klass) … … 52 65 } 53 66 54 /* Returns the name of object's up property. */ 67 68 /** 69 * midgard_object_class_get_property_up: 70 * @klass: #MidgardObjectClass 71 * 72 * /param klass MidgardObjectClass pointer 73 * 74 * Returned string is a pointer to object's up property. 75 * Up property is a property which holds value of field which points to 76 * "upper" object's identifier. Up property always points to object's 77 * identifier which is the same type as given MidgardObjectClass klass. 78 * 79 * This is static method. 80 * 81 * NULL is returned if up property is not registered for given class. 82 * 83 * Returns: the name of object's up property or %NULL. 84 */ 55 85 const gchar *midgard_object_class_get_property_up( 56 86 MidgardObjectClass *klass) … … 62 92 } 63 93 64 /* Returns class' lang usage information. */ 94 95 /** 96 * midgard_object_class_is_multilang: 97 * @klass: MidgardObjectClass 98 * 99 * Checks whether given MidgardObjectClass is multilingual. 100 * 101 * This is static method. 102 * 103 * Returns: %TRUE if MidgardObjectClass is mutlilingual, %FALSE otherwise. 104 */ 65 105 gboolean midgard_object_class_is_multilang( 66 106 MidgardObjectClass *klass) … … 75 115 } 76 116 77 /* Returns children ( in tree ) classes' pointers */ 117 /** 118 * midgard_object_class_list_children: 119 * @klass: MidgardObjectClass 120 * 121 * Returns newly allocated and NULL terminated children ( in midgard tree ) classes' pointers . 122 * Returned array should be freed if no longer needed without freeing array's elements. 123 * Elements are static pointers owned by GLib. 124 * 125 * This is static method. 126 * 127 * Returns: array of childreen ( in midgard tree ) classes of the given MidgardObjectClass. 128 */ 78 129 MidgardObjectClass **midgard_object_class_list_children( 79 130 MidgardObjectClass *klass) … … 102 153 } 103 154 104 /* Returns Midgard Object identified by guid */ 155 /** 156 * midgard_object_class_get_object_by_guid: 157 * @mgd: #MidgardConnection handler 158 * @guid: guid string which should identify an object 159 * 160 * #MidgardError set by this function: 161 * - MGD_ERR_NOT_EXISTS: object is not found 162 * - MGD_ERR_OBJECT_DELETED: object is already deleted 163 * - MGD_ERR_OBJECT_PURGED: object is purged 164 * - MGD_ERR_SITEGROUP_VIOLATION if more than one record exists 165 * 166 * This is static method. 167 * 168 * Returns: #MgdObject object identified by given @guid 169 */ 105 170 MgdObject *midgard_object_class_get_object_by_guid ( MidgardConnection *mgd, 106 171 const gchar *guid) … … 249 314 } 250 315 316 /** 317 * midgard_object_class_get_object_by_path: 318 * @mgd: #MidgardConnection holder 319 * @classname: name of the class for which object should be returned 320 * @object_path: a path, at which object should be found 321 * 322 * This is static method. 323 * 324 * Cases to set NULL: 325 * - object is not found by path 326 * - object's class has neither name nor id member 327 * - object's class doesn't have both: parent and up property 328 * 329 * MidgardError set by this method: 330 * - MGD_ERR_INTERNAL 331 * - MGD_ERR_NOT_EXISTS 332 * 333 * Returns: #MgdObject instance of @classname or %NULL if object is not found 334 */ 251 335 MgdObject *midgard_object_class_get_object_by_path(MidgardConnection *mgd, 252 336 const gchar *classname, const gchar *object_path) … … 382 466 } 383 467 468 /** 469 * midgard_object_class_undelete: 470 * @mgd: MidgardConnection object 471 * @guid: string which should identify object 472 * 473 * Undelete midgard object identified by given @guid 474 * 475 * MidgardError set by this method: 476 * - MGD_ERR_NOT_EXISTS 477 * - MGD_ERR_OBJECT_PURGED 478 * - MGD_ERR_INTERNAL 479 * 480 * Returns: %TRUE on success, %FALSE otherwise 481 */ 384 482 gboolean midgard_object_class_undelete(MidgardConnection *mgd, const gchar *guid) 385 483 { trunk/midgard/core/midgard/src/midgard_object_class.h
r15473 r16574 1 1 /* 2 * Copyright (C) 2005 Piotr Pokora <piotr.pokora@infoglob.pl>2 * Copyright (C) 2005, 2008 Piotr Pokora <piotrek.pokora@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it … … 32 32 #include "midgard_object.h" 33 33 34 /* 35 * \ingroup moc 36 * 37 * Returns the name of object's primary property. 38 * 39 * This is static method. 40 * 41 * /param klass MidgardObjectClass pointer 42 * 43 * /return primary property name 44 * 45 * Returned string is a pointer to object's primary property. 46 * By default , 'guid' property is primary property which uniquely identifies 47 * object's record and object itself. However in some circumstances ( like 48 * backward compatibility ) id property can be defined as primary property. 49 * 50 * You should not use this function. 51 * 52 */ 53 extern const gchar *midgard_object_class_get_primary_property(MidgardObjectClass *klass); 54 55 /* 56 * \ingroup moc 57 * 58 * Returns the name of object's parent property. 59 * 60 * This is static method. 61 * 62 * /param klass MidgardObjectClass pointer 63 * 64 * /return parent property name 65 * 66 * Returned string is a pointer to object's parent property. 67 * Parent property is a property which holds value of field which points to 68 * parent object's identifier. Parent property always points to object's 69 * identifier which is not the same type as given MidgardObjectClass klass. 70 * 71 * NULL is returned if parent property is not found. 72 */ 73 extern const gchar *midgard_object_class_get_property_parent(MidgardObjectClass *klass); 74 75 /* 76 * \ingroup moc 77 * 78 * Returns the name of object's up property. 79 * 80 * This is static method. 81 * 82 * /param klass MidgardObjectClass pointer 83 * 84 * /return up property name 85 * 86 * Returned string is a pointer to object's up property. 87 * Up property is a property which holds value of field which points to 88 * "upper" object's identifier. Up property always points to object's 89 * dentifier which is the same type as given MidgardObjectClass klass. 90 * 91 * NULL is returned if up property is not found. 92 * 93 */ 94 extern const gchar *midgard_object_class_get_property_up(MidgardObjectClass *klass); 95 96 /** 97 * \ingruop moc 98 * 99 * Returns array of childreen tree classes for the given MidgardObjectClass. 100 * 101 * This is static method. 102 * 103 * \param klass , MidgardObjectClass pointer 104 * 105 * Returns newly allocated children tree classes' pointers. 106 * NULL is added as the last array element. 107 * Returned array should be freed if no longer needed without freeing array's elements. 108 * ( Use g_free instead of g_strfreev ) 109 */ 110 extern MidgardObjectClass **midgard_object_class_list_children( 34 const gchar *midgard_object_class_get_primary_property(MidgardObjectClass *klass); 35 const gchar *midgard_object_class_get_property_parent(MidgardObjectClass *klass); 36 const gchar *midgard_object_class_get_property_up(MidgardObjectClass *klass); 37 MidgardObjectClass **midgard_object_class_list_children( 111 38 MidgardObjectClass *klass); 112 113 /** 114 * \ingroup moc 115 * 116 * Checks whether given MidgardObjectClass is multilingual. 117 * 118 * This is static method. 119 * 120 * \param[in] object MidgardObjectClass 121 * 122 * \return TRUE if MidgardObjectClass is mutlilingual, FALSE otherwise. 123 */ 124 extern gboolean midgard_object_class_is_multilang(MidgardObjectClass *klass); 125 126 /** 127 * \ingruop moc 128 * 129 * Returns Midgard Object identified by guid 130 * 131 * This is static method. 132 * 133 * \param mgd, MidgardConnection object 134 * \param guid, guid string which identifies object 135 * 136 * \return MgdObject or NULL 137 * 138 * MidgardError set by this function: 139 * - MGD_ERR_NOT_EXISTS if object is not found 140 * - MGD_ERR_OBJECT_DELETED is object is already deleted 141 * - MGD_ERR_OBJECT_PURGED is object is purged 142 * - MGD_ERR_SITEGROUP_VIOLATION if more than one record exists 143 * 144 * MGD_ERR_SITEGROUP_VIOLATION is returned if function is invoked by root 145 * user and additional sitegroup constraint has been not defined. 146 * 147 */ 148 extern MgdObject *midgard_object_class_get_object_by_guid( 39 gboolean midgard_object_class_is_multilang(MidgardObjectClass *klass); 40 MgdObject *midgard_object_class_get_object_by_guid( 149 41 MidgardConnection *mgd, const gchar *guid); 150 151 /** 152 * \ingroup moc 153 * 154 * Get Midgard Object for the given path. 155 * 156 * This is static method. 157 * 158 * \param mgd, MidgardConnection object 159 * \param classname, name of the class for which object should be returned 160 * \param object_path, a path where object should be found 161 * 162 * \return MgdObject's /c classname instance or NULL if object is not found 163 * 164 * Cases to set NULL: 165 * - object is not found by path 166 * - object's class has no name or id member 167 * - object's class has no parent and up property 168 * 169 * MidgardError set by this method: 170 * - MGD_ERR_INTERNAL 171 */ 172 extern MgdObject *midgard_object_class_get_object_by_path(MidgardConnection *mgd, 42 MgdObject *midgard_object_class_get_object_by_path(MidgardConnection *mgd, 173 43 const gchar *classname, const gchar *object_path); 174 175 /** 176 * \ingroup moc 177 * 178 * Undelete midgard object identified by given guid 179 * 180 * \param mgd, MidgardConnection object 181 * \param guid, string which identifies object 182 * 183 * \return TRUE on success, FALSE otherwise 184 * 185 * MidgardError set by this method: 186 * - MGD_ERR_NOT_EXISTS 187 * - MGD_ERR_OBJECT_PURGED 188 * - MGD_ERR_INTERNAL 189 */ 190 extern gboolean midgard_object_class_undelete(MidgardConnection *mgd, const gchar *guid);
