2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Christophe Chapuis (for any bug report, please mail me to tofe@users.berlios.de)
27
******************************************************************************/
30
#include <cairo-dock.h>
31
#include <libetpan/libetpan.h>
33
#include "cd-mail-applet-struct.h"
34
#include "cd-mail-applet-etpan.h"
35
#include "cd-mail-applet-accounts.h"
37
#define _add_icon(pMailAccount)\
38
pIcon = g_new0 (Icon, 1);\
39
pIcon->acName = g_strdup (pMailAccount->name);\
40
pIcon->acFileName = g_strdup (myConfig.cNoMailUserImage);\
41
pIcon->cQuickInfo = g_strdup ("...");\
45
pIcon->fWidthFactor = 1.;\
46
pIcon->fHeightFactor = 1.;\
47
pIcon->acCommand = g_strdup ("none");\
48
pIcon->cParentDockName = g_strdup (myIcon->acName);\
49
cd_debug (" + %s (%s)\n", pIcon->acName, pIcon->acFileName);\
50
pIconList = g_list_append (pIconList, pIcon);\
51
pMailAccount->icon = pIcon;
53
void cd_mail_create_pop3_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
55
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "pop3");
56
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL); // on lui met un widget pour ne pas que la cle se fasse bazarder lors d'une mise a jour du fichier de conf.
58
g_key_file_set_string (pKeyFile, pMailAccountName, "host", "pop3.myhost.org");
59
g_key_file_set_comment (pKeyFile, pMailAccountName, "host", "s0 server address:", NULL);
61
g_key_file_set_string (pKeyFile, pMailAccountName, "username", "myLogin");
62
g_key_file_set_comment (pKeyFile, pMailAccountName, "username", "s0 username:", NULL);
64
g_key_file_set_string (pKeyFile, pMailAccountName, "password", "");
65
g_key_file_set_comment (pKeyFile, pMailAccountName, "password", "p0 password:\n{The password will be crypted.}", NULL);
67
g_key_file_set_integer (pKeyFile, pMailAccountName, "port", 0);
68
g_key_file_set_comment (pKeyFile, pMailAccountName, "port", "i0 port:\n{Enter 0 to use the default port. Default ports are 110 for POP3 or APOP and 995 for POP3S.}", NULL);
70
g_key_file_set_boolean (pKeyFile, pMailAccountName, "use secure connection", FALSE);
71
g_key_file_set_comment (pKeyFile, pMailAccountName, "use secure connection", "b0 use secure connection (SSL)", NULL);
73
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
74
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
77
void cd_mail_retrieve_pop3_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
79
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
81
gboolean bFlushConfFileNeeded = FALSE;
83
mailaccount->driver = POP3_STORAGE;
84
mailaccount->storage = mailstorage_new(NULL);
85
mailaccount->folder = NULL;
86
mailaccount->server = NULL;
87
mailaccount->port = 0;
88
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
89
mailaccount->user = NULL;
90
mailaccount->password = NULL;
91
mailaccount->auth_type = POP3_AUTH_TYPE_TRY_APOP;
92
mailaccount->path = NULL;
93
mailaccount->timeout = 0;
95
if (g_key_file_has_key (pKeyFile, mailbox_name, "host", NULL))
97
mailaccount->server = CD_CONFIG_GET_STRING (mailbox_name, "host");
99
if (g_key_file_has_key (pKeyFile, mailbox_name, "username", NULL))
101
mailaccount->user = CD_CONFIG_GET_STRING (mailbox_name, "username");
103
if (g_key_file_has_key (pKeyFile, mailbox_name, "password", NULL))
105
gchar *encryptedPassword = CD_CONFIG_GET_STRING (mailbox_name, "password");
106
cairo_dock_decrypt_string( encryptedPassword, &(mailaccount->password) );
108
if( encryptedPassword ) g_free(encryptedPassword);
110
mailaccount->connection_type = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT (mailbox_name, "use secure connection", FALSE)?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN;
111
mailaccount->port = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "port", 0);
113
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
116
void cd_mail_create_imap_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
118
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "imap");
119
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);
121
g_key_file_set_string (pKeyFile, pMailAccountName, "host", "imap.myhost.org");
122
g_key_file_set_comment (pKeyFile, pMailAccountName, "host", "s0 server address:", NULL);
124
g_key_file_set_string (pKeyFile, pMailAccountName, "username", "myLogin");
125
g_key_file_set_comment (pKeyFile, pMailAccountName, "username", "s0 username:", NULL);
127
g_key_file_set_string (pKeyFile, pMailAccountName, "password", "");
128
g_key_file_set_comment (pKeyFile, pMailAccountName, "password", "p0 password:", NULL);
130
g_key_file_set_integer (pKeyFile, pMailAccountName, "port", 0);
131
g_key_file_set_comment (pKeyFile, pMailAccountName, "port", "i0 port:\n{Enter 0 to use the default port. Default ports are 143 for IMAP4 and 993 for IMAP4 over SSL.}", NULL);
133
g_key_file_set_boolean (pKeyFile, pMailAccountName, "use secure connection", FALSE);
134
g_key_file_set_comment (pKeyFile, pMailAccountName, "use secure connection", "b0 use secure connection (SSL)", NULL);
136
g_key_file_set_string (pKeyFile, pMailAccountName, "server_directory", "Inbox");
137
g_key_file_set_comment (pKeyFile, pMailAccountName, "server_directory", "s0 directory on server:", NULL);
139
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
140
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
143
void cd_mail_retrieve_imap_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
145
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
147
gboolean bFlushConfFileNeeded = FALSE;
149
mailaccount->driver = IMAP_STORAGE;
150
mailaccount->storage = mailstorage_new(NULL);
151
mailaccount->folder = NULL;
152
mailaccount->server = NULL;
153
mailaccount->port = 0;
154
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
155
mailaccount->user = NULL;
156
mailaccount->password = NULL;
157
mailaccount->auth_type = IMAP_AUTH_TYPE_PLAIN;
158
mailaccount->path = g_strdup("/");
159
mailaccount->timeout = 0;
161
if (g_key_file_has_key (pKeyFile, mailbox_name, "host", NULL))
163
mailaccount->server = CD_CONFIG_GET_STRING (mailbox_name, "host");
165
if (g_key_file_has_key (pKeyFile, mailbox_name, "username", NULL))
167
mailaccount->user = CD_CONFIG_GET_STRING (mailbox_name, "username");
169
if (g_key_file_has_key (pKeyFile, mailbox_name, "password", NULL))
171
gchar *encryptedPassword = CD_CONFIG_GET_STRING (mailbox_name, "password");
172
cairo_dock_decrypt_string( encryptedPassword, &(mailaccount->password) );
174
if( encryptedPassword ) g_free(encryptedPassword);
176
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
177
mailaccount->port = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "port", 0);
179
mailaccount->connection_type = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT (mailbox_name, "use secure connection", FALSE)?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN;
181
/* CONNECTION_TYPE_TLS ? CONNECTION_TYPE_STARTTLS ? */
183
if (g_key_file_has_key (pKeyFile, mailbox_name, "server_directory", NULL))
185
mailaccount->path = CD_CONFIG_GET_STRING (mailbox_name, "server_directory");
189
void cd_mail_create_mbox_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
191
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "mbox");
192
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);
194
g_key_file_set_string (pKeyFile, pMailAccountName, "filename", "");
195
g_key_file_set_comment (pKeyFile, pMailAccountName, "filename", "s0 path of mbox file:", NULL);
197
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
198
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
201
void cd_mail_retrieve_mbox_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
203
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
205
gboolean bFlushConfFileNeeded = FALSE;
207
mailaccount->driver = MBOX_STORAGE;
208
mailaccount->storage = mailstorage_new(NULL);
209
mailaccount->folder = NULL;
210
mailaccount->server = NULL;
211
mailaccount->port = 0;
212
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
213
mailaccount->user = NULL;
214
mailaccount->password = NULL;
215
mailaccount->auth_type = POP3_AUTH_TYPE_PLAIN;
216
mailaccount->timeout = 0;
217
if (g_key_file_has_key (pKeyFile, mailbox_name, "filename", NULL))
218
mailaccount->path = CD_CONFIG_GET_STRING_WITH_DEFAULT (mailbox_name, "filename", "/");
219
if (mailaccount->path == NULL)
220
mailaccount->path = g_strdup("/");
221
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
223
//{"filename", "ctime", "size", "interval", NULL, NULL}
226
void cd_mail_create_mh_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
228
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "mh");
229
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);
231
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
232
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
235
void cd_mail_retrieve_mh_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
237
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
239
gboolean bFlushConfFileNeeded = FALSE;
241
mailaccount->driver = MH_STORAGE;
242
mailaccount->storage = mailstorage_new(NULL);
243
mailaccount->folder = NULL;
244
mailaccount->server = NULL;
245
mailaccount->port = 0;
246
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
247
mailaccount->user = NULL;
248
mailaccount->password = NULL;
249
mailaccount->auth_type = POP3_AUTH_TYPE_PLAIN;
250
mailaccount->path = g_strdup("/");
251
mailaccount->timeout = 0;
253
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
256
void cd_mail_create_maildir_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
258
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "maildir");
259
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);
261
g_key_file_set_string (pKeyFile, pMailAccountName, "path", "");
262
g_key_file_set_comment (pKeyFile, pMailAccountName, "path", "s0 path to mail directory:", NULL);
264
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
265
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
268
void cd_mail_retrieve_maildir_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
270
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
272
gboolean bFlushConfFileNeeded = FALSE;
274
mailaccount->driver = MAILDIR_STORAGE;
275
mailaccount->storage = mailstorage_new(NULL);
276
mailaccount->folder = NULL;
277
mailaccount->server = NULL;
278
mailaccount->port = 0;
279
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
280
mailaccount->user = NULL;
281
mailaccount->password = NULL;
282
mailaccount->auth_type = POP3_AUTH_TYPE_PLAIN;
283
mailaccount->path = g_strdup("/");
284
mailaccount->timeout = 0;
286
if (g_key_file_has_key (pKeyFile, mailbox_name, "path", NULL))
288
mailaccount->path = CD_CONFIG_GET_STRING (mailbox_name, "path");
290
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
292
//{"path", "mtime", "interval", NULL, NULL, NULL, NULL}
295
void cd_mail_create_gmail_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
297
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "gmail");
298
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);
300
g_key_file_set_string (pKeyFile, pMailAccountName, "username", "myLogin");
301
g_key_file_set_comment (pKeyFile, pMailAccountName, "username", "s0 username:", NULL);
303
g_key_file_set_string (pKeyFile, pMailAccountName, "password", "");
304
g_key_file_set_comment (pKeyFile, pMailAccountName, "password", "p0 password:", NULL);
306
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
307
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
310
void cd_mail_retrieve_gmail_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
312
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
314
gboolean bFlushConfFileNeeded = FALSE;
316
#if ( __WORDSIZE == 64 )
317
/* in 64bit libetpan crashes with RSS, so use the IMAP feature of GMail
319
mailaccount->driver = IMAP_STORAGE;
320
mailaccount->storage = mailstorage_new(NULL);
321
mailaccount->folder = NULL;
322
mailaccount->server = g_strdup("imap.gmail.com");
323
mailaccount->port = 993;
324
mailaccount->connection_type = CONNECTION_TYPE_TLS;
325
mailaccount->user = NULL;
326
mailaccount->password = NULL;
327
mailaccount->auth_type = IMAP_AUTH_TYPE_PLAIN;
328
mailaccount->path = g_strdup("Inbox");
329
mailaccount->timeout = 0;
331
if (g_key_file_has_key (pKeyFile, mailbox_name, "username", NULL))
333
mailaccount->user = CD_CONFIG_GET_STRING (mailbox_name, "username");
335
if (g_key_file_has_key (pKeyFile, mailbox_name, "password", NULL))
337
gchar *encryptedPassword = CD_CONFIG_GET_STRING (mailbox_name, "password");
338
cairo_dock_decrypt_string( encryptedPassword, &(mailaccount->password) );
340
if( encryptedPassword ) g_free(encryptedPassword);
342
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
344
mailaccount->driver = FEED_STORAGE;
345
mailaccount->storage = mailstorage_new(NULL);
346
mailaccount->folder = NULL;
347
mailaccount->server = NULL;
348
mailaccount->port = 443;
349
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
350
mailaccount->user = NULL;
351
mailaccount->password = NULL;
352
mailaccount->auth_type = POP3_AUTH_TYPE_PLAIN;
353
mailaccount->path = NULL;
354
mailaccount->timeout = 0;
356
if (g_key_file_has_key (pKeyFile, mailbox_name, "username", NULL))
358
mailaccount->user = CD_CONFIG_GET_STRING (mailbox_name, "username");
360
if (g_key_file_has_key (pKeyFile, mailbox_name, "password", NULL))
362
gchar *encryptedPassword = CD_CONFIG_GET_STRING (mailbox_name, "password");
363
cairo_dock_decrypt_string( encryptedPassword, &(mailaccount->password) );
365
if( encryptedPassword ) g_free(encryptedPassword);
368
gchar *user_without_column = NULL;
369
gchar *password_without_column = NULL;
371
if( mailaccount->user )
373
gchar **splitString = g_strsplit(mailaccount->user, ":", 0);
374
user_without_column = g_strjoinv("%3A", splitString);
375
g_strfreev( splitString );
377
if( mailaccount->password )
379
gchar **splitString = g_strsplit(mailaccount->password, ":", 0);
380
password_without_column = g_strjoinv("%3A", splitString);
381
g_strfreev( splitString );
384
if( user_without_column && password_without_column )
386
mailaccount->path = g_strconcat("https://", user_without_column, ":", password_without_column, "@mail.google.com/mail/feed/atom", NULL);
390
mailaccount->path = g_strdup( "https://mail.google.com/mail/feed/atom" );
392
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
394
g_free( user_without_column );
395
g_free( password_without_column );
399
void cd_mail_create_feed_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
401
g_key_file_set_string (pKeyFile, pMailAccountName, "type", "feed");
402
g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);
404
g_key_file_set_string (pKeyFile, pMailAccountName, "path", "http://www.cairo-dock.org/rss/cd_svn.xml");
405
g_key_file_set_comment (pKeyFile, pMailAccountName, "path", "s0 address of feed:", NULL);
407
g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
408
g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
411
void cd_mail_retrieve_feed_params (CDMailAccount *mailaccount, GKeyFile *pKeyFile, gchar *mailbox_name)
413
if( !mailaccount || !pKeyFile || !mailbox_name ) return;
415
extern int mailstream_debug;
416
mailstream_debug = 1;
418
gboolean bFlushConfFileNeeded = FALSE;
420
mailaccount->driver = FEED_STORAGE;
421
mailaccount->storage = mailstorage_new(NULL);
422
mailaccount->folder = NULL;
423
mailaccount->server = NULL;
424
mailaccount->port = 443;
425
mailaccount->connection_type = CONNECTION_TYPE_PLAIN;
426
mailaccount->user = NULL;
427
mailaccount->password = NULL;
428
mailaccount->auth_type = POP3_AUTH_TYPE_PLAIN;
429
mailaccount->path = NULL;
430
mailaccount->timeout = 0;
432
if (g_key_file_has_key (pKeyFile, mailbox_name, "path", NULL))
434
mailaccount->path = CD_CONFIG_GET_STRING (mailbox_name, "path");
436
mailaccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (mailbox_name, "timeout mn", 10);
440
{POP3_STORAGE, "pop3", {"host", "username", "password", "auth_type", "timeout mn", "port", NULL}},
441
{IMAP_STORAGE, "imap", {"host", "username", "password", "auth_type", "timeout mn", "port", "server_directory"}},
442
{NNTP_STORAGE, "nntp", {NULL, NULL, NULL, NULL, NULL, NULL, NULL}},
443
{MBOX_STORAGE, "mbox", {"filename", "ctime", "size", "interval", NULL, NULL}},
444
{MH_STORAGE, "mh", {"timeout mn", NULL, NULL, NULL, NULL, NULL, NULL}},
445
{MAILDIR_STORAGE, "maildir", {"path", "mtime", "interval", NULL, NULL, NULL, NULL}},
446
{FEED_STORAGE, "feed", {"username", "password", "timeout mn", NULL, NULL, NULL, NULL}},
447
{FEED_STORAGE, "gmail", {"username", "password", "timeout mn", NULL, NULL, NULL, NULL}},
451
void cd_mail_init_accounts(CairoDockModuleInstance *myApplet)
453
if (myData.pMailAccounts == NULL)
455
g_print ("%s (%d comptes)\n", __func__, myData.pMailAccounts->len);
457
//\_______________________ On initialise chaque compte.
458
CDMailAccount *pMailAccount;
459
GList *pIconList = NULL;
464
for (i = 0; i < myData.pMailAccounts->len; i ++)
466
pMailAccount = g_ptr_array_index (myData.pMailAccounts, i);
467
if( !pMailAccount ) continue;
470
switch (pMailAccount->driver) {
472
r = pop3_mailstorage_init(pMailAccount->storage, pMailAccount->server, pMailAccount->port,
473
NULL, pMailAccount->connection_type,
474
pMailAccount->auth_type, pMailAccount->user, pMailAccount->password,
475
FALSE /*cached*/, NULL /*cache_directory*/, NULL /*flags_directory*/);
479
r = imap_mailstorage_init(pMailAccount->storage, pMailAccount->server, pMailAccount->port,
480
NULL, pMailAccount->connection_type,
481
IMAP_AUTH_TYPE_PLAIN, pMailAccount->user, pMailAccount->password,
482
FALSE /*cached*/, NULL /*cache_directory*/);
486
r = nntp_mailstorage_init(pMailAccount->storage, pMailAccount->server, pMailAccount->port,
487
NULL, pMailAccount->connection_type,
488
NNTP_AUTH_TYPE_PLAIN, pMailAccount->user, pMailAccount->password,
489
FALSE /*cached*/, NULL /*cache_directory*/, NULL /*flags_directory*/);
493
r = mbox_mailstorage_init(pMailAccount->storage, pMailAccount->path,
494
FALSE /*cached*/, NULL /*cache_directory*/, NULL /*flags_directory*/);
498
r = mh_mailstorage_init(pMailAccount->storage, pMailAccount->path,
499
FALSE /*cached*/, NULL /*cache_directory*/, NULL /*flags_directory*/);
502
case MAILDIR_STORAGE:
503
r = maildir_mailstorage_init(pMailAccount->storage, pMailAccount->path,
504
FALSE /*cached*/, NULL /*cache_directory*/, NULL /*flags_directory*/);
508
r = feed_mailstorage_init(pMailAccount->storage, pMailAccount->path,
509
FALSE /*cached*/, NULL /*cache_directory*/, NULL /*flags_directory*/);
515
// add an icon for this account.
516
if (myData.pMailAccounts->len == 1) // 1 seul compte
522
_add_icon (pMailAccount);
526
// if all is OK, then set a timeout for this mail account
527
if (r == MAIL_NO_ERROR)
529
CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("...");
530
pMailAccount->pAccountMailTimer = cairo_dock_new_task (pMailAccount->timeout * 60,
531
(CairoDockGetDataAsyncFunc) cd_mail_get_folder_data,
532
(CairoDockUpdateSyncFunc) cd_mail_update_account_status,
534
cairo_dock_launch_task (pMailAccount->pAccountMailTimer);
538
cd_warning ("mail : the mail account %s couldn't be initialized !", pMailAccount->name);
539
CairoContainer *pContainer = (myData.pMailAccounts->len == 1 ? myContainer : CD_APPLET_MY_ICONS_LIST_CONTAINER);
540
cairo_dock_set_quick_info (myDrawContext, "N/A", pIcon, cairo_dock_get_max_scale (pContainer));
544
//\_______________________ On efface l'ancienne liste.
545
CD_APPLET_DELETE_MY_ICONS_LIST;
547
//\_______________________ On charge la nouvelle liste.
548
if (myData.pMailAccounts->len > 1)
550
gpointer pConfig[2] = {GINT_TO_POINTER (FALSE), GINT_TO_POINTER (FALSE)};
551
CD_APPLET_LOAD_MY_ICONS_LIST (pIconList, myConfig.cRenderer, (iNbIcons > 1 ? "Caroussel" : "Simple"), (iNbIcons > 1 ? pConfig : NULL));
554
//\_______________ On dessine l'icone principale initialement.
555
CD_APPLET_SET_IMAGE_ON_MY_ICON (myConfig.cNoMailUserImage);
557
CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("...");
561
void cd_mail_free_account (CDMailAccount *pMailAccount)
563
if (pMailAccount == NULL)
566
cairo_dock_free_task( pMailAccount->pAccountMailTimer );
568
g_free( pMailAccount->name );
569
g_free( pMailAccount->server );
570
g_free( pMailAccount->user );
571
g_free( pMailAccount->password );
572
g_free( pMailAccount->path );
574
if( pMailAccount->folder )
575
mailfolder_free(pMailAccount->folder);
576
if( pMailAccount->storage )
577
mailstorage_free(pMailAccount->storage);
579
g_list_foreach (pMailAccount->pUnseenMessageList, (GFunc) g_free, NULL);
580
g_list_free (pMailAccount->pUnseenMessageList);
582
g_free( pMailAccount );
585
void cd_mail_free_all_accounts (CairoDockModuleInstance *myApplet)
587
if (myData.pMailAccounts == NULL)
589
CDMailAccount *pMailAccount;
591
for (i = 0; i < myData.pMailAccounts->len; i ++)
593
pMailAccount = g_ptr_array_index (myData.pMailAccounts, i);
594
cd_mail_free_account (pMailAccount);
596
g_ptr_array_free (myData.pMailAccounts, TRUE);
597
myData.pMailAccounts = NULL;