From: Dirk-Jan C. Binnema Date: Wed, 17 Jan 2007 08:02:49 +0000 (+0000) Subject: * all: X-Git-Tag: git_migration_finished~4225 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=1f6bcb80a516f8212bc404ba39165ef8dcde423e * all: - move local folder stuff to modest-local-folder-info.[ch] - document the functions pmo-trunk-r654 --- diff --git a/src/Makefile.am b/src/Makefile.am index d4af382..7061aef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ # # Makefile.am -# Time-stamp: <2007-01-16 23:49:28 (djcb)> +# Time-stamp: <2007-01-17 09:44:06 (djcb)> SUBDIRS=$(MODEST_PLATFORM) widgets DIST_SUBDIRS = widgets gtk maemo @@ -45,6 +45,8 @@ modest_SOURCES=\ modest-icon-factory.h\ modest-init.h\ modest-init.c\ + modest-local-folder-info.h \ + modest-local-folder-info.c \ modest-mail-operation-queue.c \ modest-mail-operation-queue.h \ modest-mail-operation.c \ diff --git a/src/modest-init.c b/src/modest-init.c index d9e530e..d17f137 100644 --- a/src/modest-init.c +++ b/src/modest-init.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -43,7 +43,6 @@ typedef struct { } FolderCols; - #if MODEST_PLATFORM_ID==1 /*gtk*/ static const FolderCols INBOX_COLUMNS[] = { {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 20}, @@ -205,7 +204,7 @@ modest_init_local_folders (void) for (j = 0; j != G_N_ELEMENTS(maildirs); ++j) { gchar *dir; dir = g_build_filename (path, "local_folders", - modest_tny_folder_get_local_folder_type_name(LOCAL_FOLDERS[i]), + modest_local_folder_info_get_type_name(LOCAL_FOLDERS[i]), maildirs[j], NULL); if (g_mkdir_with_parents (dir, 0755) < 0) { diff --git a/src/modest-local-folder-info.c b/src/modest-local-folder-info.c new file mode 100644 index 0000000..dfdfd6c --- /dev/null +++ b/src/modest-local-folder-info.c @@ -0,0 +1,92 @@ +/* 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. + */ + +#include +#include /* strcmp */ +#include + +typedef struct { + ModestLocalFolderType type; + const gchar *name; + const gchar *display_name; +} ModestLocalFolder; + +const ModestLocalFolder ModestLocalFolderMap[] = { + { MODEST_LOCAL_FOLDER_TYPE_JUNK, "junk", N_("Junk")}, + { MODEST_LOCAL_FOLDER_TYPE_TRASH, "trash", N_("Trash")}, + { MODEST_LOCAL_FOLDER_TYPE_DRAFTS, "drafts", N_("Drafts")}, + { MODEST_LOCAL_FOLDER_TYPE_SENT, "sent", N_("Sent")}, + { MODEST_LOCAL_FOLDER_TYPE_OUTBOX, "outbox", N_("Outbox")}, + { MODEST_LOCAL_FOLDER_TYPE_ARCHIVE, "archive", N_("Archive")} +}; + + +ModestLocalFolderType +modest_local_folder_info_get_type (const gchar *name) +{ + int i; + + g_return_val_if_fail (name, MODEST_LOCAL_FOLDER_TYPE_UNKNOWN); + + for (i = 0; i != G_N_ELEMENTS(ModestLocalFolderMap); ++i) { + if (strcmp (ModestLocalFolderMap[i].name, name) == 0) + return ModestLocalFolderMap[i].type; + } + return MODEST_LOCAL_FOLDER_TYPE_UNKNOWN; +} + +const gchar* +modest_local_folder_info_get_type_name (ModestLocalFolderType type) +{ + int i = 0; + g_return_val_if_fail (type > MODEST_LOCAL_FOLDER_TYPE_UNKNOWN && + type < MODEST_LOCAL_FOLDER_TYPE_NUM, NULL); + + for (i = 0; i != G_N_ELEMENTS(ModestLocalFolderMap); ++i) { + if (ModestLocalFolderMap[i].type == type) + return ModestLocalFolderMap[i].name; + } + return NULL; +} + +const gchar* +modest_local_folder_info_get_type_display_name (ModestLocalFolderType type) +{ + int i = 0; + g_return_val_if_fail (type > MODEST_LOCAL_FOLDER_TYPE_UNKNOWN && + type < MODEST_LOCAL_FOLDER_TYPE_NUM, NULL); + + for (i = 0; i != G_N_ELEMENTS(ModestLocalFolderMap); ++i) { + if (ModestLocalFolderMap[i].type == type) + return ModestLocalFolderMap[i].display_name; + } + return NULL; +} + + diff --git a/src/modest-local-folder-info.h b/src/modest-local-folder-info.h new file mode 100644 index 0000000..4b5ea10 --- /dev/null +++ b/src/modest-local-folder-info.h @@ -0,0 +1,89 @@ +/* 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_LOCAL_FOLDER_INFO_H__ +#define __MODEST_LOCAL_FOLDER_INFO_H__ + +G_BEGIN_DECLS + +#include + +typedef enum { + MODEST_LOCAL_FOLDER_TYPE_UNKNOWN, + MODEST_LOCAL_FOLDER_TYPE_DRAFTS, + MODEST_LOCAL_FOLDER_TYPE_SENT, + MODEST_LOCAL_FOLDER_TYPE_OUTBOX, + MODEST_LOCAL_FOLDER_TYPE_ARCHIVE, + MODEST_LOCAL_FOLDER_TYPE_JUNK, + MODEST_LOCAL_FOLDER_TYPE_TRASH, + MODEST_LOCAL_FOLDER_TYPE_NUM +} ModestLocalFolderType; + + +/** + * modest_local_folder_info_get_type + * @name: the name of the local folder (ie. "trash", "inbox" etc., + * these name can be found with modest_local_folder_get_name) + * + * get the type of some local folder + * + * Returns: the local folder type, or MODEST_LOCAL_FOLDER_TYPE_UNKNOWN + * in case of error + * + */ +ModestLocalFolderType modest_local_folder_info_get_type (const gchar *name); + +/** + * modest_local_folder_get_type_name + * @type: the type of the local folder + * + * get the name of some local folder + * + * Returns: the local folder name, or NULL in case of error + * the returned name should NOT be freed or modified + * + */ +const gchar* modest_local_folder_info_get_type_name (ModestLocalFolderType type); + +/** + * modest_local_folder_get_type_display_name + * @type: the type of the local folder + * + * get the localized display name for some local folder + * + * Returns: the local folder display name, or NULL in case of error + * the returned name should NOT be freed or modified + * + */ +const gchar* modest_local_folder_info_get_type_display_name (ModestLocalFolderType type); + + +G_END_DECLS +#endif /* __MODEST_LOCAL_FOLDER_INFO_H__ */ +