Enlightenment CVS committal
Author : englebass
Project : e_modules
Module : mail
Dir : e_modules/mail
Modified Files:
imap2.h imap2.c
Log Message:
Common event handler.
Add some debug messages.
===================================================================
RCS file: /cvs/e/e_modules/mail/imap2.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- imap2.h 25 Jul 2007 18:28:17 -0000 1.4
+++ imap2.h 4 Jan 2008 08:31:21 -0000 1.5
@@ -31,10 +31,6 @@
int idle;
unsigned char idling : 1;
- Ecore_Event_Handler *add_handler;
- Ecore_Event_Handler *del_handler;
- Ecore_Event_Handler *data_handler;
-
void *data;
struct {
===================================================================
RCS file: /cvs/e/e_modules/mail/imap2.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- imap2.c 30 Dec 2007 00:04:37 -0000 1.13
+++ imap2.c 4 Jan 2008 08:31:21 -0000 1.14
@@ -6,7 +6,7 @@
#include "imap2.h"
#if 0
-#define D(args...) printf(##args)
+#define D(args...) printf(args)
#else
#define D(args...)
#endif
@@ -32,6 +32,10 @@
static Evas_List *iclients = NULL;
+static Ecore_Event_Handler *add_handler = NULL;
+static Ecore_Event_Handler *del_handler = NULL;
+static Ecore_Event_Handler *data_handler = NULL;
+
void
_mail_imap_check_mail (void *data)
{
@@ -44,29 +48,19 @@
ic = l->data;
ic->data = data;
- D ("Checking (%s:%s): %p\n", ic->config->host, ic->config->new_path,
ic->server);
+ D ("Checking ([EMAIL PROTECTED]:%s): %p\n", ic->config->host,
ic->config->port, ic->config->new_path, ic->server);
if (!ic->server)
{
- if (!ic->add_handler)
- ic->add_handler =
- ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
- _mail_imap_server_add, NULL);
- if (!ic->del_handler)
- ic->del_handler =
- ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
- _mail_imap_server_del, NULL);
- if (!ic->data_handler)
- ic->data_handler =
- ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
- _mail_imap_server_data, NULL);
-
if (ic->config->local)
type = ECORE_CON_LOCAL_SYSTEM;
else
type = ECORE_CON_REMOTE_SYSTEM;
if (ecore_con_ssl_available_get () && (ic->config->ssl))
- type |= ECORE_CON_USE_SSL;
+ {
+ type |= ECORE_CON_USE_SSL;
+ D ("Use SSL for %s:%s\n", ic->config->host,
ic->config->new_path);
+ }
ic->state = IMAP_STATE_DISCONNECTED;
ic->server =
ecore_con_server_connect (type, ic->config->host,
@@ -95,6 +89,16 @@
return;
/* Client get will create the client if it does not exist */
_mail_imap_client_get (cb);
+
+ if (!add_handler)
+ add_handler = ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
+ _mail_imap_server_add, NULL);
+ if (!del_handler)
+ del_handler = ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
+ _mail_imap_server_del, NULL);
+ if (!data_handler)
+ data_handler = ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
+ _mail_imap_server_data, NULL);
}
void
@@ -109,13 +113,19 @@
ic = _mail_imap_client_get (cb);
if (!ic)
return;
- if (ic->add_handler)
- ecore_event_handler_del (ic->add_handler);
- if (ic->del_handler)
- ecore_event_handler_del (ic->del_handler);
- if (ic->data_handler)
- ecore_event_handler_del (ic->data_handler);
iclients = evas_list_remove (iclients, ic);
+ if (!iclients)
+ {
+ if (add_handler)
+ ecore_event_handler_del (add_handler);
+ add_handler = NULL;
+ if (del_handler)
+ ecore_event_handler_del (del_handler);
+ del_handler = NULL;
+ if (data_handler)
+ ecore_event_handler_del (data_handler);
+ data_handler = NULL;
+ }
_mail_imap_client_logout (ic);
E_FREE (ic);
}
@@ -128,17 +138,21 @@
ImapClient *ic;
ic = iclients->data;
- if (ic->add_handler)
- ecore_event_handler_del (ic->add_handler);
- if (ic->del_handler)
- ecore_event_handler_del (ic->del_handler);
- if (ic->data_handler)
- ecore_event_handler_del (ic->data_handler);
iclients = evas_list_remove_list (iclients, iclients);
_mail_imap_client_logout (ic);
E_FREE (ic->prev.data);
E_FREE (ic);
}
+
+ if (add_handler)
+ ecore_event_handler_del (add_handler);
+ add_handler = NULL;
+ if (del_handler)
+ ecore_event_handler_del (del_handler);
+ del_handler = NULL;
+ if (data_handler)
+ ecore_event_handler_del (data_handler);
+ data_handler = NULL;
}
/* PRIVATES */
@@ -196,6 +210,7 @@
if (!ic)
return 1;
+ D ("Connect to %s:%s\n", ic->config->host, ic->config->new_path);
ic->state = IMAP_STATE_CONNECTED;
ic->cmd = 1;
return 0;
@@ -211,6 +226,7 @@
if (!ic)
return 1;
+ D ("Disconnect from %s:%s\n", ic->config->host, ic->config->new_path);
if (ic->state != IMAP_STATE_DISCONNECTED)
{
printf ("The connection was unexpectedly shut down, consider reducing
the check time.\n");
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs