Update for new gadget code.

SVN revision: 31728
master
Sebastian Dransfeld 15 years ago
parent 9b46910a6a
commit fb52fb1a04
  1. 4
      e_mod_config.c
  2. 2
      e_mod_config_box.c
  3. 220
      e_mod_main.c
  4. 7
      e_mod_main.h
  5. 31
      imap2.c

@ -154,7 +154,7 @@ _basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
ci->show_popup = cfdata->show_popup;
ci->show_popup_empty = cfdata->show_popup_empty;
e_config_save_queue ();
_mail_config_updated (ci->id);
_mail_config_updated (ci);
return 1;
}
@ -354,7 +354,7 @@ _cb_del_box (void *data, void *data2)
continue;
if (!strcmp (s, cb->name))
{
_mail_box_deleted (ci->id, cb->name);
_mail_box_deleted (ci, cb->name);
break;
}
}

@ -353,7 +353,7 @@ _basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
/* cfd->data = cb; */
mail_ci->boxes = evas_list_append (mail_ci->boxes, cb);
e_config_save_queue ();
_mail_box_added (mail_ci->id, cb->name);
_mail_box_added (mail_ci, cb->name);
}
_mail_box_config_updated (prev_dlg);

@ -78,14 +78,13 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
E_Gadcon_Client *gcc;
Instance *inst;
Mail *mail;
Config_Item *ci;
Evas_List *l;
int have_pop = 0, have_imap = 0, have_mbox = 0;
inst = E_NEW (Instance, 1);
ci = _mail_config_item_get (id);
if (!ci->id)
ci->id = evas_stringshare_add (id);
inst->ci = _mail_config_item_get (id);
if (!inst->ci->id)
inst->ci->id = evas_stringshare_add (id);
mail = _mail_new (gc->evas);
mail->inst = inst;
@ -103,13 +102,13 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
evas_object_event_callback_add (inst->mail_obj, EVAS_CALLBACK_MOUSE_OUT,
_mail_cb_mouse_out, inst);
if (ci->show_label)
if (inst->ci->show_label)
edje_object_signal_emit (inst->mail_obj, "label_active", "");
else
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
mail_config->instances = evas_list_append (mail_config->instances, inst);
for (l = ci->boxes; l; l = l->next)
for (l = inst->ci->boxes; l; l = l->next)
{
Config_Box *cb;
@ -121,7 +120,7 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
_mail_imap_add_mailbox (cb);
if (!inst->check_timer)
inst->check_timer =
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
ecore_timer_add ((inst->ci->check_time * 60.0), _mail_cb_check,
inst);
break;
case MAIL_TYPE_POP:
@ -129,7 +128,7 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
_mail_pop_add_mailbox (cb);
if (!inst->check_timer)
inst->check_timer =
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
ecore_timer_add ((inst->ci->check_time * 60.0), _mail_cb_check,
inst);
break;
case MAIL_TYPE_MDIR:
@ -140,7 +139,7 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
_mail_mbox_add_mailbox (inst, cb);
if (!inst->check_timer)
inst->check_timer =
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
ecore_timer_add ((inst->ci->check_time * 60.0), _mail_cb_check,
inst);
break;
}
@ -209,7 +208,6 @@ _mail_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
void *event_info)
{
Instance *inst = data;
Config_Item *ci;
Evas_Event_Mouse_Down *ev = event_info;
Evas_List *l;
@ -226,8 +224,7 @@ _mail_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
e_menu_post_deactivate_callback_set (mn, _mail_menu_cb_post, inst);
mail_config->menu = mn;
ci = _mail_config_item_get (inst->gcc->id);
if ((ci->boxes) && (evas_list_count (ci->boxes) > 0))
if ((inst->ci->boxes) && (evas_list_count (inst->ci->boxes) > 0))
{
E_Menu_Item *mm;
@ -238,7 +235,7 @@ _mail_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
e_menu_item_icon_edje_set (mm, buf, "icon");
sn = e_menu_new ();
for (l = ci->boxes; l; l = l->next)
for (l = inst->ci->boxes; l; l = l->next)
{
Config_Box *cb;
@ -283,7 +280,6 @@ static void
_mail_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
Instance *inst = data;
Config_Item *ci;
Evas_Object *list;
Evas_List *l;
char buf[256];
@ -294,20 +290,19 @@ _mail_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, void *event_info)
edje_object_signal_emit (inst->mail_obj, "label_active", "");
if (inst->popup) return;
ci = _mail_config_item_get (inst->gcc->id);
if ((!ci->show_popup) || (!ci->boxes)) return;
if ((!inst->ci->show_popup) || (!inst->ci->boxes)) return;
inst->popup = e_gadcon_popup_new (inst->gcc, _mail_popup_resize);
snprintf (path, sizeof (path), "%s/mail.edj",
e_module_dir_get (mail_config->module));
list = e_tlist_add (inst->popup->win->evas);
for (l = ci->boxes; l; l = l->next)
for (l = inst->ci->boxes; l; l = l->next)
{
Config_Box *cb;
cb = l->data;
if (!cb) continue;
if ((!ci->show_popup_empty) && (!cb->num_new)) continue;
if ((!inst->ci->show_popup_empty) && (!cb->num_new)) continue;
snprintf (buf, sizeof (buf), "%s: %d/%d", cb->name, cb->num_new,
cb->num_total);
e_tlist_append (list, buf, NULL, NULL, NULL, NULL);
@ -328,12 +323,10 @@ static void
_mail_cb_mouse_out (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
Instance *inst = data;
Config_Item *ci;
if (!inst)
return;
ci = _mail_config_item_get (inst->gcc->id);
if (!ci->show_label)
if (!inst->ci->show_label)
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
if (inst->popup)
@ -356,12 +349,10 @@ static void
_mail_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi)
{
Instance *inst = data;
Config_Item *ci;
if (!inst)
return;
ci = _mail_config_item_get (inst->gcc->id);
_config_mail_module (ci);
_config_mail_module (inst->ci);
}
static Config_Item *
@ -544,19 +535,6 @@ e_modapi_shutdown (E_Module * m)
EAPI int
e_modapi_save (E_Module * m)
{
Evas_List *l;
for (l = mail_config->instances; l; l = l->next)
{
Instance *inst;
Config_Item *ci;
inst = l->data;
ci = _mail_config_item_get (inst->gcc->id);
if (ci->id)
evas_stringshare_del (ci->id);
ci->id = evas_stringshare_add (inst->gcc->id);
}
e_config_domain_save ("module.mail", conf_edd, mail_config);
return 1;
}
@ -600,18 +578,13 @@ static int
_mail_cb_check (void *data)
{
Instance *inst = data;
Config_Item *ci;
Evas_List *l;
int have_imap = 0, have_pop = 0, have_mbox = 0;
if (!inst)
return 1;
ci = _mail_config_item_get (inst->gcc->id);
if (!ci->boxes)
return 1;
for (l = ci->boxes; l; l = l->next)
for (l = inst->ci->boxes; l; l = l->next)
{
Config_Box *cb;
@ -650,7 +623,6 @@ void
_mail_set_text (void *data)
{
Instance *inst = data;
Config_Item *ci;
Evas_List *l;
char buf[1024];
int count = 0;
@ -658,23 +630,16 @@ _mail_set_text (void *data)
if (!inst)
return;
ci = _mail_config_item_get (inst->gcc->id);
if (!ci)
return;
for (l = inst->ci->boxes; l; l = l->next)
{
Config_Box *cb;
if (ci->boxes)
{
for (l = ci->boxes; l; l = l->next)
{
Config_Box *cb;
cb = l->data;
if (!cb)
continue;
count += cb->num_new;
}
}
cb = l->data;
if (!cb)
continue;
count += cb->num_new;
}
if (count > 0)
{
snprintf (buf, sizeof (buf), "%d", count);
@ -716,139 +681,120 @@ _mail_cb_exe_exit (void *data, int type, void *event)
}
void
_mail_box_added (const char *ci_name, const char *box_name)
_mail_box_added (Config_Item *ci, const char *box_name)
{
Evas_List *l, *b;
for (l = mail_config->instances; l; l = l->next)
{
Instance *inst;
Config_Item *ci;
inst = l->data;
ci = _mail_config_item_get (inst->gcc->id);
if ((ci->id) && (!strcmp (ci->id, ci_name)))
if (inst->ci != ci) continue;
for (b = ci->boxes; b; b = b->next)
{
for (b = ci->boxes; b; b = b->next)
{
Config_Box *cb;
cb = b->data;
if ((cb->name) && (!strcmp (cb->name, box_name)))
{
switch (cb->type)
{
case MAIL_TYPE_IMAP:
Config_Box *cb;
cb = b->data;
if ((cb->name) && (!strcmp (cb->name, box_name)))
{
switch (cb->type)
{
case MAIL_TYPE_IMAP:
_mail_imap_add_mailbox (cb);
break;
case MAIL_TYPE_POP:
case MAIL_TYPE_POP:
_mail_pop_add_mailbox (cb);
break;
case MAIL_TYPE_MDIR:
case MAIL_TYPE_MDIR:
_mail_mdir_add_mailbox (inst, cb);
break;
case MAIL_TYPE_MBOX:
case MAIL_TYPE_MBOX:
_mail_mbox_add_mailbox (inst, cb);
break;
}
break;
}
}
break;
}
break;
}
}
}
}
void
_mail_box_deleted (const char *ci_name, const char *box_name)
_mail_box_deleted (Config_Item *ci, const char *box_name)
{
Evas_List *d, *i;
Config_Box *cb;
int found = 0;
for (i = mail_config->instances; i; i = i->next)
{
Instance *inst;
inst = i->data;
if (!inst->gcc->id)
continue;
if (!strcmp (inst->gcc->id, ci_name))
{
Config_Item *ci;
Instance *inst;
int found = 0;
ci = _mail_config_item_get (inst->gcc->id);
for (d = ci->boxes; d; d = d->next)
{
cb = d->data;
if ((cb->name) && (box_name))
{
if (!strcmp (cb->name, box_name))
{
inst = i->data;
if (inst->ci != ci) continue;
for (d = ci->boxes; d; d = d->next)
{
cb = d->data;
if ((cb->name) && (box_name))
{
if (!strcmp (cb->name, box_name))
{
found = 1;
break;
}
}
}
if (found)
{
switch (cb->type)
{
case MAIL_TYPE_IMAP:
}
}
}
if (found)
{
switch (cb->type)
{
case MAIL_TYPE_IMAP:
_mail_imap_del_mailbox (cb);
break;
case MAIL_TYPE_POP:
case MAIL_TYPE_POP:
_mail_pop_del_mailbox (cb);
break;
case MAIL_TYPE_MDIR:
case MAIL_TYPE_MDIR:
_mail_mdir_del_mailbox (cb);
break;
case MAIL_TYPE_MBOX:
case MAIL_TYPE_MBOX:
_mail_mbox_del_mailbox (cb);
break;
}
ci->boxes = evas_list_remove (ci->boxes, cb);
e_config_save_queue ();
break;
}
break;
}
}
ci->boxes = evas_list_remove (ci->boxes, cb);
e_config_save_queue ();
break;
}
}
}
void
_mail_config_updated (const char *id)
_mail_config_updated (Config_Item *ci)
{
Evas_List *l;
Config_Item *ci;
if (!mail_config)
return;
ci = _mail_config_item_get (id);
for (l = mail_config->instances; l; l = l->next)
{
Instance *inst;
inst = l->data;
if (!inst->gcc->id)
continue;
if (!strcmp (inst->gcc->id, ci->id))
if (inst->ci != ci) continue;
if (inst->check_timer)
{
if (inst->check_timer)
{
ecore_timer_del (inst->check_timer);
inst->check_timer =
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
inst);
}
if (ci->show_label)
edje_object_signal_emit (inst->mail_obj, "label_active", "");
else
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
break;
ecore_timer_del (inst->check_timer);
inst->check_timer =
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
inst);
}
if (ci->show_label)
edje_object_signal_emit (inst->mail_obj, "label_active", "");
else
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
break;
}
}

@ -28,6 +28,7 @@ struct _Instance
Ecore_Exe *exe;
Ecore_Timer *check_timer;
int count;
Config_Item *ci;
E_Gadcon_Popup *popup;
};
@ -90,10 +91,10 @@ EAPI int e_modapi_save(E_Module *m);
EAPI int e_modapi_about(E_Module *m);
void _config_mail_module(Config_Item *ci);
void _mail_config_updated(const char *id);
void _mail_config_updated(Config_Item *ci);
void _mail_box_config_updated(E_Config_Dialog *cfd);
void _mail_box_deleted(const char *ci_name, const char *box_name);
void _mail_box_added(const char *ci_name, const char *box_name);
void _mail_box_deleted(Config_Item *ci, const char *box_name);
void _mail_box_added(Config_Item *ci, const char *box_name);
void _mail_set_text(void *data);
void _mail_start_exe(void *data);

@ -5,6 +5,12 @@
#include "e_mod_main.h"
#include "imap2.h"
#if 0
#define D(args...) printf(##args)
#else
#define D(args...)
#endif
/*
* TODO:
* * Let the user select between Unseen, Recent and New mail
@ -38,6 +44,7 @@ _mail_imap_check_mail (void *data)
ic = l->data;
ic->data = data;
D ("Checking (%s:%s): %p\n", ic->config->host, ic->config->new_path, ic->server);
if (!ic->server)
{
if (!ic->add_handler)
@ -233,6 +240,8 @@ _mail_imap_server_data (void *data, int type, void *event)
if (ic->state == IMAP_STATE_DISCONNECTED)
return 1;
D ("Data from %s:%s\n", ic->config->host, ic->config->new_path);
/* Hijack server data.
* We require minimum 2 characters, as the minimum server data is '\r\n' */
if ((ic->prev.data) || (ev->size < 2))
@ -258,6 +267,7 @@ _mail_imap_server_data (void *data, int type, void *event)
/* Check for correct EOD */
if ((*(reply + size - 2) != '\r') && (*(reply + size - 1) != '\n'))
{
D ("Wrong eod %s:%s\n", ic->config->host, ic->config->new_path);
/* We got incomplete data, search for last EOD */
unsigned int pos = 0;
char *data;
@ -342,7 +352,7 @@ _mail_imap_server_data (void *data, int type, void *event)
case IMAP_STATE_IDLING:
if ((ic->idle == 1) && (!ic->idling))
{
printf ("Begin idle\n");
D ("Begin idle\n");
len = snprintf (out, sizeof (out), "A%04i IDLE\r\n", ic->cmd++);
ecore_con_server_send (ic->server, out, len);
ic->idling = 1;
@ -370,6 +380,7 @@ _mail_imap_server_data (void *data, int type, void *event)
if (ic->cmd > 9999)
ic->cmd = 1;
_mail_set_text (ic->data);
D ("\n");
return 0;
}
@ -408,7 +419,7 @@ _mail_imap_server_data_parse (ImapClient *ic, char *line)
}
else if (!strcmp (result, "OK"))
{
printf ("Reply ok: %s\n", value);
D ("Reply ok: %s\n", value);
}
else
{
@ -446,7 +457,7 @@ _mail_imap_server_data_parse (ImapClient *ic, char *line)
if (pp) *pp = '\0';
if (!strcmp (p, "IDLE"))
{
printf ("Server supports idle\n");
D ("Server supports idle\n");
ic->idle = 1;
}
if (pp)
@ -461,16 +472,16 @@ _mail_imap_server_data_parse (ImapClient *ic, char *line)
}
else if (!strcmp (result, "OK"))
{
printf ("Result OK: %s\n", value);
D ("Result OK: %s\n", value);
}
else if (!strcmp (result, "FLAGS"))
{
printf ("Flags: %s\n", value);
D ("Flags: %s\n", value);
}
else if (!strcmp (result, "SEARCH"))
{
ic->config->num_new = elements (value);
printf ("New mail (%s:%s): %d\n", ic->config->host, ic->config->new_path, ic->config->num_new);
D ("New mail (%s:%s): %d\n", ic->config->host, ic->config->new_path, ic->config->num_new);
}
else
{
@ -481,26 +492,26 @@ _mail_imap_server_data_parse (ImapClient *ic, char *line)
if (p) *p = '\0';
if (!strcmp (value, "RECENT"))
{
printf ("Recent mails: %d\n", atoi (result));
D ("Recent mails: %d\n", atoi (result));
//ic->state = IMAP_STATE_SEARCH_UNSEEN;
//ic->state = IMAP_STATE_SEARCH_RECENT;
ic->state = IMAP_STATE_SEARCH_NEW;
}
else if (!strcmp (value, "EXISTS"))
{
printf ("Existing mails: %d\n", atoi (result));
D ("Existing mails: %d\n", atoi (result));
ic->config->num_total = atoi (result);
}
else if (!strcmp (value, "FETCH"))
{
printf ("Reading mail: %d\n", atoi (result));
D ("Reading mail: %d\n", atoi (result));
//ic->state = IMAP_STATE_SEARCH_UNSEEN;
//ic->state = IMAP_STATE_SEARCH_RECENT;
ic->state = IMAP_STATE_SEARCH_NEW;
}
else if (!strcmp (value, "EXPUNGE"))
{
printf ("Deleting mail: %d\n", atoi (result));
D ("Deleting mail: %d\n", atoi (result));
//ic->state = IMAP_STATE_SEARCH_UNSEEN;
//ic->state = IMAP_STATE_SEARCH_RECENT;
ic->state = IMAP_STATE_SEARCH_NEW;

Loading…
Cancel
Save