API
libJentchina.h
/*
* libJentchina.h
* Part of the Birds Lake project
* STRASSER Michel <michelNOSPAM.strasserNOSPAM@freeNOSPAM.frNOSPAM>
* 20040414_0945 Initial Release
* */
#ifndef __LIB_JENTCHINA_H__
#define __LIB_JENTCHINA_H__
#include <Jentchina/JentchinaObj.h>
#include <Jentchina/JentchinaTreeModel.h>
#endif
JentchinaObj.h
/* Jentchina - Obj
* STRASSER Michel - 20040406 init
* */
#ifndef __JENTCHINA_OBJ_H__
#define __JENTCHINA_OBJ_H__
#include <glib.h>
#include <glib-object.h>
#include <lsmlib.h>
#define JENTCHINA_TYPE_OBJ (JentchinaObj_getType ())
#define JENTCHINA_OBJ(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), JENTCHINA_TYPE_OBJ, JentchinaObj))
#define JENTCHINA_OBJ_CLASS(object) (G_TYPE_CHECK_CLASS_CAST ((object), JENTCHINA_TYPE_OBJ, JentchinaObjClass))
#define JENTCHINA_IS_OBJ(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), \
JENTCHINA_TYPE_OBJ))
#define JENTCHINA_IS_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
JENTCHINA_TYPE_OBJ))
#define JENTCHINA_OBJ_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
#define JENTCHINA_OBJ_TYPE_NAME(object) (g_type_name (JENTCHINA_OBJ_TYPE (object)))
typedef struct _JentchinaObj JentchinaObj;
typedef struct _JentchinaObjClass JentchinaObjClass;
#ifndef JENTCHINA_ITER
#define JENTCHINA_ITER
typedef guint32 JentchinaIter;
#endif
typedef enum {
JentchinaFilterType_IMPORT,
JentchinaFilterType_EXPORT,
JentchinaFilterType_NUM
} JentchinaFilterType;
typedef enum {
JentchinaTreeModelType_SERVER,
/* JentchinaTreeModelType_CATEGORY, TODO later */
JentchinaTreeModelType_NUM
} JentchinaTreeModelType;
typedef enum {
/* TODO */
JentchinaStatus_OK,
JentchinaStatus_BAD_OBJ,
JentchinaStatus_INVALID_ITER,
JentchinaStatus_INVALID_SESSION_KEY,
JentchinaStatus_APPLY_FILTER_ERROR,
JentchinaStatus_SYSTEM_ERROR, /* may be network error */
JentchinaStatus_NUM
} JentchinaStatus;
struct _JentchinaObj
{
GObject parent_instance;
/* private */
GObject* cnl; /* JnaCnlJentchina */
};
struct _JentchinaObjClass
{
GObjectClass parent_class;
};
G_BEGIN_DECLS
GType
JentchinaObj_getType (void);
GObject*
JentchinaObj_new (char* appName);
GObject* /* JentchinaTreeModel */
JentchinaObj_getNewModel (JentchinaObj* self,
JentchinaFilterType filterType,
JentchinaTreeModelType modelType);
JentchinaStatus
JentchinaObj_getRendezVous (JentchinaObj* self,
JentchinaIter in_iter,
char* in_user,
char* in_password,
LsmTree* in_doc,
GList** out_interfaces, /* newly allocated, list of string */
int* out_vortexLifeTime, /* not supported yet */
char** out_sessionKey); /* newly allocated */
JentchinaStatus
JentchinaObj_applyFilter (JentchinaObj* self,
char* in_sessionKey,
char* in_interfacesStream,
LsmTree** out_filteredDoc); /* newly allocated */
JentchinaStatus
JentchinaObj_getInfos (JentchinaObj* self,
JentchinaIter in_iter,
char** out_serverName, /* newly allocated */
char** out_serverPic, /* newly allocated */
char** out_filterName, /* newly allocated */
int* out_version,
char** out_year, /* newly allocated */
char** out_license, /* newly allocated */
char** out_application, /* newly allocated */
char** out_info, /* newly allocated */
GList** out_authors, /* newly allocated, list of string */
char** out_filterPic); /* newly allocated */
JentchinaStatus
JentchinaObj_getAuthorInfos (JentchinaObj* self,
JentchinaIter iter,
char* in_id,
char** out_name, /* newly allocated */
char** out_email, /* newly allocated */
char** out_picture); /* newly allocated */
void
JentchinaObj_setData (JentchinaObj* self,
JentchinaIter iter,
int data); /* you may cast your data with GPOINTER_TO_INT */
int /* you may cast your data with INT_TO_GPOINTER */
JentchinaObj_getData (JentchinaObj* self,
JentchinaIter iter);
/* for debugging purposes only, prints a Java's toString() alike string of the actual state, this may be very verbose */
void
JentchinaObj_print (JentchinaObj* self);
G_END_DECLS
#endif /* __JENTCHINA_OBJ_H__ */
JentchinaTreeModel.h
/* Jentchina - TreeModel
* STRASSER Michel - 20040405 init
* */
#ifndef __JENTCHINA_TREE_MODEL_H__
#define __JENTCHINA_TREE_MODEL_H__
#include <glib.h>
#include <glib-object.h>
#define JENTCHINA_TYPE_TREE_MODEL (JentchinaTreeModel_getType ())
#define JENTCHINA_TREE_MODEL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), JENTCHINA_TYPE_TREE_MODEL, JentchinaTreeModel))
#define JENTCHINA_TREE_MODEL_CLASS(object) (G_TYPE_CHECK_CLASS_CAST ((object), JENTCHINA_TYPE_TREE_MODEL, JentchinaTreeModelClass))
#define JENTCHINA_IS_TREE_MODEL(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), \
JENTCHINA_TYPE_TREE_MODEL))
#define JENTCHINA_IS_TREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
JENTCHINA_TYPE_TREE_MODEL))
#define JENTCHINA_TREE_MODEL_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
#define JENTCHINA_TREE_MODEL_TYPE_NAME(object) (g_type_name (JENTCHINA_TREE_MODEL_TYPE (object)))
typedef struct _JentchinaTreeModel JentchinaTreeModel;
typedef struct _JentchinaTreeModelClass JentchinaTreeModelClass;
#ifndef JENTCHINA_ITER
#define JENTCHINA_ITER
typedef guint32 JentchinaIter;
#endif
struct _JentchinaTreeModel
{
GObject parent_instance;
};
struct _JentchinaTreeModelClass
{
GObjectClass parent_class;
gint (*getNColumns) (JentchinaTreeModel* self);
GType (*getColumnType) (JentchinaTreeModel* self,
gint index);
gboolean (*getIter) (JentchinaTreeModel* self,
JentchinaIter* out_iter,
char* path);
char* (*getPath) (JentchinaTreeModel* self,
JentchinaIter iter);
void (*getValue) (JentchinaTreeModel* self,
JentchinaIter iter,
gint column,
GValue* out_value);
gboolean (*iterNext) (JentchinaTreeModel* self,
JentchinaIter* inOut_iter);
gboolean (*iterChildren) (JentchinaTreeModel* self,
JentchinaIter* out_iter,
JentchinaIter parent);
gboolean (*iterHasChild) (JentchinaTreeModel* self,
JentchinaIter iter);
gint (*iterNChildren) (JentchinaTreeModel* self,
JentchinaIter iter);
gboolean (*iterNthChild) (JentchinaTreeModel* self,
JentchinaIter* out_iter,
JentchinaIter parent,
int n);
gboolean (*iterParent) (JentchinaTreeModel* self,
JentchinaIter* out_iter,
JentchinaIter child);
};
G_BEGIN_DECLS
GType
JentchinaTreeModel_getType (void);
/* README :
*
* There is no constructor since it is an abstract class
* People using this class through the API should get a reference of such an object by using
* a JentchinaObj like a factory
*
* The API is optimized for bringing an implementation of a view in GTK with minimal
* efforts. If one had not a MVC compliant GUI toolkit used over Jentchina, we may want to use
* the setData / getData methods in order to store for each node a reference to the "graphical node".
* Cast any pointer to int in that case.
* */
gint
JentchinaTreeModel_getNColumns (JentchinaTreeModel* self);
GType
JentchinaTreeModel_getColumnType (JentchinaTreeModel* self,
gint index);
gboolean
JentchinaTreeModel_getIter (JentchinaTreeModel* self,
JentchinaIter* out_iter,
char* path);
char* /* newly allocated */
JentchinaTreeModel_getPath (JentchinaTreeModel* self,
JentchinaIter iter);
void
JentchinaTreeModel_getValue (JentchinaTreeModel* self,
JentchinaIter iter,
gint column,
GValue* out_value);
gboolean
JentchinaTreeModel_iterNext (JentchinaTreeModel* self,
JentchinaIter* inOut_iter);
gboolean
JentchinaTreeModel_iterChildren (JentchinaTreeModel* self,
JentchinaIter* out_iter,
JentchinaIter parent);
gboolean
JentchinaTreeModel_iterHasChild (JentchinaTreeModel* self,
JentchinaIter iter);
gint
JentchinaTreeModel_iterNChildren (JentchinaTreeModel* self,
JentchinaIter iter);
gboolean
JentchinaTreeModel_iterNthChild (JentchinaTreeModel* self,
JentchinaIter* out_iter,
JentchinaIter parent,
int n);
gboolean
JentchinaTreeModel_iterParent (JentchinaTreeModel* self,
JentchinaIter* out_iter,
JentchinaIter child);
void
JentchinaTreeModel_print (JentchinaTreeModel* self,
int maxDepth,
int maxNext);
G_END_DECLS
#endif /* __JENTCHINA_TREE_MODEL_H__ */