MidgardObject attachments

MidgardObject attachments

Synopsis

#include <midgard/midgard.h>

MidgardObject *     midgard_object_create_attachment    (MidgardObject *self,
                                                         const gchar *name,
                                                         const gchar *title,
                                                         const gchar *mimetype);
MidgardObject **    midgard_object_list_attachments     (MidgardObject *self,
                                                         guint *n_objects);
MidgardObject **    midgard_object_find_attachments     (MidgardObject *self,
                                                         guint n_params,
                                                         const GParameter *parameters);
gboolean            midgard_object_has_attachments      (MidgardObject *self);
gboolean            midgard_object_delete_attachments   (MidgardObject *self,
                                                         guint n_params,
                                                         const GParameter *parameters);
gboolean            midgard_object_purge_attachments    (MidgardObject *self,
                                                         gboolean delete_blob,
                                                         guint n_params,
                                                         const GParameter *parameters);

Description

Details

midgard_object_create_attachment ()

MidgardObject *     midgard_object_create_attachment    (MidgardObject *self,
                                                         const gchar *name,
                                                         const gchar *title,
                                                         const gchar *mimetype);

Creates object's attachment using given properties. Any property may be explicitly set to NULL.

self :

MidgardObject instance

name :

name for attachment

title :

its title

mimetype :

and mimetype

Returns :

newly created MidgardObject of midgard_attachment class or NULL on failure. [transfer full]

midgard_object_list_attachments ()

MidgardObject **    midgard_object_list_attachments     (MidgardObject *self,
                                                         guint *n_objects);

Returned objects are midgard_attachment class. Attachments objects are fetched from database unconditionally. That is, only those which parent guid property matches object's guid.

Returned array should be freed when no longer needed.

self :

a MidgardObject self instance

n_objects :

pointer to store number of returned objects. [out]

Returns :

Newly allocated and NULL terminated array of midgard_attachment objects. [array length=n_objects][transfer full]

midgard_object_find_attachments ()

MidgardObject **    midgard_object_find_attachments     (MidgardObject *self,
                                                         guint n_params,
                                                         const GParameter *parameters);

Find object's attachment(s) with matching given properties. parameters argument is optional. All object's attachments are returned ( if exist ) if parameters is explicitly set to NULL.

self :

MidgardObject instance

n_params :

number of properties

parameters :

properties list

Returns :

newly created, NULL terminated array of MidgardObject ( midgard_attachment class ) or NULL on failure. [transfer full]

midgard_object_has_attachments ()

gboolean            midgard_object_has_attachments      (MidgardObject *self);

self :

MidgardObject instance

Returns :

TRUE if object has attachments, FALSE otherwise.

midgard_object_delete_attachments ()

gboolean            midgard_object_delete_attachments   (MidgardObject *self,
                                                         guint n_params,
                                                         const GParameter *parameters);

Delete object's attachments(s) which match given properties' values. Properties list in parameters is optional. All object's attachments are deleted ( if exist ) if parameters is explicitly set to NULL.

self :

MidgardObject instance

n_params :

number of properties

parameters :

properties list. [allow-none]

Returns :

TRUE on success, FALSE if at least one of the attachment could not be deleted

midgard_object_purge_attachments ()

gboolean            midgard_object_purge_attachments    (MidgardObject *self,
                                                         gboolean delete_blob,
                                                         guint n_params,
                                                         const GParameter *parameters);

Purge object's attachments(s) which match given properties' values. Properties list in parameters is optional. All object's attachments are purged ( if exist ) if parameters is explicitly set to NULL.

delete_blob should be set to TRUE if midgard_attachment holds a reference to blob located on filesystem ( it should be set to TRUE by default ). However, if midgard_attachment is created for blobs sharing and file should not be deleted, delete_blob should be set to FALSE.

There's no way to determine if midgard_attachment is sharing blob, so aplication itelf is responsible to create such own logic.

self :

MidgardObject instance

delete_blob :

whether blob should be deleted as well

n_params :

number of properties

parameters :

properties list. [allow-none]

Returns :

TRUE on success, FALSE if at least one of the attachment could not be purged