StorageStore API
- From: Marco Pesenti Gritti <marco gnome org>
- To: storage-list gnome org
- Subject: StorageStore API
- Date: Thu, 11 Sep 2003 19:34:53 +0200
Attached are the headers for:
- StorageStore
As suggested by set support two convenience constructors
for local/remote login.
Do you think do_query should return nodes or a list
of identifiers ?
- StorageQuery
The logic is based on RBFilter. The idea is that you construct
the query using normal C api and pass the object to the store
when doing a query. It has a private to_sql function that the
store can use to make the actual query on the db and return the
matching items.
- StorageItem
Removed the parts that are now in the store and changed the _new
to accept a StorageStore argument.
What do you think ?
If it make sense, I can go ahead and try to implement it, otherwise
suggestions would very welcome.
Marco
#ifndef STORAGE_ITEM_H
#define STORAGE_ITEM_H
#include <glib/gerror.h>
#include <glib-object.h>
#include <libgnomevfs/gnome-vfs.h>
G_BEGIN_DECLS
/* predefined list of attributes */
#define STORAGE_FILE_NAME "title"
#define STORAGE_FILE_SIZE "size"
#define STORAGE_FILE_TEXT "content"
#define STORAGE_FILE_MIME "mimetype"
#define STORAGE_FILE_BLOB "blobid"
#define STORAGE_FILE_PERM "permissions"
#define STORAGE_FILE_ACCESS "access_time"
#define STORAGE_FILE_MODIFICATION "modification_time"
#define STORAGE_FILE_CREATION "creation_time"
#define STORAGE_FILE_DATE "date"
#define STORAGE_FILE_LENGTH "length"
#define STORAGE_FILE_WIDTH "width"
#define STORAGE_FILE_HEIGHT "height"
#define STORAGE_FILE_BITRATE "bitrate"
#define STORAGE_FILE_DURATION "duration"
#define STORAGE_FILE_PAGES "pages"
#define STORAGE_FILE_YEAR "year"
#define STORAGE_FILE_TRACK "track"
#define STORAGE_FILE_THUMBNAIL "thumbnail"
#define STORAGE_FILE_PIXELDEPTH "pixeldepth"
#define STORAGE_TYPE_ITEM (storage_item_get_type ())
#define STORAGE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STORAGE_TYPE_ITEM, StorageItem))
#define STORAGE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STORAGE_TYPE_ITEM, StorageItemClass))
#define STORAGE_IS_ITEM(obj) (GTK_TYPE_CHECK_INSTANCE_TYPE ((obj), STORAGE_TYPE_ITEM))
#define STORAGE_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STORAGE_TYPE_ITEM))
#define STORAGE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STORAGE_TYPE_ITEM, StorageItemClass))
typedef struct _StorageInterfacePrivate StorageInterfacePrivate;
typedef struct _StorageAttrPair StorageAttrPair;
typedef struct _StorageItem StorageItem;
typedef struct _StorageItemClass StorageItemClass;
typedef enum
{
STORAGE_ITEM_TYPE_NODE,
STORAGE_ITEM_TYPE_TEXT,
STORAGE_ITEM_TYPE_BINARY
} StorageItemType;
GType storage_item_type_get_type (void);
typedef enum
{
storageStringType,
storageIntType,
storageTimeType
} StorageDataType;
#define STORAGE_TYPE_ITEM_TYPE (storage_item_type_get_type ())
struct _StorageAttrPair
{
char *name;
char *value;
};
struct _StorageItem
{
GObject parent_instance;
StorageInterfacePrivate *privy;
};
struct _StorageItemClass
{
GObjectClass parent_class;
};
GType storage_item_get_type (void);
GObject *storage_item_new (StorageStore *store,
StorageItemType type);
void storage_item_remove (StorageItem *item);
void storage_item_remove_ext (StorageItem *item,
gboolean dontTouchChildren,
gboolean dontTouchTopLevelRecs,
gboolean dontTouchMultiParentChildren);
char *storage_item_get_uri (StorageItem *item);
char *storage_item_get_id (StorageItem *item);
guint storage_item_get_n_parents (StorageItem *item);
GSList* storage_item_get_parents (StorageItem *item);
int storage_item_insert_child (StorageItem *item,
StorageItem *child,
int childNum);
guint storage_item_n_children (StorageItem *item);
GSList *storage_item_get_children (StorageItem *item);
StorageItem *storage_item_get_nth_child (StorageItem *item,
guint childNum);
int storage_item_sever_nth_child (StorageItem *item,
int childNum);
guint storage_item_n_attributes (StorageItem *item);
GSList *storage_item_get_attributes_pairs (StorageItem *item);
gboolean storage_item_has_attribute (StorageItem *item,
const char *attrName);
char *storage_item_get_attribute_value (StorageItem *item,
const char *attrName);
void storage_item_set_attribute_value (StorageItem *item,
const char *attrName,
const char *new_attrValue);
void storage_item_delete_attribute (StorageItem *item,
const char *attrName);
void storage_item_cache_all_attributes (StorageItem *item);
guint storage_item_get_approx_size (StorageItem *item);
char *storage_item_read_entire_binary (StorageItem *item,
int *result_binary_size);
GnomeVFSHandle *storage_item_get_handle (StorageItem *item);
StorageDataType storage_get_type_from_attribute (char *attrname);
/* Some stuff we are unsure. Do not use */
#define STORAGE_FILE_TOP "top_level" /* must pass it a value of "[T|t].*" or "[F|f].*" */
#define STORAGE_FILE_UID "uid"
#define STORAGE_FILE_GID "gid"
G_END_DECLS
#endif /* GNOME_STORAGE_INTERFACE_H */
#ifndef STORAGE_QUERY_H
#define STORAGE_QUERY_H
#include <glib-object.h>
G_BEGIN_DECLS
#define STORAGE_TYPE_QUERY (storage_item_get_type ())
#define STORAGE_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STORAGE_TYPE_QUERY, StorageQuery))
#define STORAGE_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STORAGE_TYPE_QUERY, StorageQueryClass))
#define STORAGE_IS_QUERY(obj) (GTK_TYPE_CHECK_INSTANCE_TYPE ((obj), STORAGE_TYPE_QUERY))
#define STORAGE_IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STORAGE_TYPE_QUERY))
#define STORAGE_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STORAGE_TYPE_QUERY, StorageQueryClass))
typedef struct _StorageQuery StorageQuery;
typedef struct _StorageQueryClass StorageQueryClass;
struct _StorageQuery
{
GObject parent_instance;
StorageQuery *priv;
};
struct _StorageQueryClass
{
GObjectClass parent_class;
};
typedef enum
{
STORAGE_QUERY_EXPR_ATTRIBUTE_CONTAINS, /* args: const char *attr_name, const char *string */
STORAGE_QUERY_EXPR_ATTRIBUTE_EQUALS, /* args: const char *attr_name, const char *string */
} StorageQueryExpression;
/* The filter starts iterating over all expressions at level 0,
* if one of them is TRUE it continues to level 1, etc.
* If it still has TRUE when there are no more expressions at the
* next level, the result is TRUE. Otherwise, it's FALSE.
*/
GType storage_query_get_type (void);
StorageQuery *storage_query_new (void);
void storage_query_add_expression (StorageQuery *query,
StorageQueryExpression *expression,
int level,
...);
/* Private */
char *_storage_query_to_sql (StorageQuery *query);
G_END_DECLS
#endif /* STORAGE_QUERY_H */
#ifndef STORAGE_STORE_H
#define STORAGE_STORE_H
#include <glib-object.h>
G_BEGIN_DECLS
#define STORAGE_TYPE_STORE (storage_item_get_type ())
#define STORAGE_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STORAGE_TYPE_STORE, StorageStore))
#define STORAGE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STORAGE_TYPE_STORE, StorageStoreClass))
#define STORAGE_IS_STORE(obj) (GTK_TYPE_CHECK_INSTANCE_TYPE ((obj), STORAGE_TYPE_STORE))
#define STORAGE_IS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STORAGE_TYPE_STORE))
#define STORAGE_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STORAGE_TYPE_STORE, StorageStoreClass))
typedef struct _StorageStore StorageStore;
typedef struct _StorageStoreClass StorageStoreClass;
struct _StorageStore
{
GObject parent_instance;
StorageStore *priv;
};
struct _StorageStoreClass
{
GObjectClass parent_class;
};
GType storage_store_get_type (void);
StorageStore *storage_store_new (void);
GObject *storage_store_new_with_login (const char *hostname,
const char *username,
const char *password);
StorageItem *storage_store_get_item_from_id (StorageStore *store,
const char *id);
StorageItem *storage_store_get_item_from_uri (StorageStore *store,
const char *uri);
GList *storage_store_do_query (StorageStore *store,
StorageQuery *query);
G_END_DECLS
#endif /* STORAGE_STORE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]