From 542764c8b27141036a391f6cdc6bd0256a564d10 Mon Sep 17 00:00:00 2001 From: Florian Boor Date: Tue, 9 May 2006 15:59:20 +0000 Subject: [PATCH] Add account preset object draft. pmo-trunk-r20 --- experimental/ChangeLog | 3 + experimental/accountpresets/Makefile | 13 ++ .../accountpresets/modest-account-presets.c | 129 ++++++++++++++++++++ .../accountpresets/modest-account-presets.h | 65 ++++++++++ .../accountpresets/test-modest-account-presets.c | 16 +++ 5 files changed, 226 insertions(+) create mode 100644 experimental/ChangeLog create mode 100644 experimental/accountpresets/Makefile create mode 100644 experimental/accountpresets/modest-account-presets.c create mode 100644 experimental/accountpresets/modest-account-presets.h create mode 100644 experimental/accountpresets/test-modest-account-presets.c diff --git a/experimental/ChangeLog b/experimental/ChangeLog new file mode 100644 index 0000000..fddf484 --- /dev/null +++ b/experimental/ChangeLog @@ -0,0 +1,3 @@ +2006-05-09 Florian Boor + + * Add account preset object draft. diff --git a/experimental/accountpresets/Makefile b/experimental/accountpresets/Makefile new file mode 100644 index 0000000..3751496 --- /dev/null +++ b/experimental/accountpresets/Makefile @@ -0,0 +1,13 @@ +# Makefile for testing ModestAccountPresets + +test-modest-account-presets: modest-account-presets.o test-modest-account-presets.o + $(CC) -o test-modest-account-presets test-modest-account-presets.o modest-account-presets.o `pkg-config --libs gobject-2.0` + +modest-account-presets.o: modest-account-presets.c modest-account-presets.h + $(CC) -c modest-account-presets.c -g -Wall `pkg-config --cflags gobject-2.0` + +test-modest-account-presets.o: test-modest-account-presets.c modest-account-presets.h + $(CC) -c test-modest-account-presets.c -g -Wall `pkg-config --cflags gobject-2.0` + +clean: + rm -f *.o *~ core diff --git a/experimental/accountpresets/modest-account-presets.c b/experimental/accountpresets/modest-account-presets.c new file mode 100644 index 0000000..cdea9d7 --- /dev/null +++ b/experimental/accountpresets/modest-account-presets.c @@ -0,0 +1,129 @@ +/* modest-account-presets.c */ + +/* insert (c)/licensing information) */ + +#include "modest-account-presets.h" +/* include other impl specific header files */ + +/* 'private'/'protected' functions */ +static void modest_account_presets_class_init (ModestAccountPresetsClass *klass); +static void modest_account_presets_init (ModestAccountPresets *obj); +static void modest_account_presets_finalize (GObject *obj); + +/* list my signals */ +enum { + /* MY_SIGNAL_1, */ + /* MY_SIGNAL_2, */ + LAST_SIGNAL +}; + +typedef struct _ModestAccountPresetsPrivate ModestAccountPresetsPrivate; +struct _ModestAccountPresetsPrivate { + /* my private members go here, eg. */ + GKeyFile *preset_file; + GList *preset_list; +}; +#define MODEST_ACCOUNT_PRESETS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ + MODEST_TYPE_ACCOUNT_PRESETS, \ + ModestAccountPresetsPrivate)) +/* globals */ +static GObjectClass *parent_class = NULL; + +/* uncomment the following if you have defined any signals */ +/* static guint signals[LAST_SIGNAL] = {0}; */ + +GType +modest_account_presets_get_type (void) +{ + static GType my_type = 0; + if (!my_type) { + static const GTypeInfo my_info = { + sizeof(ModestAccountPresetsClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) modest_account_presets_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof(ModestAccountPresets), + 1, /* n_preallocs */ + (GInstanceInitFunc) modest_account_presets_init, + }; + my_type = g_type_register_static (G_TYPE_OBJECT, + "ModestAccountPresets", + &my_info, 0); + } + return my_type; +} + +static void +modest_account_presets_class_init (ModestAccountPresetsClass *klass) +{ + GObjectClass *gobject_class; + gobject_class = (GObjectClass*) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = modest_account_presets_finalize; + + g_type_class_add_private (gobject_class, sizeof(ModestAccountPresetsPrivate)); + + klass->get_list = modest_account_presets_get_list; + klass->get_names = modest_account_presets_get_names; + klass->get_by_name = modest_account_presets_get_by_name; + klass->load_file = modest_account_presets_load_file; + /* signal definitions go here, e.g.: */ +/* signals[MY_SIGNAL_1] = */ +/* g_signal_new ("my_signal_1",....); */ +/* signals[MY_SIGNAL_2] = */ +/* g_signal_new ("my_signal_2",....); */ +/* etc. */ +} + +static void +modest_account_presets_init (ModestAccountPresets *obj) +{ + ModestAccountPresetsPrivate *priv = MODEST_ACCOUNT_PRESETS_GET_PRIVATE(obj); + + priv->preset_file = g_key_file_new (); + priv->preset_list = NULL; + obj->count = 0; +} + +static void +modest_account_presets_finalize (GObject *obj) +{ + ModestAccountPresetsPrivate *priv = MODEST_ACCOUNT_PRESETS_GET_PRIVATE(obj); + + g_object_unref (priv->preset_file); +} + +GObject* +modest_account_presets_new (void) +{ + return G_OBJECT(g_object_new(MODEST_TYPE_ACCOUNT_PRESETS, NULL)); +} + +/* method implementations */ + +GList * +modest_account_presets_get_list (ModestAccountPresets *self) +{ + +} + +GList * +modest_account_presets_get_names (ModestAccountPresets *self) +{ +} + +ModestPreset * +modest_account_presets_get_by_name (ModestAccountPresets *self, const gchar *name) +{ + +} + +gboolean +modest_account_presets_load_file (ModestAccountPresets *self, const gchar *filename) +{ + + return TRUE; +} diff --git a/experimental/accountpresets/modest-account-presets.h b/experimental/accountpresets/modest-account-presets.h new file mode 100644 index 0000000..cdc5613 --- /dev/null +++ b/experimental/accountpresets/modest-account-presets.h @@ -0,0 +1,65 @@ +/* modest-account-presets.h */ +/* insert (c)/licensing information) */ + +#ifndef __MODEST_ACCOUNT_PRESETS_H__ +#define __MODEST_ACCOUNT_PRESETS_H__ + +#include +/* other include files */ + +G_BEGIN_DECLS + +/* convenience macros */ +#define MODEST_TYPE_ACCOUNT_PRESETS (modest_account_presets_get_type()) +#define MODEST_ACCOUNT_PRESETS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_PRESETS,ModestAccountPresets)) +#define MODEST_ACCOUNT_PRESETS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_PRESETS,GObject)) +#define MODEST_IS_ACCOUNT_PRESETS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_PRESETS)) +#define MODEST_IS_ACCOUNT_PRESETS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_PRESETS)) +#define MODEST_ACCOUNT_PRESETS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_PRESETS,ModestAccountPresetsClass)) + +typedef struct _ModestAccountPresets ModestAccountPresets; +typedef struct _ModestAccountPresetsClass ModestAccountPresetsClass; + +typedef struct _ModestPreset ModestPreset; + +struct _ModestAccountPresets { + GObject parent; + /* public members */ + gint count; /* number of available presets */ +}; + +struct _ModestAccountPresetsClass { + GObjectClass parent_class; + GList * (* get_list) (ModestAccountPresets *self); + GList * (* get_names) (ModestAccountPresets *self); + ModestPreset * (* get_by_name) (ModestAccountPresets *self, const gchar *name); + gboolean (* load_file) (ModestAccountPresets *self, const gchar *filename); +}; + +/* data type to hold an account preset dataset */ +struct _ModestPreset { + gchar *name; + gchar *transport_server; + gchar *storage_server; + gint transport_port; + gint storage_port; + /* add security stuff */ + gchar *note; +}; + +/* member functions */ +GType modest_account_presets_get_type (void) G_GNUC_CONST; + +/* typical parameter-less _new function */ +GObject* modest_account_presets_new (void); + +/* public methods */ +GList *modest_account_presets_get_list (ModestAccountPresets *self); +GList *modest_account_presets_get_names (ModestAccountPresets *self); +ModestPreset *modest_account_presets_get_by_name (ModestAccountPresets *self, const gchar *name); +gboolean modest_account_presets_load_file (ModestAccountPresets *self, const gchar *filename); + + +G_END_DECLS + +#endif /* __MODEST_ACCOUNT_PRESETS_H__ */ diff --git a/experimental/accountpresets/test-modest-account-presets.c b/experimental/accountpresets/test-modest-account-presets.c new file mode 100644 index 0000000..7a39522 --- /dev/null +++ b/experimental/accountpresets/test-modest-account-presets.c @@ -0,0 +1,16 @@ +/* unit test for the ModestAccountPresets implementation */ + +#include "modest-account-presets.h" + +int +main (int argc, char* argv[]) +{ + GObject *obj; + + g_type_init (); + + obj = modest_account_presets_new (); +/* do something interesting with our brand new object */ + + return 0; +} -- 1.7.9.5