From 4bcb88671521e0996f1d9886cfa3715bfefdd1a5 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 8 Aug 2006 09:10:14 +0000 Subject: [PATCH] * remove unneeded files pmo-trunk-r467 --- src/modest-identity-keys.h | 54 ----- src/modest-identity-mgr.c | 580 -------------------------------------------- src/modest-identity-mgr.h | 277 --------------------- src/modest-window-mgr.c | 228 ----------------- src/modest-window-mgr.h | 141 ----------- 5 files changed, 1280 deletions(-) delete mode 100644 src/modest-identity-keys.h delete mode 100644 src/modest-identity-mgr.c delete mode 100644 src/modest-identity-mgr.h delete mode 100644 src/modest-window-mgr.c delete mode 100644 src/modest-window-mgr.h diff --git a/src/modest-identity-keys.h b/src/modest-identity-keys.h deleted file mode 100644 index 5ef95b6..0000000 --- a/src/modest-identity-keys.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2006, Nokia Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the Nokia Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef __MODEST_IDENTITY_KEYS_H__ -#define __MODEST_IDENTITY_KEYS_H__ - -#include "modest-conf-keys.h" - -#define MODEST_IDENTITY_DEFAULT_IDENTITY "default" - - -/* configuration key definitions for modest */ -#define MODEST_IDENTITY_NAMESPACE MODEST_CONF_NAMESPACE "/" "identities" - -/* user identity keys */ -#define MODEST_IDENTITY_DISPLAY_NAME "display_name" /* string */ -#define MODEST_IDENTITY_REALNAME "realname" /* string */ -#define MODEST_IDENTITY_EMAIL "email" /* string */ -#define MODEST_IDENTITY_EMAIL_ALTERNATIVES "email_alternatives" /* string */ -#define MODEST_IDENTITY_REPLYTO "replyto" /* string */ -#define MODEST_IDENTITY_SIGNATURE "signature" /* string */ -#define MODEST_IDENTITY_USE_SIGNATURE "use_signature" /* boolean */ -#define MODEST_IDENTITY_ID_VIA "id_via" /* string */ -#define MODEST_IDENTITY_USE_ID_VIA "use_id_via" /* boolean */ -/* MISSING: everything related to gpg */ - -#endif /*__MODEST_IDENTITY_KEYS_H__*/ diff --git a/src/modest-identity-mgr.c b/src/modest-identity-mgr.c deleted file mode 100644 index 7998b60..0000000 --- a/src/modest-identity-mgr.c +++ /dev/null @@ -1,580 +0,0 @@ -/* Copyright (c) 2006, Nokia Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the Nokia Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* modest-identity-mgr.c */ - -#include -#include "modest-marshal.h" -#include "modest-identity-mgr.h" - -/* 'private'/'protected' functions */ -static void modest_identity_mgr_class_init (ModestIdentityMgrClass * klass); -static void modest_identity_mgr_init (ModestIdentityMgr * obj); -static void modest_identity_mgr_finalize (GObject * obj); - -static gchar *get_identity_keyname (const gchar * accname, - const gchar * name); - -/* list my signals */ -enum { - IDENTITY_CHANGE_SIGNAL, - IDENTITY_REMOVE_SIGNAL, - IDENTITY_ADD_SIGNAL, - LAST_SIGNAL -}; - -typedef struct _ModestIdentityMgrPrivate ModestIdentityMgrPrivate; -struct _ModestIdentityMgrPrivate { - ModestConf *modest_conf; - GSList *current_identities; -}; - -#define MODEST_IDENTITY_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ - MODEST_TYPE_IDENTITY_MGR, \ - ModestIdentityMgrPrivate)) -/* globals */ -static GObjectClass *parent_class = NULL; - -/* uncomment the following if you have defined any signals */ -static guint signals[LAST_SIGNAL] = {0}; - - -static GSList * -delete_account_from_list (GSList *list, const gchar *name) -{ - GSList *iter, *result; - - iter = list; - result = list; - while (iter) { - if (!strcmp (name, iter->data)) { - result = g_slist_delete_link (list, iter); - break; - } - - iter = g_slist_next (iter); - } - return result; -} - -static GSList * -find_account_in_list (GSList *list, const gchar *name) -{ - GSList *iter, *result; - - iter = list; - result = list; - while (iter) { - if (!strcmp (name, iter->data)) { - return iter; - break; - } - - iter = g_slist_next (iter); - } - return NULL; -} - - -static void -modest_identity_mgr_check_change (ModestConf *conf, - const gchar *key, - const gchar *new_value, - gpointer userdata) -{ - ModestIdentityMgr *id_mgr = userdata; - ModestIdentityMgrPrivate *priv = MODEST_IDENTITY_MGR_GET_PRIVATE(id_mgr); - gchar *subkey; - gchar *param; - - if ((strlen(key) > strlen(MODEST_IDENTITY_NAMESPACE "/") - && g_str_has_prefix(key, MODEST_IDENTITY_NAMESPACE))) { - subkey = g_strdup(key + strlen(MODEST_IDENTITY_NAMESPACE "/")); - if (! strstr(subkey, "/")) { /* no more '/' means an entry was modified */ - if (!new_value) { - priv->current_identities = - delete_account_from_list (priv->current_identities, subkey); - g_signal_emit(id_mgr, signals[IDENTITY_REMOVE_SIGNAL], 0, subkey); - } - } - else { - param = strstr(subkey, "/"); - param[0] = 0; - param++; - - if (!find_account_in_list(priv->current_identities, subkey)) { - priv->current_identities = - g_slist_prepend(priv->current_identities, g_strdup(subkey)); - g_signal_emit(id_mgr, signals[IDENTITY_ADD_SIGNAL], 0, subkey); - } - g_signal_emit(id_mgr, signals[IDENTITY_CHANGE_SIGNAL], 0, subkey, param, new_value); - } - g_free(subkey); - } -} - -GType -modest_identity_mgr_get_type (void) -{ - static GType my_type = 0; - - if (!my_type) { - static const GTypeInfo my_info = { - sizeof (ModestIdentityMgrClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc) modest_identity_mgr_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (ModestIdentityMgr), - 1, /* n_preallocs */ - (GInstanceInitFunc) modest_identity_mgr_init, - }; - - my_type = g_type_register_static (G_TYPE_OBJECT, - "ModestIdentityMgr", - &my_info, 0); - } - return my_type; -} - -static void -modest_identity_mgr_class_init (ModestIdentityMgrClass * klass) -{ - GObjectClass *gobject_class; - GType paramtypes[3] = {G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER}; - - gobject_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = modest_identity_mgr_finalize; - - g_type_class_add_private (gobject_class, - sizeof (ModestIdentityMgrPrivate)); - - /* signal definitions */ - signals[IDENTITY_ADD_SIGNAL] = - g_signal_newv ("identity-add", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - NULL, NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, paramtypes); - - signals[IDENTITY_REMOVE_SIGNAL] = - g_signal_newv ("identity-remove", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - NULL, NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, paramtypes); - signals[IDENTITY_CHANGE_SIGNAL] = - g_signal_newv ("identity-change", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - NULL, NULL, NULL, - modest_marshal_VOID__POINTER_POINTER_POINTER, - G_TYPE_NONE, 3, paramtypes); -} - - -static void -modest_identity_mgr_init (ModestIdentityMgr * obj) -{ - ModestIdentityMgrPrivate *priv = - MODEST_IDENTITY_MGR_GET_PRIVATE (obj); - priv->modest_conf = NULL; -} - -static void -modest_identity_mgr_finalize (GObject * obj) -{ - ModestIdentityMgr *self = MODEST_IDENTITY_MGR (obj); - ModestIdentityMgrPrivate *priv = - MODEST_IDENTITY_MGR_GET_PRIVATE (self); - - g_object_unref (G_OBJECT (priv->modest_conf)); - priv->modest_conf = NULL; -} - -GObject * -modest_identity_mgr_new (ModestConf * conf) -{ - GObject *obj; - ModestIdentityMgrPrivate *priv; - - g_return_val_if_fail (conf, NULL); - - obj = G_OBJECT (g_object_new (MODEST_TYPE_IDENTITY_MGR, NULL)); - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (obj); - - /* - * increase the ref count on the modest_conf. Normally, the - * ModestConf should outlive the ModestIdentityMgr though - */ - g_object_ref (G_OBJECT (priv->modest_conf = conf)); - - priv->current_identities = modest_identity_mgr_identity_names (MODEST_IDENTITY_MGR(obj), NULL); - - g_signal_connect(G_OBJECT(conf), - "key-changed", - G_CALLBACK (modest_identity_mgr_check_change), - obj); - return obj; -} - - -gboolean -modest_identity_mgr_remove_identity (ModestIdentityMgr * self, - const gchar * name, GError ** err) -{ - ModestIdentityMgrPrivate *priv; - gchar *key; - gboolean retval; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - - if (!modest_identity_mgr_identity_exists (self, name, err)) { - g_warning ("identity doest not exist"); - return FALSE; - } - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - key = get_identity_keyname (name, NULL); - - retval = modest_conf_remove_key (priv->modest_conf, key, NULL); - - g_free (key); - return retval; -} - - -static const gchar * -null_means_empty (const gchar * str) -{ - return str ? str : ""; -} - - -gboolean -modest_identity_mgr_add_identity (ModestIdentityMgr * self, - const gchar * name, - const gchar * realname, - const gchar * email, - const gchar * replyto, - const gchar * signature, - const gboolean use_signature, - const gchar * id_via, - const gboolean use_id_via) -{ - ModestIdentityMgrPrivate *priv; - gchar *id_key, *key; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - - /* TODO: check already exists */ - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - id_key = g_strconcat (MODEST_IDENTITY_NAMESPACE, "/", name, NULL); - - if (modest_conf_key_exists (priv->modest_conf, id_key, NULL)) { - g_warning ("identity %s already exists", name); - //g_free (id_key); - //return FALSE; - } - - /* realname */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_REALNAME, NULL); - modest_conf_set_string (priv->modest_conf, key, - null_means_empty (realname), NULL); - g_free (key); - - /* email */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_EMAIL, NULL); - modest_conf_set_string (priv->modest_conf, key, - null_means_empty (email), NULL); - g_free (key); - - /* replyto */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_REPLYTO, NULL); - modest_conf_set_string (priv->modest_conf, key, - null_means_empty (replyto), NULL); - g_free (key); - - /* signature */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_SIGNATURE, NULL); - modest_conf_set_string (priv->modest_conf, key, - null_means_empty (signature), NULL); - g_free (key); - - /* use_signature */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_USE_SIGNATURE, NULL); - modest_conf_set_bool (priv->modest_conf, key, use_signature, NULL); - g_free (key); - - /* id_via */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_ID_VIA, NULL); - modest_conf_set_string (priv->modest_conf, key, - null_means_empty (id_via), NULL); - g_free (key); - - /* use_id_via */ - key = g_strconcat (id_key, "/", MODEST_IDENTITY_USE_ID_VIA, NULL); - modest_conf_set_bool (priv->modest_conf, key, use_id_via, NULL); - g_free (key); - - g_free (id_key); - - return TRUE; /* FIXME: better error checking */ -} - -/* strip the first /n/ character from each element */ -/* caller must make sure all elements are strings with - * length >= n, and also that data can be freed. - */ -/* this function is copied from modest-account-mgr. Maybe it should be moved - * to modest-list-utils or the like... - */ -static GSList * -strip_prefix_from_elements (GSList * lst, guint n) -{ - GSList *cursor = lst; - - while (cursor) { - gchar *str = (gchar *) cursor->data; - - cursor->data = g_strdup (str + n); - g_free (str); - cursor = cursor->next; - } - return lst; -} - -GSList * -modest_identity_mgr_identity_names (ModestIdentityMgr * self, GError ** err) -{ - GSList *identities; - ModestIdentityMgrPrivate *priv; - const size_t prefix_len = strlen (MODEST_IDENTITY_NAMESPACE "/"); - - - g_return_val_if_fail (self, NULL); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - - identities = modest_conf_list_subkeys (priv->modest_conf, - MODEST_IDENTITY_NAMESPACE, - err); - return strip_prefix_from_elements (identities, prefix_len); -} - - -gchar * -modest_identity_mgr_get_identity_string (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gchar *retval; - - g_return_val_if_fail (self, NULL); - g_return_val_if_fail (name, NULL); - g_return_val_if_fail (key, NULL); - - keyname = get_identity_keyname (name, key); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - retval = modest_conf_get_string (priv->modest_conf, keyname, err); - g_free (keyname); - - return retval; -} - - -gint -modest_identity_mgr_get_identity_int (ModestIdentityMgr * self, - const gchar * name, const gchar * key, - GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gint retval; - - g_return_val_if_fail (self, -1); - g_return_val_if_fail (name, -1); - g_return_val_if_fail (key, -1); - - keyname = get_identity_keyname (name, key); - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - retval = modest_conf_get_int (priv->modest_conf, keyname, err); - g_free (keyname); - - return retval; -} - - - -gboolean -modest_identity_mgr_get_identity_bool (ModestIdentityMgr * self, - const gchar * name, const gchar * key, - GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gboolean retval; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - g_return_val_if_fail (key, FALSE); - - keyname = get_identity_keyname (name, key); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - retval = modest_conf_get_bool (priv->modest_conf, keyname, err); - g_free (keyname); - - return retval; -} - - -gboolean -modest_identity_mgr_set_identity_string (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, const gchar * val, - GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gboolean retval; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - g_return_val_if_fail (key, FALSE); - - keyname = get_identity_keyname (name, key); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - - retval = modest_conf_set_string (priv->modest_conf, keyname, val, - err); - - g_free (keyname); - return retval; -} - - -gboolean -modest_identity_mgr_set_identity_int (ModestIdentityMgr * self, - const gchar * name, const gchar * key, - const gint val, GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gboolean retval; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - g_return_val_if_fail (key, FALSE); - - keyname = get_identity_keyname (name, key); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - - retval = modest_conf_set_int (priv->modest_conf, keyname, val, err); - - g_free (keyname); - return retval; -} - - -gboolean -modest_identity_mgr_set_identity_bool (ModestIdentityMgr * self, - const gchar * name, const gchar * key, - gboolean val, GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gboolean retval; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - g_return_val_if_fail (key, FALSE); - - keyname = get_identity_keyname (name, key); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - - retval = modest_conf_set_bool (priv->modest_conf, keyname, val, err); - - g_free (keyname); - return retval; -} - - -gboolean -modest_identity_mgr_identity_exists (ModestIdentityMgr * self, - const gchar * name, GError ** err) -{ - ModestIdentityMgrPrivate *priv; - - gchar *keyname; - gboolean retval; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (name, FALSE); - - keyname = get_identity_keyname (name, NULL); - - priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self); - retval = modest_conf_key_exists (priv->modest_conf, keyname, err); - - g_free (keyname); - return retval; -} - - -/* must be freed by caller */ -static gchar * -get_identity_keyname (const gchar * idname, const gchar * name) -{ - if (name) - return g_strconcat - (MODEST_IDENTITY_NAMESPACE, "/", - idname, "/", name, NULL); - else - return g_strconcat - (MODEST_IDENTITY_NAMESPACE, "/", idname, NULL); -} diff --git a/src/modest-identity-mgr.h b/src/modest-identity-mgr.h deleted file mode 100644 index d242892..0000000 --- a/src/modest-identity-mgr.h +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright (c) 2006, Nokia Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the Nokia Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* modest-identity-mgr.h */ - -#ifndef __MODEST_IDENTITY_MGR_H__ -#define __MODEST_IDENTITY_MGR_H__ - -#include -#include "modest-conf.h" -#include "modest-identity-keys.h" -#include "modest-proto.h" - -G_BEGIN_DECLS -/* convenience macros */ -#define MODEST_TYPE_IDENTITY_MGR (modest_identity_mgr_get_type()) -#define MODEST_IDENTITY_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_IDENTITY_MGR,ModestIdentityMgr)) -#define MODEST_IDENTITY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_IDENTITY_MGR,GObject)) -#define MODEST_IS_IDENTITY_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_IDENTITY_MGR)) -#define MODEST_IS_IDENTITY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_IDENTITY_MGR)) -#define MODEST_IDENTITY_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_IDENTITY_MGR,ModestIdentityMgrClass)) -typedef struct _ModestIdentityMgr ModestIdentityMgr; -typedef struct _ModestIdentityMgrClass ModestIdentityMgrClass; - - -struct _ModestIdentityMgr { - GObject parent; - /* insert public members, if any */ -}; - -struct _ModestIdentityMgrClass { - GObjectClass parent_class; - /* insert signal callback declarations, eg. */ - /* void (* my_event) (ModestIdentityMgr* obj); */ -}; - - -/** - * modest_ui_get_type: - * - * get the GType for ModestIdentityMgr - * - * Returns: the GType - */ -GType modest_identity_mgr_get_type (void) G_GNUC_CONST; - - -/** - * modest_identity_mgr_new: - * @modest_conf: a ModestConf instance - * - * Returns: a new ModestIdentityMgr, or NULL in case of error - */ -GObject * modest_identity_mgr_new (ModestConf * modest_conf); - - -/** - * modest_identity_mgr_add_identity: - * @self: a ModestIdentityMgr instance - * @name: the name (id) for the identity - * @realname: the real name of the user - * @email: the user's email address which is used when sending email - * @replyto: the default replyto address - * @signature: the signature for this identity - * @use_signature: whether to use this signature instead of the default one - * @id_via: the transport to send emails for this identity via - * @use_id_via: whether to use this via instead of the default one - * - * add a user identity to the configuration - * - * Returns: TRUE if succeeded, FALSE otherwise, - */ -gboolean modest_identity_mgr_add_identity (ModestIdentityMgr * self, - const gchar * name, - const gchar * realname, - const gchar * email, - const gchar * replyto, - const gchar * signature, - const gboolean use_signature, - const gchar * id_via, - const gboolean use_id_via); - - -/** - * modest_identity_mgr_remove_identity: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity to remove - * @err: a GError ptr, or NULL to ignore. - * - * remove identity from the configuration - * the identity with @name should exist - * - * Returns: TRUE if the removal succeeded, FALSE otherwise, - * @err gives details in case of error - */ -gboolean modest_identity_mgr_remove_identity (ModestIdentityMgr * self, - const gchar * name, - GError ** err); - - -/** - * modest_identity_mgr_identity_names: - * @self: a ModestIdentityMgr instance - * @err: a GError ptr, or NULL to ignore. - * - * list all identities - * - * Returns: a newly allocated list of identities, or NULL in case of error or - * if there are no identities. The caller must free the returned GSList - * @err gives details in case of error - */ -GSList *modest_identity_mgr_identity_names (ModestIdentityMgr * self, - GError ** err); - - -/** - * modest_identity_mgr_identity_exists: - * @self: a ModestIdentityMgr instance - * @err: a GError ptr, or NULL to ignore. - * - * check whether identity @name exists - * - * Returns: TRUE if the identity exists, FALSE otherwise (or in case of error) - * @err gives details in case of error - */ -gboolean modest_identity_mgr_identity_exists (ModestIdentityMgr * self, - const gchar * name, - GError ** err); - - -/* identity specific functions */ - -/** - * modest_identity_mgr_get_identity_string: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity - * @key: the key of the value to retrieve - * @err: a GError ptr, or NULL to ignore. - * - * get a config string from an identity - * - * Returns: a newly allocated string with the value for the key, - * or NULL in case of error. @err gives details in case of error - */ -gchar *modest_identity_mgr_get_identity_string (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, - GError ** err); - - -/** - * modest_identity_mgr_get_identity_int: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity - * @key: the key of the value to retrieve - * @err: a GError ptr, or NULL to ignore. - * - * get a config int from an identity - * - * Returns: an integer with the value for the key, or -1 in case of - * error (but of course -1 does not necessarily imply an error) - * @err gives details in case of error - */ -gint modest_identity_mgr_get_identity_int (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, - GError ** err); - - -/** - * modest_identity_mgr_get_identity_bool: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity - * @key: the key of the value to retrieve - * @err: a GError ptr, or NULL to ignore. - * - * get a config boolean from an identity - * - * Returns: an boolean with the value for the key, or FALSE in case of - * error (but of course FALSE does not necessarily imply an error) - * @err gives details in case of error - */ -gboolean modest_identity_mgr_get_identity_bool (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, - GError ** err); - - -/** - * modest_identity_mgr_set_identity_string: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity - * @key: the key of the value to set - * @val: the value to set - * @err: a GError ptr, or NULL to ignore. - * - * set a config string for an identity - * - * Returns: TRUE if setting the value succeeded, or FALSE in case of error. - * @err gives details in case of error - */ -gboolean modest_identity_mgr_set_identity_string (ModestIdentityMgr * - self, - const gchar * name, - const gchar * key, - const gchar * val, - GError ** err); - - -/** - * modest_identity_mgr_set_identity_int: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity - * @key: the key of the value to set - * @val: the value to set - * @err: a GError ptr, or NULL to ignore. - * - * set a config int for an identity - * - * Returns: TRUE if setting the value succeeded, or FALSE in case of error. - * @err gives details in case of error - */ -gboolean modest_identity_mgr_set_identity_int (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, - gint val, GError ** err); - - -/** - * modest_identity_mgr_set_identity_bool: - * @self: a ModestIdentityMgr instance - * @name: the name of the identity - * @key: the key of the value to set - * @val: the value to set - * @err: a GError ptr, or NULL to ignore. - * - * set a config bool for an identity - * - * Returns: TRUE if setting the value succeeded, or FALSE in case of error. - * @err gives details in case of error - */ -gboolean modest_identity_mgr_set_identity_bool (ModestIdentityMgr * self, - const gchar * name, - const gchar * key, - gboolean val, - GError ** err); - - -G_END_DECLS -#endif /* __MODEST_IDENTITY_MGR_H__ */ diff --git a/src/modest-window-mgr.c b/src/modest-window-mgr.c deleted file mode 100644 index df4e0dc..0000000 --- a/src/modest-window-mgr.c +++ /dev/null @@ -1,228 +0,0 @@ -/* Copyright (c) 2006, Nokia Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the Nokia Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* modest-window-mgr.c */ - -#include "modest-window-mgr.h" -/* include other impl specific header files */ - -/* 'private'/'protected' functions */ -static void modest_window_mgr_class_init (ModestWindowMgrClass *klass); -static void modest_window_mgr_init (ModestWindowMgr *obj); -static void modest_window_mgr_finalize (GObject *obj); - -/* list my signals */ -enum { - /* MY_SIGNAL_1, */ - /* MY_SIGNAL_2, */ - LAST_WINDOW_CLOSED_SIGNAL, - LAST_SIGNAL -}; - -typedef struct _ModestWindowMgrPrivate ModestWindowMgrPrivate; -struct _ModestWindowMgrPrivate { - GSList *open_windows; - -}; -#define MODEST_WINDOW_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ - MODEST_TYPE_WINDOW_MGR, \ - ModestWindowMgrPrivate)) -/* globals */ -static GObjectClass *parent_class = NULL; - -static guint signals[LAST_SIGNAL] = {0}; - -GType -modest_window_mgr_get_type (void) -{ - static GType my_type = 0; - if (!my_type) { - static const GTypeInfo my_info = { - sizeof(ModestWindowMgrClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc) modest_window_mgr_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof(ModestWindowMgr), - 1, /* n_preallocs */ - (GInstanceInitFunc) modest_window_mgr_init, - }; - my_type = g_type_register_static (G_TYPE_OBJECT, - "ModestWindowMgr", - &my_info, 0); - } - return my_type; -} - -static void -modest_window_mgr_class_init (ModestWindowMgrClass *klass) -{ - GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; - - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = modest_window_mgr_finalize; - - g_type_class_add_private (gobject_class, sizeof(ModestWindowMgrPrivate)); - - signals[LAST_WINDOW_CLOSED_SIGNAL] = - g_signal_new ("last_window_closed", - G_TYPE_FROM_CLASS(gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(ModestWindowMgrClass, last_window_closed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -modest_window_mgr_init (ModestWindowMgr *obj) -{ - ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE(obj); - priv->open_windows = NULL; -} - -static void -modest_window_mgr_finalize (GObject *obj) -{ - ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE(obj); - g_slist_free (priv->open_windows); - priv->open_windows = NULL; -} - -GObject* -modest_window_mgr_new (void) -{ - return G_OBJECT(g_object_new(MODEST_TYPE_WINDOW_MGR, NULL)); -} - -/* insert many other interesting function implementations */ -/* such as modest_window_mgr_do_something, or modest_window_mgr_has_foo */ - -gboolean -modest_window_mgr_register (ModestWindowMgr *self, GObject *win, - ModestWindowType type, - guint window_id) -{ - ModestOpenWindow *openwin = NULL; - ModestWindowMgrPrivate *priv; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (type==MODEST_MAIN_WINDOW || type==MODEST_EDIT_WINDOW - || type == MODEST_VIEW_WINDOW, FALSE); - - priv = MODEST_WINDOW_MGR_GET_PRIVATE(self); - - openwin = g_new (ModestOpenWindow, 1); - openwin->win = win; - openwin->type = type; - openwin->id = window_id; - - priv->open_windows = g_slist_prepend (priv->open_windows, openwin); - - return TRUE; -} - - - -gboolean -modest_window_mgr_unregister (ModestWindowMgr *self, GObject *win) -{ - ModestWindowMgrPrivate *priv; - GSList *cursor; - gboolean found = FALSE; - - g_return_val_if_fail (self, FALSE); - g_return_val_if_fail (win, FALSE); - - priv = MODEST_WINDOW_MGR_GET_PRIVATE(self); - - cursor = priv->open_windows; - while (cursor) { - if (((ModestOpenWindow*)cursor->data)->win == win) { - priv->open_windows = g_slist_delete_link (priv->open_windows, - cursor); - found = TRUE; - break; - } - cursor = cursor->next; - } - if (found) { - guint win_num = g_slist_length (priv->open_windows); - if (win_num == 0) - g_signal_emit (self, signals[LAST_WINDOW_CLOSED_SIGNAL], - 0); - } - - return found; -} - - -GObject * -modest_window_mgr_find_by_type (ModestWindowMgr *self, ModestWindowType type) -{ - ModestWindowMgrPrivate *priv; - GSList *cursor; - - g_return_val_if_fail (self, NULL); - - priv = MODEST_WINDOW_MGR_GET_PRIVATE(self); - cursor = priv->open_windows; - while (cursor) { - ModestOpenWindow *openwin = (ModestOpenWindow*)cursor->data; - if (openwin->type == type) - return openwin->win; - cursor = cursor->next; - } - - return NULL; -} - - -GObject * -modest_window_mgr_find_by_id (ModestWindowMgr *self, gint window_id) -{ - ModestWindowMgrPrivate *priv; - GSList *cursor; - - g_return_val_if_fail (self, NULL); - - priv = MODEST_WINDOW_MGR_GET_PRIVATE(self); - cursor = priv->open_windows; - while (cursor) { - ModestOpenWindow *openwin = (ModestOpenWindow*)cursor->data; - if (openwin->id == window_id) - return openwin->win; - cursor = cursor->next; - } - return NULL; -} - diff --git a/src/modest-window-mgr.h b/src/modest-window-mgr.h deleted file mode 100644 index e872610..0000000 --- a/src/modest-window-mgr.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (c) 2006, Nokia Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the Nokia Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* modest-window-mgr.h */ - -#ifndef __MODEST_WINDOW_MGR_H__ -#define __MODEST_WINDOW_MGR_H__ - -#include -/* other include files */ - -G_BEGIN_DECLS - -/* convenience macros */ -#define MODEST_TYPE_WINDOW_MGR (modest_window_mgr_get_type()) -#define MODEST_WINDOW_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgr)) -#define MODEST_WINDOW_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WINDOW_MGR,GObject)) -#define MODEST_IS_WINDOW_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WINDOW_MGR)) -#define MODEST_IS_WINDOW_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WINDOW_MGR)) -#define MODEST_WINDOW_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass)) - -enum { - MODEST_MAIN_WINDOW, /* the main window */ - MODEST_EDIT_WINDOW, /* a window to edit a mail */ - MODEST_ACCOUNT_WINDOW, /* a window to edit account information */ - MODEST_VIEW_WINDOW /* a window to view mails */ -}; -typedef guint ModestWindowType; - - -typedef struct _ModestOpenWindow ModestOpenWindow; -struct _ModestOpenWindow { - GObject *win; - ModestWindowType type; - guint id; -}; - - -typedef struct _ModestWindowMgr ModestWindowMgr; -typedef struct _ModestWindowMgrClass ModestWindowMgrClass; - -struct _ModestWindowMgr { - GObject parent; -}; - -struct _ModestWindowMgrClass { - GObjectClass parent_class; - - void (* last_window_closed) (ModestWindowMgr* obj); -}; - -/* member functions */ -GType modest_window_mgr_get_type (void) G_GNUC_CONST; - -/** - * modest_window_mgr_new: - * - * creates a new ModestWindowMgr instance - * - * Returns: a new ModestWindowMgr, or NULL in case of error - */ -GObject* modest_window_mgr_new (void); - -/** - * modest_window_mgr_register: - * @self: a ModestWindowMgr instance - * @win: the GObject of the window to register - * @type: ModestWindowType of the window to register - * @window_id: a guint window_id of the window - * - * register a window with the ModestWindowMgr instance *self - * - * Returns: TRUE on success, else FALSE - */ -gboolean modest_window_mgr_register (ModestWindowMgr *self, GObject *win, - ModestWindowType type, guint window_id); - -/** - * modest_window_mgr_unregister: - * @self: a ModestWindowMgr instance - * @win: the GObject of the window to register - * - * unregister a window from the ModestWindowMgr instance *self - * - * Returns: TRUE on success, else FALSE - */ -gboolean modest_window_mgr_unregister (ModestWindowMgr *self, GObject *win); - -/** - * modest_window_mgr_find_by_type: - * @self: a ModestWindowMgr instance - * @type: the ModestWindowType to search for - * - * search for a window of type 'type' in the ModestWindowMgr instance *self - * - * Returns: the GObject of the window, else NULL - */ -GObject* modest_window_mgr_find_by_type (ModestWindowMgr *self, ModestWindowType type); - -/** - * modest_window_mgr_find_by_id: - * @self: a ModestWindowMgr instance - * @window_id: the ModestWindowType to search for - * - * search for a window with a specific 'window_id' in the ModestWindowMgr instance *self - * - * Returns: the GObject of the window, else NULL - */ -GObject* modest_window_mgr_find_by_id (ModestWindowMgr *self, gint window_id); - -G_END_DECLS - -#endif /* __MODEST_WINDOW_MGR_H__ */ - -- 1.7.9.5