parent
961e23fb01
commit
0e4e640217
|
@ -15,8 +15,10 @@ struct _E_Config_Dialog_Data
|
|||
|
||||
static void *_create_data (E_Config_Dialog * cfd);
|
||||
static void _free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata);
|
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
|
||||
E_Config_Dialog_Data * cfdata);
|
||||
static int _basic_apply_data (E_Config_Dialog * cfd,
|
||||
E_Config_Dialog_Data * cfdata);
|
||||
|
||||
static void _load_boxes (E_Config_Dialog * cfd);
|
||||
static int _ilist_header_exists (Evas_Object * il, const char *name);
|
||||
|
@ -34,14 +36,16 @@ _config_mail_module(Config_Item *ci)
|
|||
char buf[4096];
|
||||
|
||||
v = E_NEW (E_Config_Dialog_View, 1);
|
||||
if (!v) return;
|
||||
if (!v)
|
||||
return;
|
||||
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.apply_cfdata = _basic_apply_data;
|
||||
v->basic.create_widgets = _basic_create_widgets;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mail_config->module));
|
||||
snprintf (buf, sizeof (buf), "%s/module.eap",
|
||||
e_module_dir_get (mail_config->module));
|
||||
con = e_container_current_get (e_manager_current_get ());
|
||||
cfd = e_config_dialog_new (con, _("Mail Configuration"), buf, 0, v, ci);
|
||||
mail_config->config_dialog = cfd;
|
||||
|
@ -70,24 +74,29 @@ _create_data(E_Config_Dialog *cfd)
|
|||
static void
|
||||
_free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
if (!mail_config) return;
|
||||
if (!mail_config)
|
||||
return;
|
||||
mail_config->config_dialog = NULL;
|
||||
free (cfdata);
|
||||
cfdata = NULL;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
|
||||
E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ob, *ot;
|
||||
|
||||
o = e_widget_list_add (evas, 0, 0);
|
||||
of = e_widget_framelist_add (evas, _("General Settings"), 0);
|
||||
ob = e_widget_check_add(evas, _("Always Show Labels"), &(cfdata->show_label));
|
||||
ob =
|
||||
e_widget_check_add (evas, _("Always Show Labels"), &(cfdata->show_label));
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
ob = e_widget_label_add (evas, _("Check Interval"));
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%2.0f minutes"), 1.0, 60.0, 1.0, 0, &(cfdata->check_time), NULL, 100);
|
||||
ob =
|
||||
e_widget_slider_add (evas, 1, 0, _("%2.0f minutes"), 1.0, 60.0, 1.0, 0,
|
||||
&(cfdata->check_time), NULL, 100);
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
|
@ -100,13 +109,19 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
e_widget_frametable_object_append (of, ob, 0, 0, 1, 4, 1, 1, 1, 1);
|
||||
|
||||
ot = e_widget_table_add (evas, 0);
|
||||
ob = e_widget_button_add(evas, _("Add"), "widget/add", _cb_add_box, cfd, NULL);
|
||||
ob =
|
||||
e_widget_button_add (evas, _("Add"), "widget/add", _cb_add_box, cfd,
|
||||
NULL);
|
||||
e_widget_table_object_append (ot, ob, 0, 0, 1, 1, 1, 1, 1, 0);
|
||||
ob = e_widget_button_add(evas, _("Delete"), "widget/del", _cb_del_box, cfd, NULL);
|
||||
ob =
|
||||
e_widget_button_add (evas, _("Delete"), "widget/del", _cb_del_box, cfd,
|
||||
NULL);
|
||||
e_widget_disabled_set (ob, 1);
|
||||
cfdata->del = ob;
|
||||
e_widget_table_object_append (ot, ob, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||
ob = e_widget_button_add(evas, _("Configure..."), "widget/config", _cb_edit_box, cfd, NULL);
|
||||
ob =
|
||||
e_widget_button_add (evas, _("Configure..."), "widget/config",
|
||||
_cb_edit_box, cfd, NULL);
|
||||
e_widget_disabled_set (ob, 1);
|
||||
cfdata->configure = ob;
|
||||
e_widget_table_object_append (ot, ob, 0, 2, 1, 1, 1, 1, 1, 0);
|
||||
|
@ -141,14 +156,19 @@ _load_boxes(E_Config_Dialog *cfd)
|
|||
|
||||
cfdata = cfd->cfdata;
|
||||
il = cfdata->il;
|
||||
if (!il) return;
|
||||
if (!il)
|
||||
return;
|
||||
|
||||
ci = cfd->data;
|
||||
if (!ci) return;
|
||||
if (!ci->boxes) return;
|
||||
if (evas_list_count(ci->boxes) <= 0) return;
|
||||
if (!ci)
|
||||
return;
|
||||
if (!ci->boxes)
|
||||
return;
|
||||
if (evas_list_count (ci->boxes) <= 0)
|
||||
return;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mail_config->module));
|
||||
snprintf (buf, sizeof (buf), "%s/module.eap",
|
||||
e_module_dir_get (mail_config->module));
|
||||
|
||||
e_widget_ilist_clear (il);
|
||||
|
||||
|
@ -183,11 +203,14 @@ _load_boxes(E_Config_Dialog *cfd)
|
|||
Evas_Object *ic;
|
||||
|
||||
cb = box->data;
|
||||
if (cb->type != i) continue;
|
||||
if (!cb->name) continue;
|
||||
if (cb->type != i)
|
||||
continue;
|
||||
if (!cb->name)
|
||||
continue;
|
||||
ic = edje_object_add (cfd->dia->win->evas);
|
||||
edje_object_file_set (ic, buf, "icon");
|
||||
e_widget_ilist_append(il, ic, cb->name, _ilist_cb_selected, cfd, NULL);
|
||||
e_widget_ilist_append (il, ic, cb->name, _ilist_cb_selected, cfd,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
e_widget_ilist_go (il);
|
||||
|
@ -198,24 +221,28 @@ _ilist_header_exists(Evas_Object *il, const char *name)
|
|||
{
|
||||
int c, i, found = 0;
|
||||
|
||||
if (!il) return -1;
|
||||
if (!il)
|
||||
return -1;
|
||||
|
||||
c = e_widget_ilist_count (il);
|
||||
if (c <= 0) return -1;
|
||||
if (c <= 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
const char *n;
|
||||
|
||||
n = e_widget_ilist_nth_label_get (il, i);
|
||||
if (!n) continue;
|
||||
if (!n)
|
||||
continue;
|
||||
if (!strcmp (n, name))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) return i;
|
||||
if (found)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -240,7 +267,8 @@ _cb_add_box(void *data, void *data2)
|
|||
Config_Item *ci;
|
||||
|
||||
cfd = data;
|
||||
if (!cfd) return;
|
||||
if (!cfd)
|
||||
return;
|
||||
|
||||
ci = cfd->data;
|
||||
cfdata = cfd->cfdata;
|
||||
|
@ -259,21 +287,24 @@ _cb_edit_box(void *data, void *data2)
|
|||
const char *s;
|
||||
|
||||
cfd = data;
|
||||
if (!cfd) return;
|
||||
if (!cfd)
|
||||
return;
|
||||
|
||||
ci = cfd->data;
|
||||
cfdata = cfd->cfdata;
|
||||
il = cfdata->il;
|
||||
s = e_widget_ilist_selected_label_get (il);
|
||||
|
||||
if (!s) return;
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
for (l = ci->boxes; l; l = l->next)
|
||||
{
|
||||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb->name) continue;
|
||||
if (!cb->name)
|
||||
continue;
|
||||
if (!strcmp (s, cb->name))
|
||||
{
|
||||
_config_box (ci, cb, cfd);
|
||||
|
@ -293,7 +324,8 @@ _cb_del_box(void *data, void *data2)
|
|||
const char *s;
|
||||
|
||||
cfd = data;
|
||||
if (!cfd) return;
|
||||
if (!cfd)
|
||||
return;
|
||||
|
||||
ci = cfd->data;
|
||||
cfdata = cfd->cfdata;
|
||||
|
@ -305,7 +337,8 @@ _cb_del_box(void *data, void *data2)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb->name) continue;
|
||||
if (!cb->name)
|
||||
continue;
|
||||
if (!strcmp (s, cb->name))
|
||||
{
|
||||
_mail_box_deleted (ci->id, cb->name);
|
||||
|
|
|
@ -27,8 +27,10 @@ struct _E_Config_Dialog_Data
|
|||
|
||||
static void *_create_data (E_Config_Dialog * cfd);
|
||||
static void _free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata);
|
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
|
||||
E_Config_Dialog_Data * cfdata);
|
||||
static int _basic_apply_data (E_Config_Dialog * cfd,
|
||||
E_Config_Dialog_Data * cfdata);
|
||||
static void _type_cb_change (void *data, Evas_Object * obj);
|
||||
static void _use_exec_cb_change (void *data, Evas_Object * obj);
|
||||
|
||||
|
@ -43,7 +45,8 @@ _config_box(Config_Item *ci, Config_Box *cb, E_Config_Dialog *mcfd)
|
|||
E_Container *con;
|
||||
|
||||
v = E_NEW (E_Config_Dialog_View, 1);
|
||||
if (!v) return;
|
||||
if (!v)
|
||||
return;
|
||||
|
||||
prev_dlg = mcfd;
|
||||
mail_ci = ci;
|
||||
|
@ -125,21 +128,26 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
|
||||
E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ob, *ot;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
o = e_widget_list_add (evas, 0, 0);
|
||||
of = e_widget_framelist_add (evas, _("General Settings"), 0);
|
||||
ob = e_widget_check_add(evas, _("Start Program When New Mail Arrives"), &(cfdata->use_exec));
|
||||
ob =
|
||||
e_widget_check_add (evas, _("Start Program When New Mail Arrives"),
|
||||
&(cfdata->use_exec));
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
e_widget_on_change_hook_set (ob, _use_exec_cb_change, cfdata);
|
||||
ot = e_widget_table_add (evas, 1);
|
||||
cfdata->exec_label = e_widget_label_add (evas, _("Program:"));
|
||||
e_widget_table_object_append(ot, cfdata->exec_label, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_table_object_append (ot, cfdata->exec_label, 0, 0, 1, 1, 0, 0, 1,
|
||||
0);
|
||||
cfdata->exec_entry = e_widget_entry_add (evas, &cfdata->exec);
|
||||
e_widget_table_object_append(ot, cfdata->exec_entry, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_table_object_append (ot, cfdata->exec_entry, 1, 0, 1, 1, 0, 0, 1,
|
||||
0);
|
||||
e_widget_framelist_object_append (of, ot);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
|
@ -199,9 +207,11 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
e_widget_frametable_object_append (of, ob, 1, 3, 1, 1, 0, 0, 1, 0);
|
||||
|
||||
cfdata->new_path_label = e_widget_label_add (evas, _("New Mail Path:"));
|
||||
e_widget_frametable_object_append(of, cfdata->new_path_label, 0, 4, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_frametable_object_append (of, cfdata->new_path_label, 0, 4, 1, 1,
|
||||
0, 0, 1, 0);
|
||||
cfdata->new_path_entry = e_widget_entry_add (evas, &cfdata->new_path);
|
||||
e_widget_frametable_object_append(of, cfdata->new_path_entry, 1, 4, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_frametable_object_append (of, cfdata->new_path_entry, 1, 4, 1, 1,
|
||||
0, 0, 1, 0);
|
||||
if (cfdata->type == 0)
|
||||
{
|
||||
e_widget_disabled_set (cfdata->new_path_label, 1);
|
||||
|
@ -209,9 +219,11 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
}
|
||||
|
||||
cfdata->cur_path_label = e_widget_label_add (evas, _("Current Mail Path:"));
|
||||
e_widget_frametable_object_append(of, cfdata->cur_path_label, 0, 5, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_frametable_object_append (of, cfdata->cur_path_label, 0, 5, 1, 1,
|
||||
0, 0, 1, 0);
|
||||
cfdata->cur_path_entry = e_widget_entry_add (evas, &cfdata->cur_path);
|
||||
e_widget_frametable_object_append(of, cfdata->cur_path_entry, 1, 5, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_frametable_object_append (of, cfdata->cur_path_entry, 1, 5, 1, 1,
|
||||
0, 0, 1, 0);
|
||||
if ((cfdata->type == 1) || (cfdata->type == 3))
|
||||
{
|
||||
e_widget_disabled_set (cfdata->cur_path_label, 1);
|
||||
|
@ -241,7 +253,8 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
is_new = 1;
|
||||
}
|
||||
|
||||
if (cb->name) evas_stringshare_del(cb->name);
|
||||
if (cb->name)
|
||||
evas_stringshare_del (cb->name);
|
||||
if (cfdata->name != NULL)
|
||||
cb->name = evas_stringshare_add (cfdata->name);
|
||||
else
|
||||
|
@ -251,37 +264,43 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
cb->port = atoi (cfdata->port);
|
||||
cb->ssl = cfdata->ssl;
|
||||
cb->use_exec = cfdata->use_exec;
|
||||
if (cb->exec) evas_stringshare_del(cb->exec);
|
||||
if (cb->exec)
|
||||
evas_stringshare_del (cb->exec);
|
||||
if (cfdata->exec != NULL)
|
||||
cb->exec = evas_stringshare_add (cfdata->exec);
|
||||
else
|
||||
cb->exec = evas_stringshare_add ("");
|
||||
|
||||
if (cb->host) evas_stringshare_del(cb->host);
|
||||
if (cb->host)
|
||||
evas_stringshare_del (cb->host);
|
||||
if (cfdata->host != NULL)
|
||||
cb->host = evas_stringshare_add (cfdata->host);
|
||||
else
|
||||
cb->host = evas_stringshare_add ("");
|
||||
|
||||
if (cb->user) evas_stringshare_del(cb->user);
|
||||
if (cb->user)
|
||||
evas_stringshare_del (cb->user);
|
||||
if (cfdata->user != NULL)
|
||||
cb->user = evas_stringshare_add (cfdata->user);
|
||||
else
|
||||
cb->user = evas_stringshare_add ("");
|
||||
|
||||
if (cb->pass) evas_stringshare_del(cb->pass);
|
||||
if (cb->pass)
|
||||
evas_stringshare_del (cb->pass);
|
||||
if (cfdata->pass != NULL)
|
||||
cb->pass = evas_stringshare_add (cfdata->pass);
|
||||
else
|
||||
cb->pass = evas_stringshare_add ("");
|
||||
|
||||
if (cb->new_path) evas_stringshare_del(cb->new_path);
|
||||
if (cb->new_path)
|
||||
evas_stringshare_del (cb->new_path);
|
||||
if (cfdata->new_path != NULL)
|
||||
cb->new_path = evas_stringshare_add (cfdata->new_path);
|
||||
else
|
||||
cb->new_path = evas_stringshare_add ("");
|
||||
|
||||
if (cb->cur_path) evas_stringshare_del(cb->cur_path);
|
||||
if (cb->cur_path)
|
||||
evas_stringshare_del (cb->cur_path);
|
||||
if (cfdata->cur_path != NULL)
|
||||
cb->cur_path = evas_stringshare_add (cfdata->cur_path);
|
||||
else
|
||||
|
|
193
e_mod_main.c
193
e_mod_main.c
|
@ -25,17 +25,22 @@
|
|||
#include "mbox.h"
|
||||
|
||||
/* Func Protos for Gadcon */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
static E_Gadcon_Client *_gc_init (E_Gadcon * gc, const char *name,
|
||||
const char *id, const char *style);
|
||||
static void _gc_shutdown (E_Gadcon_Client * gcc);
|
||||
static void _gc_orient (E_Gadcon_Client * gcc);
|
||||
static char *_gc_label (void);
|
||||
static Evas_Object *_gc_icon (Evas * evas);
|
||||
|
||||
/* Func Protos for Module */
|
||||
static void _mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _mail_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _mail_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _mail_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _mail_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
|
||||
void *event_info);
|
||||
static void _mail_cb_mouse_in (void *data, Evas * e, Evas_Object * obj,
|
||||
void *event_info);
|
||||
static void _mail_cb_mouse_out (void *data, Evas * e, Evas_Object * obj,
|
||||
void *event_info);
|
||||
static void _mail_menu_cb_configure (void *data, E_Menu * m,
|
||||
E_Menu_Item * mi);
|
||||
static void _mail_menu_cb_post (void *data, E_Menu * m);
|
||||
static void _mail_menu_cb_exec (void *data, E_Menu * m, E_Menu_Item * mi);
|
||||
static Config_Item *_mail_config_item_get (const char *id);
|
||||
|
@ -52,8 +57,7 @@ Config *mail_config = NULL;
|
|||
|
||||
static Ecore_Event_Handler *exit_handler;
|
||||
|
||||
static const E_Gadcon_Client_Class _gc_class =
|
||||
{
|
||||
static const E_Gadcon_Client_Class _gc_class = {
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"mail", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon}
|
||||
};
|
||||
|
@ -70,7 +74,8 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
|
||||
inst = E_NEW (Instance, 1);
|
||||
ci = _mail_config_item_get (id);
|
||||
if (!ci->id) ci->id = evas_stringshare_add(id);
|
||||
if (!ci->id)
|
||||
ci->id = evas_stringshare_add (id);
|
||||
|
||||
mail = _mail_new (gc->evas);
|
||||
mail->inst = inst;
|
||||
|
@ -81,9 +86,12 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst->gcc = gcc;
|
||||
inst->mail_obj = mail->mail_obj;
|
||||
|
||||
evas_object_event_callback_add(inst->mail_obj, EVAS_CALLBACK_MOUSE_DOWN, _mail_cb_mouse_down, inst);
|
||||
evas_object_event_callback_add(inst->mail_obj, EVAS_CALLBACK_MOUSE_IN, _mail_cb_mouse_in, inst);
|
||||
evas_object_event_callback_add(inst->mail_obj, EVAS_CALLBACK_MOUSE_OUT, _mail_cb_mouse_out, inst);
|
||||
evas_object_event_callback_add (inst->mail_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_mail_cb_mouse_down, inst);
|
||||
evas_object_event_callback_add (inst->mail_obj, EVAS_CALLBACK_MOUSE_IN,
|
||||
_mail_cb_mouse_in, inst);
|
||||
evas_object_event_callback_add (inst->mail_obj, EVAS_CALLBACK_MOUSE_OUT,
|
||||
_mail_cb_mouse_out, inst);
|
||||
|
||||
if (ci->show_label)
|
||||
edje_object_signal_emit (inst->mail_obj, "label_active", "");
|
||||
|
@ -107,13 +115,17 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
have_imap = 1;
|
||||
_mail_imap_add_mailbox (cb);
|
||||
if (!inst->check_timer)
|
||||
inst->check_timer = ecore_timer_add((ci->check_time * 60.0), _mail_cb_check, inst);
|
||||
inst->check_timer =
|
||||
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
|
||||
inst);
|
||||
break;
|
||||
case MAIL_TYPE_POP:
|
||||
have_pop = 1;
|
||||
_mail_pop_add_mailbox (cb);
|
||||
if (!inst->check_timer)
|
||||
inst->check_timer = ecore_timer_add((ci->check_time * 60.0), _mail_cb_check, inst);
|
||||
inst->check_timer =
|
||||
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
|
||||
inst);
|
||||
break;
|
||||
case MAIL_TYPE_MDIR:
|
||||
_mail_mdir_add_mailbox (inst, cb);
|
||||
|
@ -123,8 +135,10 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (have_pop) _mail_pop_check_mail(inst);
|
||||
if (have_imap) _mail_imap_check_mail(inst);
|
||||
if (have_pop)
|
||||
_mail_pop_check_mail (inst);
|
||||
if (have_imap)
|
||||
_mail_imap_check_mail (inst);
|
||||
}
|
||||
return gcc;
|
||||
}
|
||||
|
@ -136,9 +150,12 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
|||
|
||||
inst = gcc->data;
|
||||
|
||||
evas_object_event_callback_del(inst->mail_obj, EVAS_CALLBACK_MOUSE_DOWN, _mail_cb_mouse_down);
|
||||
evas_object_event_callback_del(inst->mail_obj, EVAS_CALLBACK_MOUSE_IN, _mail_cb_mouse_in);
|
||||
evas_object_event_callback_del(inst->mail_obj, EVAS_CALLBACK_MOUSE_OUT, _mail_cb_mouse_out);
|
||||
evas_object_event_callback_del (inst->mail_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_mail_cb_mouse_down);
|
||||
evas_object_event_callback_del (inst->mail_obj, EVAS_CALLBACK_MOUSE_IN,
|
||||
_mail_cb_mouse_in);
|
||||
evas_object_event_callback_del (inst->mail_obj, EVAS_CALLBACK_MOUSE_OUT,
|
||||
_mail_cb_mouse_out);
|
||||
|
||||
mail_config->instances = evas_list_remove (mail_config->instances, inst);
|
||||
_mail_free (inst->mail);
|
||||
|
@ -166,20 +183,23 @@ _gc_icon(Evas *evas)
|
|||
char buf[4096];
|
||||
|
||||
o = edje_object_add (evas);
|
||||
snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mail_config->module));
|
||||
snprintf (buf, sizeof (buf), "%s/module.eap",
|
||||
e_module_dir_get (mail_config->module));
|
||||
edje_object_file_set (o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
_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;
|
||||
|
||||
if (!inst) return;
|
||||
if (!inst)
|
||||
return;
|
||||
if ((ev->button == 3) && (!mail_config->menu))
|
||||
{
|
||||
E_Menu *mn, *sn;
|
||||
|
@ -196,7 +216,8 @@ _mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
{
|
||||
E_Menu_Item *mm;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mail_config->module));
|
||||
snprintf (buf, sizeof (buf), "%s/module.eap",
|
||||
e_module_dir_get (mail_config->module));
|
||||
mm = e_menu_item_new (mn);
|
||||
e_menu_item_label_set (mm, _("Mailboxes"));
|
||||
e_menu_item_icon_edje_set (mm, buf, "icon");
|
||||
|
@ -207,9 +228,11 @@ _mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb) continue;
|
||||
if (!cb)
|
||||
continue;
|
||||
mi = e_menu_item_new (sn);
|
||||
snprintf(buf, sizeof(buf), "%s: %d/%d", cb->name, cb->num_new, cb->num_total);
|
||||
snprintf (buf, sizeof (buf), "%s: %d/%d", cb->name, cb->num_new,
|
||||
cb->num_total);
|
||||
e_menu_item_label_set (mi, buf);
|
||||
if ((cb->exec) && (cb->use_exec))
|
||||
e_menu_item_callback_set (mi, _mail_menu_cb_exec, cb);
|
||||
|
@ -230,10 +253,12 @@ _mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
e_gadcon_client_util_menu_items_append (inst->gcc, mn, 0);
|
||||
e_gadcon_canvas_zone_geometry_get (inst->gcc->gadcon, &x, &y, &w, &h);
|
||||
e_menu_activate_mouse (mn,
|
||||
e_util_zone_current_get(e_manager_current_get()),
|
||||
x + ev->output.x, y + ev->output.y, 1, 1, E_MENU_POP_DIRECTION_DOWN,
|
||||
ev->timestamp);
|
||||
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
||||
e_util_zone_current_get (e_manager_current_get
|
||||
()), x + ev->output.x,
|
||||
y + ev->output.y, 1, 1,
|
||||
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
||||
evas_event_feed_mouse_up (inst->gcc->gadcon->evas, ev->button,
|
||||
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
||||
}
|
||||
else if (ev->button == 1)
|
||||
_mail_cb_check (inst);
|
||||
|
@ -244,7 +269,8 @@ _mail_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (!inst) return;
|
||||
if (!inst)
|
||||
return;
|
||||
edje_object_signal_emit (inst->mail_obj, "label_active", "");
|
||||
}
|
||||
|
||||
|
@ -254,7 +280,8 @@ _mail_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
Instance *inst = data;
|
||||
Config_Item *ci;
|
||||
|
||||
if (!inst) return;
|
||||
if (!inst)
|
||||
return;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if (!ci->show_label)
|
||||
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
|
||||
|
@ -263,7 +290,8 @@ _mail_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
static void
|
||||
_mail_menu_cb_post (void *data, E_Menu * m)
|
||||
{
|
||||
if (!mail_config->menu) return;
|
||||
if (!mail_config->menu)
|
||||
return;
|
||||
e_object_del (E_OBJECT (mail_config->menu));
|
||||
mail_config->menu = NULL;
|
||||
}
|
||||
|
@ -274,7 +302,8 @@ _mail_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
Instance *inst = data;
|
||||
Config_Item *ci;
|
||||
|
||||
if (!inst) return;
|
||||
if (!inst)
|
||||
return;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
_config_mail_module (ci);
|
||||
}
|
||||
|
@ -288,8 +317,10 @@ _mail_config_item_get(const char *id)
|
|||
for (l = mail_config->items; l; l = l->next)
|
||||
{
|
||||
ci = l->data;
|
||||
if (!ci->id) continue;
|
||||
if (!strcmp(ci->id, id)) return ci;
|
||||
if (!ci->id)
|
||||
continue;
|
||||
if (!strcmp (ci->id, id))
|
||||
return ci;
|
||||
}
|
||||
|
||||
ci = E_NEW (Config_Item, 1);
|
||||
|
@ -302,8 +333,7 @@ _mail_config_item_get(const char *id)
|
|||
return ci;
|
||||
}
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
EAPI E_Module_Api e_modapi = {
|
||||
E_MODULE_API_VERSION,
|
||||
"Mail"
|
||||
};
|
||||
|
@ -407,19 +437,28 @@ e_modapi_shutdown(E_Module *m)
|
|||
_mail_mbox_del_mailbox (cb);
|
||||
break;
|
||||
}
|
||||
if (cb->name) evas_stringshare_del(cb->name);
|
||||
if (cb->host) evas_stringshare_del(cb->host);
|
||||
if (cb->user) evas_stringshare_del(cb->user);
|
||||
if (cb->pass) evas_stringshare_del(cb->pass);
|
||||
if (cb->new_path) evas_stringshare_del(cb->new_path);
|
||||
if (cb->cur_path) evas_stringshare_del(cb->cur_path);
|
||||
if (cb->exec) evas_stringshare_del(cb->exec);
|
||||
if (cb->name)
|
||||
evas_stringshare_del (cb->name);
|
||||
if (cb->host)
|
||||
evas_stringshare_del (cb->host);
|
||||
if (cb->user)
|
||||
evas_stringshare_del (cb->user);
|
||||
if (cb->pass)
|
||||
evas_stringshare_del (cb->pass);
|
||||
if (cb->new_path)
|
||||
evas_stringshare_del (cb->new_path);
|
||||
if (cb->cur_path)
|
||||
evas_stringshare_del (cb->cur_path);
|
||||
if (cb->exec)
|
||||
evas_stringshare_del (cb->exec);
|
||||
ci->boxes = evas_list_remove_list (ci->boxes, ci->boxes);
|
||||
free (cb);
|
||||
cb = NULL;
|
||||
}
|
||||
if (ci->id) evas_stringshare_del(ci->id);
|
||||
mail_config->items = evas_list_remove_list(mail_config->items, mail_config->items);
|
||||
if (ci->id)
|
||||
evas_stringshare_del (ci->id);
|
||||
mail_config->items =
|
||||
evas_list_remove_list (mail_config->items, mail_config->items);
|
||||
free (ci);
|
||||
ci = NULL;
|
||||
}
|
||||
|
@ -447,7 +486,8 @@ e_modapi_save(E_Module *m)
|
|||
|
||||
inst = l->data;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if (ci->id) evas_stringshare_del(ci->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);
|
||||
|
@ -458,7 +498,8 @@ EAPI int
|
|||
e_modapi_about (E_Module * m)
|
||||
{
|
||||
e_module_dialog_show (m, D_ ("Enlightenment Mail Module"),
|
||||
D_("This is a module to notify when you have new mail."));
|
||||
D_
|
||||
("This is a module to notify when you have new mail."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -471,8 +512,10 @@ _mail_new(Evas *evas)
|
|||
mail = E_NEW (Mail, 1);
|
||||
mail->mail_obj = edje_object_add (evas);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/mail.edj", e_module_dir_get(mail_config->module));
|
||||
if (!e_theme_edje_object_set(mail->mail_obj, "base/theme/modules/mail", "modules/mail/main"))
|
||||
snprintf (buf, sizeof (buf), "%s/mail.edj",
|
||||
e_module_dir_get (mail_config->module));
|
||||
if (!e_theme_edje_object_set
|
||||
(mail->mail_obj, "base/theme/modules/mail", "modules/mail/main"))
|
||||
edje_object_file_set (mail->mail_obj, buf, "modules/mail/main");
|
||||
evas_object_show (mail->mail_obj);
|
||||
|
||||
|
@ -495,10 +538,12 @@ _mail_cb_check(void *data)
|
|||
Evas_List *l;
|
||||
int have_imap = 0, have_pop = 0;
|
||||
|
||||
if (!inst) return 1;
|
||||
if (!inst)
|
||||
return 1;
|
||||
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if (!ci->boxes) return 1;
|
||||
if (!ci->boxes)
|
||||
return 1;
|
||||
|
||||
edje_object_signal_emit (inst->mail->mail_obj, "check_mail", "");
|
||||
|
||||
|
@ -507,7 +552,8 @@ _mail_cb_check(void *data)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb) continue;
|
||||
if (!cb)
|
||||
continue;
|
||||
switch (cb->type)
|
||||
{
|
||||
case MAIL_TYPE_MDIR:
|
||||
|
@ -522,8 +568,10 @@ _mail_cb_check(void *data)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (have_imap) _mail_imap_check_mail(inst);
|
||||
if (have_pop) _mail_pop_check_mail(inst);
|
||||
if (have_imap)
|
||||
_mail_imap_check_mail (inst);
|
||||
if (have_pop)
|
||||
_mail_pop_check_mail (inst);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -536,16 +584,19 @@ _mail_set_text(void *data)
|
|||
char buf[1024];
|
||||
int count = 0;
|
||||
|
||||
if (!inst) return;
|
||||
if (!inst)
|
||||
return;
|
||||
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if (!ci) return;
|
||||
if (!ci)
|
||||
return;
|
||||
for (l = ci->boxes; l; l = l->next)
|
||||
{
|
||||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb) continue;
|
||||
if (!cb)
|
||||
continue;
|
||||
count += cb->num_new;
|
||||
}
|
||||
|
||||
|
@ -568,9 +619,11 @@ _mail_start_exe(void *data)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, cb);
|
||||
exit_handler =
|
||||
ecore_event_handler_add (ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, cb);
|
||||
cb->exe = ecore_exe_run (cb->exec, cb);
|
||||
}
|
||||
|
||||
|
@ -580,7 +633,8 @@ _mail_cb_exe_exit(void *data, int type, void *event)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return 0;
|
||||
if (!cb)
|
||||
return 0;
|
||||
cb->exe = NULL;
|
||||
ecore_event_handler_del (exit_handler);
|
||||
return 0;
|
||||
|
@ -642,7 +696,8 @@ _mail_box_deleted(const char *ci_name, const char *box_name)
|
|||
Instance *inst;
|
||||
|
||||
inst = i->data;
|
||||
if (!inst->gcc->id) continue;
|
||||
if (!inst->gcc->id)
|
||||
continue;
|
||||
if (!strcmp (inst->gcc->id, ci_name))
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
@ -692,7 +747,8 @@ _mail_config_updated(const char *id)
|
|||
Evas_List *l;
|
||||
Config_Item *ci;
|
||||
|
||||
if (!mail_config) return;
|
||||
if (!mail_config)
|
||||
return;
|
||||
|
||||
ci = _mail_config_item_get (id);
|
||||
for (l = mail_config->instances; l; l = l->next)
|
||||
|
@ -700,13 +756,16 @@ _mail_config_updated(const char *id)
|
|||
Instance *inst;
|
||||
|
||||
inst = l->data;
|
||||
if (!inst->gcc->id) continue;
|
||||
if (!inst->gcc->id)
|
||||
continue;
|
||||
if (!strcmp (inst->gcc->id, ci->id))
|
||||
{
|
||||
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);
|
||||
inst->check_timer =
|
||||
ecore_timer_add ((ci->check_time * 60.0), _mail_cb_check,
|
||||
inst);
|
||||
}
|
||||
|
||||
if (ci->show_label)
|
||||
|
@ -724,8 +783,10 @@ _mail_menu_cb_exec(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, cb);
|
||||
exit_handler =
|
||||
ecore_event_handler_add (ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, cb);
|
||||
cb->exe = ecore_exe_run (cb->exec, cb);
|
||||
}
|
||||
|
|
66
imap.c
66
imap.c
|
@ -27,11 +27,17 @@ _mail_imap_check_mail(void *data)
|
|||
if (!is->server)
|
||||
{
|
||||
if (!is->add_handler)
|
||||
is->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _mail_imap_server_add, NULL);
|
||||
is->add_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
|
||||
_mail_imap_server_add, NULL);
|
||||
if (!is->del_handler)
|
||||
is->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _mail_imap_server_del, NULL);
|
||||
is->del_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
|
||||
_mail_imap_server_del, NULL);
|
||||
if (!is->data_handler)
|
||||
is->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _mail_imap_server_data, NULL);
|
||||
is->data_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
|
||||
_mail_imap_server_data, NULL);
|
||||
|
||||
for (j = is->clients; j; j = j->next)
|
||||
{
|
||||
|
@ -41,7 +47,9 @@ _mail_imap_check_mail(void *data)
|
|||
if (ecore_con_ssl_available_get () && (ic->config->ssl))
|
||||
type |= ECORE_CON_USE_SSL;
|
||||
ic->server->state = IMAP_STATE_DISCONNECTED;
|
||||
ic->server->server = ecore_con_server_connect(type, ic->config->host, ic->config->port, NULL);
|
||||
ic->server->server =
|
||||
ecore_con_server_connect (type, ic->config->host,
|
||||
ic->config->port, NULL);
|
||||
ic->server->cmd = 0;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +66,8 @@ _mail_imap_add_mailbox(void *data)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
ic = _mail_imap_client_get (cb);
|
||||
ic->server->clients = evas_list_append (ic->server->clients, ic);
|
||||
}
|
||||
|
@ -70,7 +79,8 @@ _mail_imap_del_mailbox(void *data)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
ic = _mail_imap_client_get (cb);
|
||||
ic->server->clients = evas_list_remove (ic->server->clients, ic);
|
||||
}
|
||||
|
@ -78,7 +88,8 @@ _mail_imap_del_mailbox(void *data)
|
|||
void
|
||||
_mail_imap_shutdown ()
|
||||
{
|
||||
if (!iservers) return;
|
||||
if (!iservers)
|
||||
return;
|
||||
while (iservers)
|
||||
{
|
||||
ImapServer *is;
|
||||
|
@ -123,7 +134,8 @@ _mail_imap_client_get(void *data)
|
|||
int found = 0;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return NULL;
|
||||
if (!cb)
|
||||
return NULL;
|
||||
|
||||
if ((!iservers) || (evas_list_count (iservers) <= 0))
|
||||
{
|
||||
|
@ -137,11 +149,13 @@ _mail_imap_client_get(void *data)
|
|||
for (l = iservers; l; l = l->next)
|
||||
{
|
||||
is = l->data;
|
||||
if (!is->clients) continue;
|
||||
if (!is->clients)
|
||||
continue;
|
||||
for (j = is->clients; j; j = j->next)
|
||||
{
|
||||
ic = j->data;
|
||||
if (!ic->config) continue;
|
||||
if (!ic->config)
|
||||
continue;
|
||||
if ((!strcmp (ic->config->host, cb->host)) &&
|
||||
(!strcmp (ic->config->user, cb->user)) &&
|
||||
(!strcmp (ic->config->pass, cb->pass)))
|
||||
|
@ -150,7 +164,8 @@ _mail_imap_client_get(void *data)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
|
@ -170,7 +185,8 @@ _mail_imap_server_add(void *data, int type, void *event)
|
|||
ImapServer *is;
|
||||
|
||||
is = _mail_imap_server_get (ev->server);
|
||||
if (!is) return 1;
|
||||
if (!is)
|
||||
return 1;
|
||||
|
||||
is->state = IMAP_STATE_CONNECTED;
|
||||
is->cmd = 0;
|
||||
|
@ -184,7 +200,8 @@ _mail_imap_server_del(void *data, int type, void *event)
|
|||
ImapServer *is;
|
||||
|
||||
is = _mail_imap_server_get (ev->server);
|
||||
if (!is) return 1;
|
||||
if (!is)
|
||||
return 1;
|
||||
|
||||
if (is->state == IMAP_STATE_DISCONNECTED)
|
||||
printf ("Imap Server Disconnected\n");
|
||||
|
@ -209,8 +226,10 @@ _mail_imap_server_data(void *data, int type, void *event)
|
|||
size_t slen;
|
||||
|
||||
is = _mail_imap_server_get (ev->server);
|
||||
if (!is) return 1;
|
||||
if (is->state == IMAP_STATE_DISCONNECTED) return 1;
|
||||
if (!is)
|
||||
return 1;
|
||||
if (is->state == IMAP_STATE_DISCONNECTED)
|
||||
return 1;
|
||||
|
||||
len = sizeof (in) - 1;
|
||||
len = (len > ev->size) ? (ev->size) : (len);
|
||||
|
@ -241,15 +260,20 @@ _mail_imap_server_data(void *data, int type, void *event)
|
|||
switch (is->state)
|
||||
{
|
||||
case IMAP_STATE_SERVER_READY:
|
||||
len = snprintf(out, sizeof(out), "A%03i LOGIN %s %s\r\n", ++is->cmd, ic->config->user, ic->config->pass);
|
||||
len =
|
||||
snprintf (out, sizeof (out), "A%03i LOGIN %s %s\r\n", ++is->cmd,
|
||||
ic->config->user, ic->config->pass);
|
||||
ecore_con_server_send (ev->server, out, len);
|
||||
break;
|
||||
case IMAP_STATE_LOGGED_IN:
|
||||
len = snprintf(out, sizeof(out), "A%03i STATUS %s (MESSAGES UNSEEN)\r\n", ++is->cmd, ic->config->new_path);
|
||||
len =
|
||||
snprintf (out, sizeof (out), "A%03i STATUS %s (MESSAGES UNSEEN)\r\n",
|
||||
++is->cmd, ic->config->new_path);
|
||||
ecore_con_server_send (ev->server, out, len);
|
||||
break;
|
||||
case IMAP_STATE_STATUS_OK:
|
||||
if (sscanf(in, "* STATUS %*s (MESSAGES %i UNSEEN %i)", &total, &num) == 2)
|
||||
if (sscanf (in, "* STATUS %*s (MESSAGES %i UNSEEN %i)", &total, &num) ==
|
||||
2)
|
||||
{
|
||||
ic->config->num_new = num;
|
||||
ic->config->num_total = total;
|
||||
|
@ -279,7 +303,8 @@ _mail_imap_server_data(void *data, int type, void *event)
|
|||
ic = NULL;
|
||||
}
|
||||
}
|
||||
if (!ic) break;
|
||||
if (!ic)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -292,7 +317,8 @@ _mail_imap_server_logout(ImapServer *is)
|
|||
int len;
|
||||
char out[1024];
|
||||
|
||||
if (!is) return;
|
||||
if (!is)
|
||||
return;
|
||||
|
||||
if (is->state >= IMAP_STATE_LOGGED_IN)
|
||||
{
|
||||
|
|
39
mbox.c
39
mbox.c
|
@ -4,7 +4,8 @@
|
|||
|
||||
static Evas_List *mboxes;
|
||||
|
||||
static void _mail_mbox_check_mail(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path);
|
||||
static void _mail_mbox_check_mail (void *data, Ecore_File_Monitor * monitor,
|
||||
Ecore_File_Event event, const char *path);
|
||||
|
||||
void
|
||||
_mail_mbox_add_mailbox (void *data, void *data2)
|
||||
|
@ -13,14 +14,16 @@ _mail_mbox_add_mailbox(void *data, void *data2)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data2;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
mb = E_NEW (MboxClient, 1);
|
||||
mb->config = cb;
|
||||
mb->data = data;
|
||||
mb->config->num_new = 0;
|
||||
mb->config->num_total = 0;
|
||||
mb->monitor = ecore_file_monitor_add(cb->new_path, _mail_mbox_check_mail, mb);
|
||||
mb->monitor =
|
||||
ecore_file_monitor_add (cb->new_path, _mail_mbox_check_mail, mb);
|
||||
|
||||
mboxes = evas_list_append (mboxes, mb);
|
||||
}
|
||||
|
@ -32,14 +35,17 @@ _mail_mbox_del_mailbox(void *data)
|
|||
Evas_List *l;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
for (l = mboxes; l; l = l->next)
|
||||
{
|
||||
MboxClient *mb;
|
||||
|
||||
mb = l->data;
|
||||
if (!mb) continue;
|
||||
if (mb->config != cb) continue;
|
||||
if (!mb)
|
||||
continue;
|
||||
if (mb->config != cb)
|
||||
continue;
|
||||
if (mb->monitor)
|
||||
ecore_file_monitor_del (mb->monitor);
|
||||
mboxes = evas_list_remove (mboxes, mb);
|
||||
|
@ -52,7 +58,8 @@ _mail_mbox_del_mailbox(void *data)
|
|||
void
|
||||
_mail_mbox_shutdown ()
|
||||
{
|
||||
if (!mboxes) return;
|
||||
if (!mboxes)
|
||||
return;
|
||||
while (mboxes)
|
||||
{
|
||||
MboxClient *mb;
|
||||
|
@ -68,7 +75,8 @@ _mail_mbox_shutdown()
|
|||
|
||||
/* PRIVATES */
|
||||
static void
|
||||
_mail_mbox_check_mail(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path)
|
||||
_mail_mbox_check_mail (void *data, Ecore_File_Monitor * monitor,
|
||||
Ecore_File_Event event, const char *path)
|
||||
{
|
||||
MboxClient *mb;
|
||||
Config_Box *cb;
|
||||
|
@ -77,11 +85,14 @@ _mail_mbox_check_mail(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event
|
|||
int header;
|
||||
|
||||
mb = data;
|
||||
if (!mb) return;
|
||||
if (!mb)
|
||||
return;
|
||||
|
||||
cb = mb->config;
|
||||
if (!cb) return;
|
||||
if (!cb->new_path) return;
|
||||
if (!cb)
|
||||
return;
|
||||
if (!cb->new_path)
|
||||
return;
|
||||
|
||||
if (!(f = fopen (cb->new_path, "r")))
|
||||
return;
|
||||
|
@ -99,12 +110,14 @@ _mail_mbox_check_mail(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event
|
|||
mb->config->num_total++;
|
||||
mb->config->num_new++;
|
||||
}
|
||||
else if ((header) && (!strncmp(buf, "Status: ", 7)) && (strchr(buf, 'R')))
|
||||
else if ((header) && (!strncmp (buf, "Status: ", 7))
|
||||
&& (strchr (buf, 'R')))
|
||||
mb->config->num_new--;
|
||||
}
|
||||
fclose (f);
|
||||
|
||||
_mail_set_text (mb->data);
|
||||
if ((mb->config->num_new > 0) && (mb->config->use_exec) && (mb->config->exec))
|
||||
if ((mb->config->num_new > 0) && (mb->config->use_exec)
|
||||
&& (mb->config->exec))
|
||||
_mail_start_exe (mb->config);
|
||||
}
|
||||
|
|
33
mdir.c
33
mdir.c
|
@ -4,7 +4,8 @@
|
|||
|
||||
static Evas_List *mdirs;
|
||||
|
||||
static void _mail_mdir_check_mail(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path);
|
||||
static void _mail_mdir_check_mail (void *data, Ecore_File_Monitor * monitor,
|
||||
Ecore_File_Event event, const char *path);
|
||||
static int _mail_mdir_get_files (const char *path);
|
||||
|
||||
void
|
||||
|
@ -14,14 +15,16 @@ _mail_mdir_add_mailbox(void *data, void *data2)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data2;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
mc = E_NEW (MdirClient, 1);
|
||||
mc->config = cb;
|
||||
mc->data = data;
|
||||
mc->config->num_new = 0;
|
||||
mc->config->num_total = 0;
|
||||
mc->monitor = ecore_file_monitor_add(cb->new_path, _mail_mdir_check_mail, mc);
|
||||
mc->monitor =
|
||||
ecore_file_monitor_add (cb->new_path, _mail_mdir_check_mail, mc);
|
||||
|
||||
mdirs = evas_list_append (mdirs, mc);
|
||||
}
|
||||
|
@ -33,14 +36,17 @@ _mail_mdir_del_mailbox(void *data)
|
|||
Evas_List *l;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
for (l = mdirs; l; l = l->next)
|
||||
{
|
||||
MdirClient *mc;
|
||||
|
||||
mc = l->data;
|
||||
if (!mc) continue;
|
||||
if (mc->config != cb) continue;
|
||||
if (!mc)
|
||||
continue;
|
||||
if (mc->config != cb)
|
||||
continue;
|
||||
mdirs = evas_list_remove (mdirs, mc);
|
||||
free (mc);
|
||||
mc = NULL;
|
||||
|
@ -51,7 +57,8 @@ _mail_mdir_del_mailbox(void *data)
|
|||
void
|
||||
_mail_mdir_shutdown ()
|
||||
{
|
||||
if (!mdirs) return;
|
||||
if (!mdirs)
|
||||
return;
|
||||
while (mdirs)
|
||||
{
|
||||
MdirClient *mc;
|
||||
|
@ -67,18 +74,21 @@ _mail_mdir_shutdown()
|
|||
|
||||
/* PRIVATES */
|
||||
static void
|
||||
_mail_mdir_check_mail(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path)
|
||||
_mail_mdir_check_mail (void *data, Ecore_File_Monitor * monitor,
|
||||
Ecore_File_Event event, const char *path)
|
||||
{
|
||||
MdirClient *mc;
|
||||
|
||||
mc = data;
|
||||
if (!mc) return;
|
||||
if (!mc)
|
||||
return;
|
||||
|
||||
mc->config->num_total = _mail_mdir_get_files (mc->config->cur_path);
|
||||
mc->config->num_new = _mail_mdir_get_files (mc->config->new_path);
|
||||
|
||||
_mail_set_text (mc->data);
|
||||
if ((mc->config->num_new > 0) && (mc->config->use_exec) && (mc->config->exec))
|
||||
if ((mc->config->num_new > 0) && (mc->config->use_exec)
|
||||
&& (mc->config->exec))
|
||||
_mail_start_exe (mc->config);
|
||||
}
|
||||
|
||||
|
@ -93,7 +103,8 @@ _mail_mdir_get_files(const char *path)
|
|||
ecore_list_goto_first (l);
|
||||
while ((item = (char *) ecore_list_next (l)) != NULL)
|
||||
{
|
||||
if ((!strcmp(item, ".")) || (!strcmp(item, ".."))) continue;
|
||||
if ((!strcmp (item, ".")) || (!strcmp (item, "..")))
|
||||
continue;
|
||||
i++;
|
||||
}
|
||||
ecore_list_destroy (l);
|
||||
|
|
91
pop.c
91
pop.c
|
@ -19,27 +19,37 @@ _mail_pop_check_mail(void *data)
|
|||
Instance *inst;
|
||||
|
||||
inst = data;
|
||||
if (!inst) return;
|
||||
if (!inst)
|
||||
return;
|
||||
|
||||
for (l = pclients; l; l = l->next)
|
||||
{
|
||||
PopClient *pc;
|
||||
|
||||
pc = l->data;
|
||||
if (!pc) continue;
|
||||
if (!pc)
|
||||
continue;
|
||||
pc->data = inst;
|
||||
if (!pc->server)
|
||||
{
|
||||
if (!pc->add_handler)
|
||||
pc->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _mail_pop_server_add, NULL);
|
||||
pc->add_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
|
||||
_mail_pop_server_add, NULL);
|
||||
if (!pc->del_handler)
|
||||
pc->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _mail_pop_server_del, NULL);
|
||||
pc->del_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
|
||||
_mail_pop_server_del, NULL);
|
||||
if (!pc->data_handler)
|
||||
pc->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _mail_pop_server_data, NULL);
|
||||
pc->data_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
|
||||
_mail_pop_server_data, NULL);
|
||||
|
||||
if ((ecore_con_ssl_available_get ()) && (pc->config->ssl))
|
||||
type |= ECORE_CON_USE_SSL;
|
||||
pc->server = ecore_con_server_connect(type, pc->config->host, pc->config->port, pc);
|
||||
pc->server =
|
||||
ecore_con_server_connect (type, pc->config->host,
|
||||
pc->config->port, pc);
|
||||
pc->state = POP_STATE_DISCONNECTED;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +62,8 @@ _mail_pop_add_mailbox(void *data)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
pc = _mail_pop_client_get (cb);
|
||||
pc->config->num_new = 0;
|
||||
pc->config->num_total = 0;
|
||||
|
@ -66,7 +77,8 @@ _mail_pop_del_mailbox(void *data)
|
|||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
pc = _mail_pop_client_get (cb);
|
||||
if (pc->server)
|
||||
_mail_pop_client_quit (pc);
|
||||
|
@ -82,14 +94,16 @@ _mail_pop_del_mailbox(void *data)
|
|||
void
|
||||
_mail_pop_shutdown ()
|
||||
{
|
||||
if (!pclients) return;
|
||||
if (!pclients)
|
||||
return;
|
||||
|
||||
while (pclients)
|
||||
{
|
||||
PopClient *pc;
|
||||
|
||||
pc = pclients->data;
|
||||
if (!pc) continue;
|
||||
if (!pc)
|
||||
continue;
|
||||
if (pc->server)
|
||||
_mail_pop_client_quit (pc);
|
||||
if (pc->add_handler)
|
||||
|
@ -112,7 +126,8 @@ _mail_pop_server_add(void *data, int type, void *event)
|
|||
PopClient *pc;
|
||||
|
||||
pc = _mail_pop_client_get_from_server (ev->server);
|
||||
if (!pc) return 1;
|
||||
if (!pc)
|
||||
return 1;
|
||||
|
||||
pc->state = POP_STATE_CONNECTED;
|
||||
return 0;
|
||||
|
@ -125,7 +140,8 @@ _mail_pop_server_del(void *data, int type, void *event)
|
|||
PopClient *pc;
|
||||
|
||||
pc = _mail_pop_client_get_from_server (ev->server);
|
||||
if (!pc) return 1;
|
||||
if (!pc)
|
||||
return 1;
|
||||
|
||||
if (pc->state == POP_STATE_DISCONNECTED)
|
||||
printf ("Pop Server Disconnected\n");
|
||||
|
@ -146,8 +162,10 @@ _mail_pop_server_data(void *data, int type, void *event)
|
|||
int len, num = 0, total = 0;
|
||||
|
||||
pc = _mail_pop_client_get_from_server (ev->server);
|
||||
if (!pc) return 1;
|
||||
if (pc->state == POP_STATE_DISCONNECTED) return 1;
|
||||
if (!pc)
|
||||
return 1;
|
||||
if (pc->state == POP_STATE_DISCONNECTED)
|
||||
return 1;
|
||||
|
||||
len = sizeof (in) - 1;
|
||||
len = (((len) > (ev->size)) ? ev->size : len);
|
||||
|
@ -207,7 +225,8 @@ _mail_pop_client_get(void *data)
|
|||
int found = 0;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return NULL;
|
||||
if (!cb)
|
||||
return NULL;
|
||||
|
||||
if ((!pclients) || (evas_list_count (pclients) <= 0))
|
||||
{
|
||||
|
@ -216,18 +235,26 @@ _mail_pop_client_get(void *data)
|
|||
pc->state = POP_STATE_DISCONNECTED;
|
||||
pc->config = cb;
|
||||
if (!pc->add_handler)
|
||||
pc->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _mail_pop_server_add, NULL);
|
||||
pc->add_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
|
||||
_mail_pop_server_add, NULL);
|
||||
if (!pc->del_handler)
|
||||
pc->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _mail_pop_server_del, NULL);
|
||||
pc->del_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
|
||||
_mail_pop_server_del, NULL);
|
||||
if (!pc->data_handler)
|
||||
pc->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _mail_pop_server_data, NULL);
|
||||
pc->data_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
|
||||
_mail_pop_server_data, NULL);
|
||||
}
|
||||
|
||||
for (l = pclients; l; l = l->next)
|
||||
{
|
||||
pc = l->data;
|
||||
if (!pc) continue;
|
||||
if (!pc->config) continue;
|
||||
if (!pc)
|
||||
continue;
|
||||
if (!pc->config)
|
||||
continue;
|
||||
if ((!strcmp (pc->config->host, cb->host)) &&
|
||||
(!strcmp (pc->config->user, cb->user)) &&
|
||||
(!strcmp (pc->config->pass, cb->pass)))
|
||||
|
@ -243,11 +270,17 @@ _mail_pop_client_get(void *data)
|
|||
pc->state = POP_STATE_DISCONNECTED;
|
||||
pc->config = cb;
|
||||
if (!pc->add_handler)
|
||||
pc->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _mail_pop_server_add, NULL);
|
||||
pc->add_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
|
||||
_mail_pop_server_add, NULL);
|
||||
if (!pc->del_handler)
|
||||
pc->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _mail_pop_server_del, NULL);
|
||||
pc->del_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
|
||||
_mail_pop_server_del, NULL);
|
||||
if (!pc->data_handler)
|
||||
pc->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _mail_pop_server_data, NULL);
|
||||
pc->data_handler =
|
||||
ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
|
||||
_mail_pop_server_data, NULL);
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
|
@ -258,14 +291,17 @@ _mail_pop_client_get_from_server(void *data)
|
|||
Ecore_Con_Server *server = data;
|
||||
Evas_List *l;
|
||||
|
||||
if (!pclients) return NULL;
|
||||
if (!pclients)
|
||||
return NULL;
|
||||
for (l = pclients; l; l = l->next)
|
||||
{
|
||||
PopClient *pc;
|
||||
|
||||
pc = l->data;
|
||||
if (!pc) continue;
|
||||
if (!pc->server) continue;
|
||||
if (!pc)
|
||||
continue;
|
||||
if (!pc->server)
|
||||
continue;
|
||||
if (pc->server == server)
|
||||
return pc;
|
||||
}
|
||||
|
@ -280,7 +316,8 @@ _mail_pop_client_quit(void *data)
|
|||
char out[1024];
|
||||
|
||||
pc = data;
|
||||
if (!pc) return;
|
||||
if (!pc)
|
||||
return;
|
||||
if (pc->state >= POP_STATE_CONNECTED)
|
||||
{
|
||||
len = snprintf (out, sizeof (out), "QUIT\r\n");
|
||||
|
|
Loading…
Reference in New Issue