Unifying the plug-in API between projects

This commit is contained in:
Pierre Pronchery 2011-01-29 02:16:42 +00:00
parent c247ca4b42
commit f9971b4c33
16 changed files with 202 additions and 173 deletions

View File

@ -11,7 +11,7 @@ clean:
distclean: clean distclean: clean
install: all install:
$(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps
$(INSTALL) -m 0644 -- mailer.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/mailer.png $(INSTALL) -m 0644 -- mailer.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/mailer.png
$(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps

View File

@ -11,7 +11,7 @@ clean:
distclean: clean distclean: clean
install: all install:
$(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps
$(INSTALL) -m 0644 -- mailer.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/mailer.png $(INSTALL) -m 0644 -- mailer.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/mailer.png
$(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps

View File

@ -17,7 +17,7 @@ clean:
distclean: distclean:
@for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done @for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done
install: all install:
@for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done @for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done
$(MKDIR) $(DESTDIR)$(PREFIX)/share/applications $(MKDIR) $(DESTDIR)$(PREFIX)/share/applications
$(INSTALL) -m 0644 -- mailer.desktop $(DESTDIR)$(PREFIX)/share/applications/mailer.desktop $(INSTALL) -m 0644 -- mailer.desktop $(DESTDIR)$(PREFIX)/share/applications/mailer.desktop

View File

@ -86,23 +86,27 @@ typedef struct _AccountPluginHelper
GtkIconTheme * theme; GtkIconTheme * theme;
GdkPixbuf * mail_read; GdkPixbuf * mail_read;
GdkPixbuf * mail_unread; GdkPixbuf * mail_unread;
int (*error)(Mailer * mailer, char const * message, int ret);
} AccountPluginHelper; } AccountPluginHelper;
typedef struct _AccountPlugin typedef struct _AccountPlugin AccountPlugin;
struct _AccountPlugin
{ {
AccountPluginHelper * helper; AccountPluginHelper * helper;
char const * type; char const * type;
char const * name; char const * name;
char const * icon;
AccountConfig * config; AccountConfig * config;
int (*init)(GtkTreeStore * store, GtkTreeIter * parent, int (*init)(AccountPlugin * plugin, GtkTreeStore * store,
GtkTextBuffer * buffer); GtkTreeIter * parent, GtkTextBuffer * buffer);
int (*quit)(void); int (*destroy)(AccountPlugin * plugin);
GtkTextBuffer * (*select)(AccountFolder * folder, GtkTextBuffer * (*select)(AccountPlugin * plugin,
AccountMessage * message); AccountFolder * folder, AccountMessage * message);
GtkTextBuffer * (*select_source)(AccountFolder * folder, GtkTextBuffer * (*select_source)(AccountPlugin * plugin,
AccountMessage * message); AccountFolder * folder, AccountMessage * message);
void * priv; void * priv;
} AccountPlugin; };
/* constants */ /* constants */

View File

@ -21,7 +21,7 @@ clean:
distclean: clean distclean: clean
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: all install: $(TARGETS)
./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "fr.mo" ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "fr.mo"
uninstall: uninstall:

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Mailer 0.0.0\n" "Project-Id-Version: Mailer 0.0.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-01-05 17:08+0100\n" "POT-Creation-Date: 2011-01-29 03:13+0100\n"
"PO-Revision-Date: 2010-10-02 23:25+0200\n" "PO-Revision-Date: 2010-10-02 23:25+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n" "Language-Team: French\n"
@ -167,8 +167,8 @@ msgid ""
"Are you sure you want to close?" "Are you sure you want to close?"
msgstr "" msgstr ""
#: ../src/compose.c:453 ../src/compose.c:458 ../src/mailer.c:717 #: ../src/compose.c:453 ../src/compose.c:458 ../src/mailer.c:718
#: ../src/mailer.c:722 #: ../src/mailer.c:723
msgid "Error" msgid "Error"
msgstr "Erreur" msgstr "Erreur"
@ -276,43 +276,43 @@ msgstr "Préférences"
msgid "Mailer" msgid "Mailer"
msgstr "Mailer" msgstr "Mailer"
#: ../src/mailer.c:406 #: ../src/mailer.c:407
msgid "Folders" msgid "Folders"
msgstr "Dossiers" msgstr "Dossiers"
#: ../src/mailer.c:474 #: ../src/mailer.c:475
msgid "Subject" msgid "Subject"
msgstr "Sujet" msgstr "Sujet"
#: ../src/mailer.c:476 #: ../src/mailer.c:477
msgid "From" msgid "From"
msgstr "De" msgstr "De"
#: ../src/mailer.c:478 #: ../src/mailer.c:479
msgid "To" msgid "To"
msgstr "À" msgstr "À"
#: ../src/mailer.c:480 #: ../src/mailer.c:481
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: ../src/mailer.c:580 #: ../src/mailer.c:581
msgid " Subject: " msgid " Subject: "
msgstr " Sujet: " msgstr " Sujet: "
#: ../src/mailer.c:581 #: ../src/mailer.c:582
msgid " From: " msgid " From: "
msgstr " De: " msgstr " De: "
#: ../src/mailer.c:582 #: ../src/mailer.c:583
msgid " To: " msgid " To: "
msgstr " À: " msgstr " À: "
#: ../src/mailer.c:583 #: ../src/mailer.c:584
msgid " Date: " msgid " Date: "
msgstr " Date: " msgstr " Date: "
#: ../src/mailer.c:821 #: ../src/mailer.c:822
msgid "" msgid ""
"The messages selected will be deleted.\n" "The messages selected will be deleted.\n"
"Continue?" "Continue?"
@ -320,112 +320,112 @@ msgstr ""
"Les messages sélectionnés vont être effacés.\n" "Les messages sélectionnés vont être effacés.\n"
"Continuer?" "Continuer?"
#: ../src/mailer.c:893 #: ../src/mailer.c:894
msgid "Mailer - View source" msgid "Mailer - View source"
msgstr "Mailer - Source" msgstr "Mailer - Source"
#: ../src/mailer.c:939 #: ../src/mailer.c:940
msgid "Re: " msgid "Re: "
msgstr "Re: " msgstr "Re: "
#: ../src/mailer.c:1090 #: ../src/mailer.c:1091
msgid "Mailer preferences" msgid "Mailer preferences"
msgstr "Préférences de Mailer" msgstr "Préférences de Mailer"
#: ../src/mailer.c:1126 #: ../src/mailer.c:1127
msgid "Enabled" msgid "Enabled"
msgstr "Actif" msgstr "Actif"
#: ../src/mailer.c:1130 #: ../src/mailer.c:1131
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
#: ../src/mailer.c:1134 #: ../src/mailer.c:1135
msgid "Type" msgid "Type"
msgstr "Type" msgstr "Type"
#: ../src/mailer.c:1158 #: ../src/mailer.c:1159
msgid "Accounts" msgid "Accounts"
msgstr "Comptes" msgstr "Comptes"
#: ../src/mailer.c:1165 #: ../src/mailer.c:1166
msgid "Messages font:" msgid "Messages font:"
msgstr "Police des messages:" msgstr "Police des messages:"
#: ../src/mailer.c:1175 #: ../src/mailer.c:1176
msgid "Display" msgid "Display"
msgstr "Affichage" msgstr "Affichage"
#: ../src/mailer.c:1257 #: ../src/mailer.c:1258
msgid "No account plug-in available" msgid "No account plug-in available"
msgstr "Aucun greffon de compte disponible" msgstr "Aucun greffon de compte disponible"
#: ../src/mailer.c:1412 ../src/mailer.c:1693 #: ../src/mailer.c:1413 ../src/mailer.c:1694
msgid "Account name" msgid "Account name"
msgstr "Nom du compte" msgstr "Nom du compte"
#: ../src/mailer.c:1419 #: ../src/mailer.c:1420
msgid "Your name" msgid "Your name"
msgstr "Votre nom" msgstr "Votre nom"
#: ../src/mailer.c:1426 #: ../src/mailer.c:1427
msgid "e-mail address" msgid "e-mail address"
msgstr "Adresse e-mail" msgstr "Adresse e-mail"
#: ../src/mailer.c:1433 #: ../src/mailer.c:1434
msgid "Type of account" msgid "Type of account"
msgstr "Type de compte" msgstr "Type de compte"
#: ../src/mailer.c:1582 #: ../src/mailer.c:1583
msgid "Choose file" msgid "Choose file"
msgstr "Choisir un fichier" msgstr "Choisir un fichier"
#: ../src/mailer.c:1762 #: ../src/mailer.c:1763
msgid "hidden" msgid "hidden"
msgstr "masqué" msgstr "masqué"
#: ../src/mailer.c:1796 #: ../src/mailer.c:1797
msgid "Yes" msgid "Yes"
msgstr "Oui" msgstr "Oui"
#: ../src/mailer.c:1796 #: ../src/mailer.c:1797
msgid "No" msgid "No"
msgstr "Non" msgstr "Non"
#: ../src/mailer.c:1824 #: ../src/mailer.c:1825
msgid "Account type " msgid "Account type "
msgstr "Type de compte " msgstr "Type de compte "
#: ../src/mailer.c:1825 #: ../src/mailer.c:1826
msgid " active\n" msgid " active\n"
msgstr " actif\n" msgstr " actif\n"
#: ../src/mailer.c:1869 #: ../src/mailer.c:1870
msgid "Edit account: " msgid "Edit account: "
msgstr "Modification du compte: " msgstr "Modification du compte: "
#: ../src/mailer.c:1936 #: ../src/mailer.c:1937
msgid "An error occured while saving preferences" msgid "An error occured while saving preferences"
msgstr "Une erreur est survenue pendant la sauvegarde des préférences" msgstr "Une erreur est survenue pendant la sauvegarde des préférences"
#: ../src/mailer.c:2070 ../src/mailer.c:2075 #: ../src/mailer.c:2071 ../src/mailer.c:2076
msgid "Question" msgid "Question"
msgstr "Question" msgstr "Question"
#: ../src/mailer.c:2144 #: ../src/mailer.c:2145
#, c-format #, c-format
msgid "%s/%s: %d %s" msgid "%s/%s: %d %s"
msgstr "%s/%s: %d %s" msgstr "%s/%s: %d %s"
#: ../src/mailer.c:2147 #: ../src/mailer.c:2148
msgid "messages" msgid "messages"
msgstr "messages" msgstr "messages"
#: ../src/mailer.c:2147 #: ../src/mailer.c:2148
msgid "message" msgid "message"
msgstr "message" msgstr "message"
#: ../src/mailer.c:2150 #: ../src/mailer.c:2151
msgid "Ready" msgid "Ready"
msgstr "Prêt" msgstr "Prêt"

View File

@ -52,7 +52,7 @@ distclean:
$(RM) -- $(mailer_OBJS) $(RM) -- $(mailer_OBJS)
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: all install: $(TARGETS)
@for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done @for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done
$(MKDIR) $(DESTDIR)$(BINDIR) $(MKDIR) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 -- mailer $(DESTDIR)$(BINDIR)/mailer $(INSTALL) -m 0755 -- mailer $(DESTDIR)$(BINDIR)/mailer

View File

@ -108,8 +108,8 @@ void account_delete(Account * account)
if(account->plugin != NULL) if(account->plugin != NULL)
{ {
if(account->plugin->quit != NULL) if(account->plugin->destroy != NULL)
account->plugin->quit(); account->plugin->destroy(account->plugin);
if(account->plugin->config != NULL) if(account->plugin->config != NULL)
for(p = account->plugin->config; p->name != NULL; p++) for(p = account->plugin->config; p->name != NULL; p++)
switch(p->type) switch(p->type)
@ -287,7 +287,8 @@ int account_init(Account * account, GtkTreeStore * store, GtkTreeIter * parent)
#endif #endif
if(account->plugin->init == NULL) if(account->plugin->init == NULL)
return 0; return 0;
return account->plugin->init(store, parent, account->buffer); return account->plugin->init(account->plugin, store, parent,
account->buffer);
} }
@ -301,7 +302,7 @@ GtkTextBuffer * account_select(Account * account, AccountFolder * folder,
#endif #endif
if(account->plugin->select == NULL) if(account->plugin->select == NULL)
return NULL; return NULL;
return account->plugin->select(folder, message); return account->plugin->select(account->plugin, folder, message);
} }
@ -315,5 +316,5 @@ GtkTextBuffer * account_select_source(Account * account, AccountFolder * folder,
#endif #endif
if(account->plugin->select_source == NULL) if(account->plugin->select_source == NULL)
return NULL; return NULL;
return account->plugin->select_source(folder, message); return account->plugin->select_source(account->plugin, folder, message);
} }

View File

@ -74,7 +74,7 @@ clean:
distclean: clean distclean: clean
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: all install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(LIBDIR)/Mailer/account $(MKDIR) $(DESTDIR)$(LIBDIR)/Mailer/account
$(INSTALL) -m 0644 -- mbox.so $(DESTDIR)$(LIBDIR)/Mailer/account/mbox.so $(INSTALL) -m 0644 -- mbox.so $(DESTDIR)$(LIBDIR)/Mailer/account/mbox.so

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -44,6 +44,7 @@ AccountPlugin account_plugin =
NULL, NULL,
_imap4_type, _imap4_type,
_imap4_name, _imap4_name,
NULL,
_imap4_config, _imap4_config,
NULL, NULL,
NULL, NULL,

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,6 +30,9 @@
/* Mbox */ /* Mbox */
/* private */ /* private */
#define _FOLDER_CNT 5
/* types */ /* types */
typedef enum _ParserContext typedef enum _ParserContext
{ {
@ -39,8 +42,12 @@ typedef enum _ParserContext
PC_GARBAGE /* inside crap */ PC_GARBAGE /* inside crap */
} ParserContext; } ParserContext;
typedef struct _Mbox Mbox;
typedef struct _MboxFolder typedef struct _MboxFolder
{ {
Mbox * mbox;
AccountFolder folder;
AccountConfig * config; AccountConfig * config;
AccountMessage ** messages; AccountMessage ** messages;
size_t messages_cnt; size_t messages_cnt;
@ -62,17 +69,17 @@ typedef struct _MboxFolder
char * pixbuf; char * pixbuf;
} MboxFolder; } MboxFolder;
struct _Mbox
{
AccountPlugin * plugin;
MboxFolder folders[_FOLDER_CNT];
};
/* constants */ /* constants */
#define _FOLDER_CNT 5
/* variables */ /* variables */
static char const _mbox_type[] = "MBOX";
static char const _mbox_name[] = "Local folders";
static char const * _error = NULL;
static AccountConfig _mbox_config[_FOLDER_CNT + 1] = static AccountConfig _mbox_config[_FOLDER_CNT + 1] =
{ {
{ "mbox", "Inbox file", ACT_FILE, NULL }, { "mbox", "Inbox file", ACT_FILE, NULL },
@ -83,73 +90,69 @@ static AccountConfig _mbox_config[_FOLDER_CNT + 1] =
{ NULL, NULL, 0, NULL } { NULL, NULL, 0, NULL }
}; };
static MboxFolder _mbox_inbox = static const MboxFolder _mbox_folder_defaults[_FOLDER_CNT] =
{ {
{
NULL,
{ AFT_INBOX, "Inbox", NULL, NULL },
&_mbox_config[0], NULL, 0, NULL, &_mbox_config[0], NULL, 0, NULL,
0, NULL, -1, 0, NULL, -1,
0, PC_FROM, NULL, 0, NULL, 0, PC_FROM, NULL, 0, NULL,
"mailer-inbox" "mailer-inbox"
}; },
{
static MboxFolder _mbox_spool = NULL,
{ { AFT_INBOX, "Spool", NULL, NULL },
&_mbox_config[1], NULL, 0, NULL, &_mbox_config[1], NULL, 0, NULL,
0, NULL, -1, 0, NULL, -1,
0, PC_FROM, NULL, 0, NULL, 0, PC_FROM, NULL, 0, NULL,
"mailer-inbox" "mailer-inbox"
}; },
{
static MboxFolder _mbox_drafts = NULL,
{ { AFT_DRAFTS, "Drafts", NULL, NULL },
&_mbox_config[2], NULL, 0, NULL, &_mbox_config[2], NULL, 0, NULL,
0, NULL, -1, 0, NULL, -1,
0, PC_FROM, NULL, 0, NULL, 0, PC_FROM, NULL, 0, NULL,
"stock_mail-handling" "stock_mail-handling"
}; },
{
static MboxFolder _mbox_sent = NULL,
{ { AFT_SENT, "Sent", NULL, NULL },
&_mbox_config[3], NULL, 0, NULL, &_mbox_config[3], NULL, 0, NULL,
0, NULL, -1, 0, NULL, -1,
0, PC_FROM, NULL, 0, NULL, 0, PC_FROM, NULL, 0, NULL,
"mailer-sent" "mailer-sent"
}; },
{
static MboxFolder _mbox_trash = NULL,
{ { AFT_TRASH, "Trash", NULL, NULL },
&_mbox_config[4], NULL, 0, NULL, &_mbox_config[4], NULL, 0, NULL,
0, NULL, -1, 0, NULL, -1,
0, PC_FROM, NULL, 0, NULL, 0, PC_FROM, NULL, 0, NULL,
"stock_trash_full" "stock_trash_full"
}; }
static AccountFolder _config_folder[_FOLDER_CNT] =
{
{ AFT_INBOX, "Inbox", NULL, &_mbox_inbox },
{ AFT_INBOX, "Spool", NULL, &_mbox_spool },
{ AFT_DRAFTS, "Drafts", NULL, &_mbox_drafts },
{ AFT_SENT, "Sent", NULL, &_mbox_sent },
{ AFT_TRASH, "Trash", NULL, &_mbox_trash }
}; };
/* plug-in */ /* plug-in */
static int _mbox_init(GtkTreeStore * store, GtkTreeIter * parent, static int _mbox_init(AccountPlugin * plugin, GtkTreeStore * store,
GtkTextBuffer * buffer); GtkTreeIter * parent, GtkTextBuffer * buffer);
static int _mbox_quit(void); static int _mbox_destroy(AccountPlugin * plugin);
static GtkTextBuffer * _mbox_select(AccountFolder * folder, static GtkTextBuffer * _mbox_select(AccountPlugin * plugin,
AccountMessage * message); AccountFolder * folder, AccountMessage * message);
static GtkTextBuffer * _mbox_select_source(AccountFolder * folder, static GtkTextBuffer * _mbox_select_source(AccountPlugin * plugin,
AccountMessage * message); AccountFolder * folder, AccountMessage * message);
AccountPlugin account_plugin = AccountPlugin account_plugin =
{ {
NULL, NULL,
_mbox_type, "MBOX",
_mbox_name, "Local folders",
NULL,
_mbox_config, _mbox_config,
_mbox_init, _mbox_init,
_mbox_quit, _mbox_destroy,
_mbox_select, _mbox_select,
_mbox_select_source, _mbox_select_source,
NULL NULL
@ -190,31 +193,39 @@ static int _message_set_header(AccountMessage * message, char const * header,
/* Mbox */ /* Mbox */
/* functions */ /* functions */
/* mbox_init */ /* mbox_init */
static int _mbox_init(GtkTreeStore * store, GtkTreeIter * parent, static int _mbox_init(AccountPlugin * plugin, GtkTreeStore * store,
GtkTextBuffer * buffer) GtkTreeIter * parent, GtkTextBuffer * buffer)
{ {
int ret = 0; int ret = 0;
Mbox * mbox;
size_t i; size_t i;
char * filename; char * filename;
AccountFolder * af; AccountFolder * af;
MboxFolder * mbox; MboxFolder * folder;
GdkPixbuf * pixbuf; GdkPixbuf * pixbuf;
GtkTreeIter iter; GtkTreeIter iter;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif #endif
if((mbox = malloc(sizeof(*mbox))) == NULL)
return -1;
plugin->priv = mbox;
mbox->plugin = plugin;
memcpy(mbox->folders, _mbox_folder_defaults, sizeof(mbox->folders));
for(i = 0; i < _FOLDER_CNT; i++) for(i = 0; i < _FOLDER_CNT; i++)
{ {
af = &_config_folder[i]; af = &mbox->folders[i].folder;
mbox = af->data; af->data = &mbox->folders[i];
mbox->buffer = buffer; folder = &mbox->folders[i];
filename = mbox->config->value; folder->mbox = mbox;
folder->buffer = buffer;
filename = folder->config->value;
if(filename == NULL) if(filename == NULL)
continue; continue;
pixbuf = gtk_icon_theme_load_icon(account_plugin.helper->theme, pixbuf = gtk_icon_theme_load_icon(account_plugin.helper->theme,
(mbox->pixbuf != NULL) (folder->pixbuf != NULL)
? mbox->pixbuf : "stock_folder", 16, ? folder->pixbuf : "stock_folder", 16,
0, NULL); 0, NULL);
gtk_tree_store_append(store, &iter, parent); gtk_tree_store_append(store, &iter, parent);
gtk_tree_store_set(store, &iter, MF_COL_ACCOUNT, NULL, gtk_tree_store_set(store, &iter, MF_COL_ACCOUNT, NULL,
@ -222,40 +233,42 @@ static int _mbox_init(GtkTreeStore * store, GtkTreeIter * parent,
MF_COL_NAME, af->name, -1); MF_COL_NAME, af->name, -1);
g_object_unref(pixbuf); g_object_unref(pixbuf);
/* XXX should not be done here? */ /* XXX should not be done here? */
_config_folder[i].store = gtk_list_store_new(MH_COL_COUNT, af->store = gtk_list_store_new(MH_COL_COUNT, G_TYPE_POINTER,
G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, GDK_TYPE_PIXBUF,
GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN, G_TYPE_INT); G_TYPE_INT);
mbox->source = g_idle_add(_folder_idle, &_config_folder[i]); folder->source = g_idle_add(_folder_idle, af);
} }
return ret; return ret;
} }
/* mbox_quit */ /* mbox_destroy */
static int _mbox_quit(void) static int _mbox_destroy(AccountPlugin * plugin)
{ {
Mbox * mbox = plugin->priv;
size_t i; size_t i;
MboxFolder * mf; MboxFolder * mf;
size_t j; size_t j;
for(i = 0; i < _FOLDER_CNT; i++) for(i = 0; i < _FOLDER_CNT; i++)
{ {
mf = _config_folder[i].data; mf = &mbox->folders[i];
for(j = 0; j < mf->messages_cnt; j++) for(j = 0; j < mf->messages_cnt; j++)
_message_delete(mf->messages[j]); _message_delete(mf->messages[j]);
free(mf->messages); free(mf->messages);
mf->messages = NULL; mf->messages = NULL;
mf->messages_cnt = 0; mf->messages_cnt = 0;
} }
free(mbox);
return 0; return 0;
} }
/* mbox_select */ /* mbox_select */
static GtkTextBuffer * _mbox_select(AccountFolder * folder, static GtkTextBuffer * _mbox_select(AccountPlugin * plugin,
AccountMessage * message) AccountFolder * folder, AccountMessage * message)
{ {
MboxFolder * mf = folder->data; MboxFolder * mf = folder->data;
char const * filename = mf->config->value; char const * filename = mf->config->value;
@ -272,7 +285,10 @@ static GtkTextBuffer * _mbox_select(AccountFolder * folder,
gtk_text_buffer_get_end_iter(mf->buffer, &iter); gtk_text_buffer_get_end_iter(mf->buffer, &iter);
/* XXX we may still be reading the file... */ /* XXX we may still be reading the file... */
if((fp = fopen(filename, "r")) == NULL) if((fp = fopen(filename, "r")) == NULL)
{
plugin->helper->error(NULL, strerror(errno), 1);
return NULL; return NULL;
}
if(message->body_offset != 0 && message->body_length > 0 if(message->body_offset != 0 && message->body_length > 0
&& fseek(fp, message->body_offset, SEEK_SET) == 0 && fseek(fp, message->body_offset, SEEK_SET) == 0
&& (buf = malloc(message->body_length)) != NULL) && (buf = malloc(message->body_length)) != NULL)
@ -287,8 +303,8 @@ static GtkTextBuffer * _mbox_select(AccountFolder * folder,
/* mbox_select_source */ /* mbox_select_source */
static GtkTextBuffer * _mbox_select_source(AccountFolder * folder, static GtkTextBuffer * _mbox_select_source(AccountPlugin * plugin,
AccountMessage * message) AccountFolder * folder, AccountMessage * message)
{ {
/* FIXME code duplication with _mbox_select */ /* FIXME code duplication with _mbox_select */
GtkTextBuffer * ret; GtkTextBuffer * ret;
@ -307,7 +323,10 @@ static GtkTextBuffer * _mbox_select_source(AccountFolder * folder,
gtk_text_buffer_get_end_iter(ret, &iter); gtk_text_buffer_get_end_iter(ret, &iter);
/* XXX we may still be reading the file... */ /* XXX we may still be reading the file... */
if((fp = fopen(filename, "r")) == NULL) if((fp = fopen(filename, "r")) == NULL)
{
plugin->helper->error(NULL, strerror(errno), 1);
return NULL; return NULL;
}
size = message->body_offset - message->offset + message->body_length; size = message->body_offset - message->offset + message->body_length;
if(fseek(fp, message->offset, SEEK_SET) == 0 if(fseek(fp, message->offset, SEEK_SET) == 0
&& (buf = malloc(size)) != NULL) && (buf = malloc(size)) != NULL)
@ -476,9 +495,10 @@ AccountMessage * _folder_message_add(AccountFolder * folder, off_t offset)
static gboolean _folder_idle(gpointer data) static gboolean _folder_idle(gpointer data)
{ {
AccountFolder * folder = data; AccountFolder * folder = data;
MboxFolder * mbox = folder->data; MboxFolder * mf = folder->data;
Mbox * mbox = mf->mbox;
struct stat st; struct stat st;
char const * filename = mbox->config->value; char const * filename = mf->config->value;
GError * error = NULL; GError * error = NULL;
#ifdef DEBUG #ifdef DEBUG
@ -488,26 +508,26 @@ static gboolean _folder_idle(gpointer data)
return FALSE; return FALSE;
if(stat(filename, &st) != 0) if(stat(filename, &st) != 0)
{ {
_error = strerror(errno); mbox->plugin->helper->error(NULL, strerror(errno), 1);
mbox->source = g_timeout_add(1000, _folder_idle, folder); mf->source = g_timeout_add(1000, _folder_idle, folder);
return FALSE; return FALSE;
} }
if(st.st_mtime == mbox->mtime) if(st.st_mtime == mf->mtime)
{ {
mbox->source = g_timeout_add(1000, _folder_idle, folder); mf->source = g_timeout_add(1000, _folder_idle, folder);
return FALSE; return FALSE;
} }
mbox->mtime = st.st_mtime; /* FIXME only when done */ mf->mtime = st.st_mtime; /* FIXME only when done */
if(mbox->channel == NULL) if(mf->channel == NULL)
if((mbox->channel = g_io_channel_new_file(filename, "r", if((mf->channel = g_io_channel_new_file(filename, "r",
&error)) == NULL) &error)) == NULL)
{ {
_error = error->message; mbox->plugin->helper->error(NULL, error->message, 1);
mbox->source = g_timeout_add(1000, _folder_idle, folder); mf->source = g_timeout_add(1000, _folder_idle, folder);
return FALSE; return FALSE;
} }
g_io_channel_set_encoding(mbox->channel, NULL, NULL); g_io_channel_set_encoding(mf->channel, NULL, NULL);
mbox->source = g_io_add_watch(mbox->channel, G_IO_IN, _folder_watch, mf->source = g_io_add_watch(mf->channel, G_IO_IN, _folder_watch,
folder); folder);
return FALSE; return FALSE;
} }
@ -529,7 +549,8 @@ static gboolean _folder_watch(GIOChannel * source, GIOCondition condition,
gpointer data) gpointer data)
{ {
AccountFolder * folder = data; AccountFolder * folder = data;
MboxFolder * mbox = folder->data; MboxFolder * mf = folder->data;
Mbox * mbox = mf->mbox;
char buf[BUFSIZ]; char buf[BUFSIZ];
size_t read; size_t read;
GError * error = NULL; GError * error = NULL;
@ -537,7 +558,7 @@ static gboolean _folder_watch(GIOChannel * source, GIOCondition condition,
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__,
(char const *)mbox->config->value); (char const *)mf->config->value);
#endif #endif
if(condition != G_IO_IN) if(condition != G_IO_IN)
return FALSE; /* FIXME implement message deletion */ return FALSE; /* FIXME implement message deletion */
@ -546,7 +567,7 @@ static gboolean _folder_watch(GIOChannel * source, GIOCondition condition,
switch(status) switch(status)
{ {
case G_IO_STATUS_ERROR: case G_IO_STATUS_ERROR:
_error = error->message; mbox->plugin->helper->error(NULL, error->message, 1);
/* FIXME new timeout 1000 function after invalidating /* FIXME new timeout 1000 function after invalidating
* mtime */ * mtime */
return FALSE; return FALSE;
@ -560,14 +581,12 @@ static gboolean _folder_watch(GIOChannel * source, GIOCondition condition,
if(status == G_IO_STATUS_EOF) if(status == G_IO_STATUS_EOF)
{ {
/* XXX should not be necessary here */ /* XXX should not be necessary here */
if(mbox->message != NULL) if(mf->message != NULL)
_message_set_body(mbox->message, _message_set_body(mf->message, mf->message->body_offset,
mbox->message->body_offset, mf->offset - mf->message->body_offset);
mbox->offset
- mbox->message->body_offset);
g_io_channel_close(source); g_io_channel_close(source);
mbox->channel = NULL; mf->channel = NULL;
mbox->source = g_timeout_add(1000, _folder_idle, folder); mf->source = g_timeout_add(1000, _folder_idle, folder);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -42,6 +42,7 @@ AccountPlugin account_plugin =
NULL, NULL,
_nntp_type, _nntp_type,
_nntp_name, _nntp_name,
NULL,
_nntp_config, _nntp_config,
NULL, NULL,
NULL, NULL,

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -44,6 +44,7 @@ AccountPlugin account_plugin =
NULL, NULL,
_pop3_type, _pop3_type,
_pop3_name, _pop3_name,
NULL,
_pop3_config, _pop3_config,
NULL, NULL,
NULL, NULL,

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -38,6 +38,7 @@ AccountPlugin account_plugin =
NULL, NULL,
_rss_type, _rss_type,
_rss_name, _rss_name,
NULL,
_rss_config, _rss_config,
NULL, NULL,
NULL, NULL,

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
static char const _copyright[] = static char const _copyright[] =
"Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>"; "Copyright (c) 2011 Pierre Pronchery <khorben@defora.org>";
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
static char const _license[] = static char const _license[] =
"This program is free software: you can redistribute it and/or modify\n" "This program is free software: you can redistribute it and/or modify\n"

View File

@ -349,6 +349,7 @@ static int _new_plugins(Mailer * mailer)
mailer->helper.theme, "mail-read", 16, 0, NULL); mailer->helper.theme, "mail-read", 16, 0, NULL);
mailer->helper.mail_unread = gtk_icon_theme_load_icon( mailer->helper.mail_unread = gtk_icon_theme_load_icon(
mailer->helper.theme, "mail-unread", 16, 0, NULL); mailer->helper.theme, "mail-unread", 16, 0, NULL);
mailer->helper.error = mailer_error;
if((dirname = string_new_append(PLUGINDIR, "/account", NULL)) == NULL) if((dirname = string_new_append(PLUGINDIR, "/account", NULL)) == NULL)
return -1; return -1;
if((dir = opendir(dirname)) == NULL) if((dir = opendir(dirname)) == NULL)