Use the user settings to control the imap internal timer.

SVN revision: 30433
This commit is contained in:
Sebastian Dransfeld 2007-06-22 12:26:44 +00:00
parent abdc73b82e
commit c1cd2c995d
4 changed files with 28 additions and 12 deletions

View File

@ -277,6 +277,7 @@ _basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
if (!cb) if (!cb)
{ {
cb = E_NEW (Config_Box, 1); cb = E_NEW (Config_Box, 1);
cb->item = mail_ci;
cb->type = 0; cb->type = 0;
cb->port = 110; cb->port = 110;
cb->monitor = 1; cb->monitor = 1;

View File

@ -112,6 +112,7 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
Config_Box *cb; Config_Box *cb;
cb = l->data; cb = l->data;
cb->item = ci;
switch (cb->type) switch (cb->type)
{ {
case MAIL_TYPE_IMAP: case MAIL_TYPE_IMAP:

View File

@ -58,6 +58,7 @@ struct _Config_Item
struct _Config_Box struct _Config_Box
{ {
const char *name; const char *name;
Config_Item *item;
int type; int type;
int port; int port;

31
imap2.c
View File

@ -52,13 +52,17 @@ _mail_imap_check_mail (void *data)
if (ecore_con_ssl_available_get () && (ic->config->ssl)) if (ecore_con_ssl_available_get () && (ic->config->ssl))
type |= ECORE_CON_USE_SSL; type |= ECORE_CON_USE_SSL;
ic->state = IMAP_STATE_DISCONNECTED; ic->state = IMAP_STATE_DISCONNECTED;
printf ("Connect: %s %d %d\n", ic->config->host, ic->config->port, ic->config->ssl);
ic->server = ic->server =
ecore_con_server_connect (type, ic->config->host, ecore_con_server_connect (type, ic->config->host,
ic->config->port, NULL); ic->config->port, NULL);
ic->cmd = 1; ic->cmd = 1;
ic->idle = -1; ic->idle = -1;
} }
else
{
/* Need to set this to revert the state of the icon */
_mail_set_text (ic->data);
}
} }
} }
@ -188,13 +192,16 @@ _mail_imap_server_del (void *data, int type, void *event)
if (!ic) if (!ic)
return 1; return 1;
if (ic->state == IMAP_STATE_DISCONNECTED) if (ic->state != IMAP_STATE_DISCONNECTED)
printf ("Imap Server Disconnected\n"); {
else printf ("The Imap Server disconnected us, consider reducing the check time.\n");
ic->state = IMAP_STATE_DISCONNECTED; ic->state = IMAP_STATE_DISCONNECTED;
}
ecore_con_server_del (ic->server); ecore_con_server_del (ic->server);
ic->server = NULL; ic->server = NULL;
if (ic->timer) ecore_timer_del (ic->timer);
ic->timer = NULL;
_mail_set_text (ic->data); _mail_set_text (ic->data);
return 0; return 0;
@ -234,16 +241,16 @@ _mail_imap_server_data (void *data, int type, void *event)
else else
{ {
printf ("Imap Failure: Couldn't find eol\n"); printf ("Imap Failure: Couldn't find eol\n");
_mail_imap_client_logout (ic);
return 0; return 0;
} }
printf ("Server data |%s|\n", p);
/* parse data */ /* parse data */
if (!_mail_imap_server_data_parse (ic, p, pp - p)) if (!_mail_imap_server_data_parse (ic, p, pp - p))
{ {
_mail_imap_client_logout (ic); _mail_imap_client_logout (ic);
return 0; return 0;
} }
/* cleanup */ /* next */
p = pp + 2; p = pp + 2;
} }
@ -281,12 +288,14 @@ _mail_imap_server_data (void *data, int type, void *event)
{ {
len = snprintf (out, sizeof (out), "A%04i IDLE\r\n", ic->cmd++); len = snprintf (out, sizeof (out), "A%04i IDLE\r\n", ic->cmd++);
ecore_con_server_send (ic->server, out, len); ecore_con_server_send (ic->server, out, len);
ic->timer = ecore_timer_add (29 * 60.0, _mail_imap_server_idle, ic); ic->timer = ecore_timer_add (ic->config->item->check_time * 60.0,
_mail_imap_server_idle, ic);
} }
} }
else if (ic->idle == 0) else if (ic->idle == 0)
{ {
if (!ic->timer) ic->timer = ecore_timer_add (5 * 60.0, _mail_imap_server_noop, ic); if (!ic->timer) ic->timer = ecore_timer_add (ic->config->item->check_time * 60.0,
_mail_imap_server_noop, ic);
} }
break; break;
} }
@ -385,6 +394,10 @@ _mail_imap_server_data_parse (ImapClient *ic, char *line, int length)
{ {
printf ("Result OK: %s\n", value); printf ("Result OK: %s\n", value);
} }
else if (!strcmp (result, "FLAGS"))
{
printf ("Flags: %s\n", value);
}
else else
{ {
char *p; char *p;
@ -486,7 +499,7 @@ _mail_imap_client_logout (ImapClient *ic)
ecore_con_server_del (ic->server); ecore_con_server_del (ic->server);
} }
ic->server = NULL; ic->server = NULL;
if (ic->timer) ecore_timer_del(ic->timer); if (ic->timer) ecore_timer_del (ic->timer);
ic->timer = NULL; ic->timer = NULL;
ic->state = IMAP_STATE_DISCONNECTED; ic->state = IMAP_STATE_DISCONNECTED;
} }