parent
961e23fb01
commit
0e4e640217
229
e_mod_config.c
229
e_mod_config.c
|
@ -13,42 +13,46 @@ struct _E_Config_Dialog_Data
|
|||
Evas_Object *configure;
|
||||
};
|
||||
|
||||
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 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 void _load_boxes(E_Config_Dialog *cfd);
|
||||
static int _ilist_header_exists(Evas_Object *il, const char *name);
|
||||
static void _ilist_cb_selected(void *data);
|
||||
static void _cb_add_box(void *data, void *data2);
|
||||
static void _cb_edit_box(void *data, void *data2);
|
||||
static void _cb_del_box(void *data, void *data2);
|
||||
static void _load_boxes (E_Config_Dialog * cfd);
|
||||
static int _ilist_header_exists (Evas_Object * il, const char *name);
|
||||
static void _ilist_cb_selected (void *data);
|
||||
static void _cb_add_box (void *data, void *data2);
|
||||
static void _cb_edit_box (void *data, void *data2);
|
||||
static void _cb_del_box (void *data, void *data2);
|
||||
|
||||
void
|
||||
_config_mail_module(Config_Item *ci)
|
||||
_config_mail_module (Config_Item * ci)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
E_Container *con;
|
||||
char buf[4096];
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
if (!v) return;
|
||||
v = E_NEW (E_Config_Dialog_View, 1);
|
||||
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));
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
cfd = e_config_dialog_new(con, _("Mail Configuration"), buf, 0, v, ci);
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
|
||||
_fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
cfdata->show_label = ci->show_label;
|
||||
cfdata->check_time = ci->check_time;
|
||||
|
@ -56,82 +60,93 @@ _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
|
|||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
_create_data (E_Config_Dialog * cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Config_Item *ci;
|
||||
|
||||
ci = cfd->data;
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
_fill_data(ci, cfdata);
|
||||
cfdata = E_NEW (E_Config_Dialog_Data, 1);
|
||||
_fill_data (ci, cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
_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);
|
||||
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));
|
||||
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);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
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));
|
||||
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);
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Mail Boxes"), 0);
|
||||
ob = e_widget_ilist_add(evas, 32, 32, NULL);
|
||||
e_widget_ilist_selector_set(ob, 1);
|
||||
of = e_widget_frametable_add (evas, _("Mail Boxes"), 0);
|
||||
ob = e_widget_ilist_add (evas, 32, 32, NULL);
|
||||
e_widget_ilist_selector_set (ob, 1);
|
||||
cfdata->il = ob;
|
||||
_load_boxes(cfd);
|
||||
e_widget_min_size_set(ob, 160, 140);
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 4, 1, 1, 1, 1);
|
||||
_load_boxes (cfd);
|
||||
e_widget_min_size_set (ob, 160, 140);
|
||||
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);
|
||||
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);
|
||||
e_widget_disabled_set(ob, 1);
|
||||
ot = e_widget_table_add (evas, 0);
|
||||
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);
|
||||
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);
|
||||
e_widget_disabled_set(ob, 1);
|
||||
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);
|
||||
e_widget_disabled_set (ob, 1);
|
||||
cfdata->configure = ob;
|
||||
e_widget_table_object_append(ot, ob, 0, 2, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_frametable_object_append(of, ot, 1, 0, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_table_object_append (ot, ob, 0, 2, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_frametable_object_append (of, ot, 1, 0, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
_basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = cfd->data;
|
||||
ci->show_label = cfdata->show_label;
|
||||
ci->check_time = cfdata->check_time;
|
||||
e_config_save_queue();
|
||||
_mail_config_updated(ci->id);
|
||||
e_config_save_queue ();
|
||||
_mail_config_updated (ci->id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_load_boxes(E_Config_Dialog *cfd)
|
||||
_load_boxes (E_Config_Dialog * cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_Object *il;
|
||||
|
@ -141,16 +156,21 @@ _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);
|
||||
e_widget_ilist_clear (il);
|
||||
|
||||
for (i = 0; i <= 3; i++)
|
||||
{
|
||||
|
@ -173,9 +193,9 @@ _load_boxes(E_Config_Dialog *cfd)
|
|||
name = "Mailbox";
|
||||
break;
|
||||
}
|
||||
found = _ilist_header_exists(il, name);
|
||||
found = _ilist_header_exists (il, name);
|
||||
if (found <= 0)
|
||||
e_widget_ilist_header_append(il, NULL, name);
|
||||
e_widget_ilist_header_append (il, NULL, name);
|
||||
|
||||
for (box = ci->boxes; box; box = box->next)
|
||||
{
|
||||
|
@ -183,44 +203,51 @@ _load_boxes(E_Config_Dialog *cfd)
|
|||
Evas_Object *ic;
|
||||
|
||||
cb = box->data;
|
||||
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);
|
||||
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_go(il);
|
||||
e_widget_ilist_go (il);
|
||||
}
|
||||
|
||||
static int
|
||||
_ilist_header_exists(Evas_Object *il, const char *name)
|
||||
_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;
|
||||
c = e_widget_ilist_count (il);
|
||||
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 (!strcmp(n, name))
|
||||
n = e_widget_ilist_nth_label_get (il, i);
|
||||
if (!n)
|
||||
continue;
|
||||
if (!strcmp (n, name))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) return i;
|
||||
if (found)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_ilist_cb_selected(void *data)
|
||||
_ilist_cb_selected (void *data)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
@ -228,28 +255,29 @@ _ilist_cb_selected(void *data)
|
|||
cfd = data;
|
||||
cfdata = cfd->cfdata;
|
||||
|
||||
e_widget_disabled_set(cfdata->del, 0);
|
||||
e_widget_disabled_set(cfdata->configure, 0);
|
||||
e_widget_disabled_set (cfdata->del, 0);
|
||||
e_widget_disabled_set (cfdata->configure, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add_box(void *data, void *data2)
|
||||
_cb_add_box (void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Config_Item *ci;
|
||||
|
||||
cfd = data;
|
||||
if (!cfd) return;
|
||||
if (!cfd)
|
||||
return;
|
||||
|
||||
ci = cfd->data;
|
||||
cfdata = cfd->cfdata;
|
||||
|
||||
_config_box(ci, NULL, cfd);
|
||||
_config_box (ci, NULL, cfd);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_edit_box(void *data, void *data2)
|
||||
_cb_edit_box (void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
@ -259,31 +287,34 @@ _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);
|
||||
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 (!strcmp(s, cb->name))
|
||||
if (!cb->name)
|
||||
continue;
|
||||
if (!strcmp (s, cb->name))
|
||||
{
|
||||
_config_box(ci, cb, cfd);
|
||||
_config_box (ci, cb, cfd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_del_box(void *data, void *data2)
|
||||
_cb_del_box (void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
@ -293,31 +324,33 @@ _cb_del_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);
|
||||
s = e_widget_ilist_selected_label_get (il);
|
||||
|
||||
for (l = ci->boxes; l; l = l->next)
|
||||
{
|
||||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb->name) continue;
|
||||
if (!strcmp(s, cb->name))
|
||||
if (!cb->name)
|
||||
continue;
|
||||
if (!strcmp (s, cb->name))
|
||||
{
|
||||
_mail_box_deleted(ci->id, cb->name);
|
||||
_mail_box_deleted (ci->id, cb->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_load_boxes(cfd);
|
||||
_load_boxes (cfd);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_box_config_updated(E_Config_Dialog *cfd)
|
||||
_mail_box_config_updated (E_Config_Dialog * cfd)
|
||||
{
|
||||
_load_boxes(cfd);
|
||||
_load_boxes (cfd);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -25,25 +25,28 @@ struct _E_Config_Dialog_Data
|
|||
Evas_Object *cur_path_entry;
|
||||
};
|
||||
|
||||
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 void _type_cb_change(void *data, Evas_Object *obj);
|
||||
static void _use_exec_cb_change(void *data, Evas_Object *obj);
|
||||
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 void _type_cb_change (void *data, Evas_Object * obj);
|
||||
static void _use_exec_cb_change (void *data, Evas_Object * obj);
|
||||
|
||||
static E_Config_Dialog *prev_dlg;
|
||||
static Config_Item *mail_ci;
|
||||
|
||||
void
|
||||
_config_box(Config_Item *ci, Config_Box *cb, E_Config_Dialog *mcfd)
|
||||
_config_box (Config_Item * ci, Config_Box * cb, E_Config_Dialog * mcfd)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
E_Container *con;
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
if (!v) return;
|
||||
v = E_NEW (E_Config_Dialog_View, 1);
|
||||
if (!v)
|
||||
return;
|
||||
|
||||
prev_dlg = mcfd;
|
||||
mail_ci = ci;
|
||||
|
@ -53,12 +56,12 @@ _config_box(Config_Item *ci, Config_Box *cb, E_Config_Dialog *mcfd)
|
|||
v->basic.apply_cfdata = _basic_apply_data;
|
||||
v->basic.create_widgets = _basic_create_widgets;
|
||||
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
cfd = e_config_dialog_new(con, _("Mailbox Configuration"), NULL, 0, v, cb);
|
||||
con = e_container_current_get (e_manager_current_get ());
|
||||
cfd = e_config_dialog_new (con, _("Mailbox Configuration"), NULL, 0, v, cb);
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(Config_Box *cb, E_Config_Dialog_Data *cfdata)
|
||||
_fill_data (Config_Box * cb, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
@ -67,163 +70,172 @@ _fill_data(Config_Box *cb, E_Config_Dialog_Data *cfdata)
|
|||
cfdata->type = 0;
|
||||
cfdata->ssl = 0;
|
||||
cfdata->use_exec = 0;
|
||||
snprintf(buf, sizeof(buf), "110");
|
||||
cfdata->port = strdup(buf);
|
||||
snprintf (buf, sizeof (buf), "110");
|
||||
cfdata->port = strdup (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb->name)
|
||||
cfdata->name = strdup(cb->name);
|
||||
cfdata->name = strdup (cb->name);
|
||||
|
||||
cfdata->type = cb->type;
|
||||
cfdata->ssl = cb->ssl;
|
||||
cfdata->use_exec = cb->use_exec;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%d", cb->port);
|
||||
cfdata->port = strdup(buf);
|
||||
snprintf (buf, sizeof (buf), "%d", cb->port);
|
||||
cfdata->port = strdup (buf);
|
||||
|
||||
if (cb->exec)
|
||||
cfdata->exec = strdup(cb->exec);
|
||||
cfdata->exec = strdup (cb->exec);
|
||||
if (cb->host)
|
||||
cfdata->host = strdup(cb->host);
|
||||
cfdata->host = strdup (cb->host);
|
||||
if (cb->user)
|
||||
cfdata->user = strdup(cb->user);
|
||||
cfdata->user = strdup (cb->user);
|
||||
if (cb->pass)
|
||||
cfdata->pass = strdup(cb->pass);
|
||||
cfdata->pass = strdup (cb->pass);
|
||||
|
||||
if (cb->new_path)
|
||||
cfdata->new_path = strdup(cb->new_path);
|
||||
cfdata->new_path = strdup (cb->new_path);
|
||||
if (cb->cur_path)
|
||||
cfdata->cur_path = strdup(cb->cur_path);
|
||||
cfdata->cur_path = strdup (cb->cur_path);
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
_create_data (E_Config_Dialog * cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = cfd->data;
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
_fill_data(cb, cfdata);
|
||||
cfdata = E_NEW (E_Config_Dialog_Data, 1);
|
||||
_fill_data (cb, cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
_free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
E_FREE(cfdata->name);
|
||||
E_FREE(cfdata->port);
|
||||
E_FREE(cfdata->host);
|
||||
E_FREE(cfdata->user);
|
||||
E_FREE(cfdata->pass);
|
||||
E_FREE(cfdata->new_path);
|
||||
E_FREE(cfdata->cur_path);
|
||||
E_FREE(cfdata->exec);
|
||||
E_FREE (cfdata->name);
|
||||
E_FREE (cfdata->port);
|
||||
E_FREE (cfdata->host);
|
||||
E_FREE (cfdata->user);
|
||||
E_FREE (cfdata->pass);
|
||||
E_FREE (cfdata->new_path);
|
||||
E_FREE (cfdata->cur_path);
|
||||
E_FREE (cfdata->exec);
|
||||
|
||||
free(cfdata);
|
||||
free (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));
|
||||
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);
|
||||
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_framelist_object_append(of, ot);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
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));
|
||||
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);
|
||||
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_framelist_object_append (of, ot);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
e_widget_disabled_set(cfdata->exec_label, !cfdata->use_exec);
|
||||
e_widget_disabled_set(cfdata->exec_entry, !cfdata->use_exec);
|
||||
e_widget_disabled_set (cfdata->exec_label, !cfdata->use_exec);
|
||||
e_widget_disabled_set (cfdata->exec_entry, !cfdata->use_exec);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Mailbox Type"), 0);
|
||||
rg = e_widget_radio_group_new(&(cfdata->type));
|
||||
ob = e_widget_radio_add(evas, _("Pop3"), 0, rg);
|
||||
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Imap"), 1, rg);
|
||||
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Maildir"), 2, rg);
|
||||
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Mbox"), 3, rg);
|
||||
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
of = e_widget_framelist_add (evas, _("Mailbox Type"), 0);
|
||||
rg = e_widget_radio_group_new (&(cfdata->type));
|
||||
ob = e_widget_radio_add (evas, _("Pop3"), 0, rg);
|
||||
e_widget_on_change_hook_set (ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
ob = e_widget_radio_add (evas, _("Imap"), 1, rg);
|
||||
e_widget_on_change_hook_set (ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
ob = e_widget_radio_add (evas, _("Maildir"), 2, rg);
|
||||
e_widget_on_change_hook_set (ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
ob = e_widget_radio_add (evas, _("Mbox"), 3, rg);
|
||||
e_widget_on_change_hook_set (ob, _type_cb_change, cfdata);
|
||||
e_widget_framelist_object_append (of, ob);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Port Settings"), 1);
|
||||
of = e_widget_frametable_add (evas, _("Port Settings"), 1);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Use SSL:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_check_add(evas, "", &(cfdata->ssl));
|
||||
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_label_add (evas, _("Use SSL:"));
|
||||
e_widget_frametable_object_append (of, ob, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_check_add (evas, "", &(cfdata->ssl));
|
||||
e_widget_on_change_hook_set (ob, _type_cb_change, cfdata);
|
||||
e_widget_frametable_object_append (of, ob, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Port:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add(evas, &cfdata->port);
|
||||
ob = e_widget_label_add (evas, _("Port:"));
|
||||
e_widget_frametable_object_append (of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add (evas, &cfdata->port);
|
||||
cfdata->port_entry = ob;
|
||||
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
e_widget_frametable_object_append (of, ob, 1, 1, 1, 1, 0, 0, 1, 0);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Mailbox Settings"), 1);
|
||||
ob = e_widget_label_add(evas, _("Name:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add(evas, &cfdata->name);
|
||||
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||
of = e_widget_frametable_add (evas, _("Mailbox Settings"), 1);
|
||||
ob = e_widget_label_add (evas, _("Name:"));
|
||||
e_widget_frametable_object_append (of, ob, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add (evas, &cfdata->name);
|
||||
e_widget_frametable_object_append (of, ob, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Mail Host:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add(evas, &cfdata->host);
|
||||
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_label_add (evas, _("Mail Host:"));
|
||||
e_widget_frametable_object_append (of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add (evas, &cfdata->host);
|
||||
e_widget_frametable_object_append (of, ob, 1, 1, 1, 1, 0, 0, 1, 0);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Username:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add(evas, &cfdata->user);
|
||||
e_widget_frametable_object_append(of, ob, 1, 2, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_label_add (evas, _("Username:"));
|
||||
e_widget_frametable_object_append (of, ob, 0, 2, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add (evas, &cfdata->user);
|
||||
e_widget_frametable_object_append (of, ob, 1, 2, 1, 1, 0, 0, 1, 0);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Password:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add(evas, &cfdata->pass);
|
||||
e_widget_frametable_object_append(of, ob, 1, 3, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_label_add (evas, _("Password:"));
|
||||
e_widget_frametable_object_append (of, ob, 0, 3, 1, 1, 0, 0, 1, 0);
|
||||
ob = e_widget_entry_add (evas, &cfdata->pass);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
if (cfdata->type == 0)
|
||||
{
|
||||
e_widget_disabled_set(cfdata->new_path_label, 1);
|
||||
e_widget_disabled_set(cfdata->new_path_entry, 1);
|
||||
e_widget_disabled_set (cfdata->new_path_label, 1);
|
||||
e_widget_disabled_set (cfdata->new_path_entry, 1);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
if ((cfdata->type == 1) || (cfdata->type == 3))
|
||||
{
|
||||
e_widget_disabled_set(cfdata->cur_path_label, 1);
|
||||
e_widget_disabled_set(cfdata->cur_path_entry, 1);
|
||||
e_widget_disabled_set (cfdata->cur_path_label, 1);
|
||||
e_widget_disabled_set (cfdata->cur_path_entry, 1);
|
||||
}
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
e_widget_list_object_append (o, of, 1, 1, 0.5);
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
_basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
Config_Box *cb;
|
||||
int is_new = 0;
|
||||
|
@ -234,136 +246,143 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
cb = cfd->data;
|
||||
if (!cb)
|
||||
{
|
||||
cb = E_NEW(Config_Box, 1);
|
||||
cb = E_NEW (Config_Box, 1);
|
||||
cb->type = 0;
|
||||
cb->port = 110;
|
||||
cb->ssl = 0;
|
||||
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);
|
||||
cb->name = evas_stringshare_add (cfdata->name);
|
||||
else
|
||||
cb->name = evas_stringshare_add("");
|
||||
cb->name = evas_stringshare_add ("");
|
||||
|
||||
cb->type = cfdata->type;
|
||||
cb->port = atoi(cfdata->port);
|
||||
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);
|
||||
cb->exec = evas_stringshare_add (cfdata->exec);
|
||||
else
|
||||
cb->exec = evas_stringshare_add("");
|
||||
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);
|
||||
cb->host = evas_stringshare_add (cfdata->host);
|
||||
else
|
||||
cb->host = evas_stringshare_add("");
|
||||
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);
|
||||
cb->user = evas_stringshare_add (cfdata->user);
|
||||
else
|
||||
cb->user = evas_stringshare_add("");
|
||||
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);
|
||||
cb->pass = evas_stringshare_add (cfdata->pass);
|
||||
else
|
||||
cb->pass = evas_stringshare_add("");
|
||||
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);
|
||||
cb->new_path = evas_stringshare_add (cfdata->new_path);
|
||||
else
|
||||
cb->new_path = evas_stringshare_add("");
|
||||
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);
|
||||
cb->cur_path = evas_stringshare_add (cfdata->cur_path);
|
||||
else
|
||||
cb->cur_path = evas_stringshare_add("");
|
||||
cb->cur_path = evas_stringshare_add ("");
|
||||
|
||||
if (!is_new)
|
||||
e_config_save_queue();
|
||||
e_config_save_queue ();
|
||||
|
||||
if (is_new)
|
||||
{
|
||||
// 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_ci->boxes = evas_list_append (mail_ci->boxes, cb);
|
||||
e_config_save_queue ();
|
||||
_mail_box_added (mail_ci->id, cb->name);
|
||||
}
|
||||
|
||||
_mail_box_config_updated(prev_dlg);
|
||||
_mail_box_config_updated (prev_dlg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_type_cb_change(void *data, Evas_Object *obj)
|
||||
_type_cb_change (void *data, Evas_Object * obj)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (cfdata->type == 0)
|
||||
{
|
||||
e_widget_disabled_set(cfdata->new_path_label, 1);
|
||||
e_widget_disabled_set(cfdata->new_path_entry, 1);
|
||||
e_widget_disabled_set(cfdata->cur_path_label, 1);
|
||||
e_widget_disabled_set(cfdata->cur_path_entry, 1);
|
||||
e_widget_entry_text_set(cfdata->new_path_entry, "");
|
||||
e_widget_entry_text_set(cfdata->cur_path_entry, "");
|
||||
e_widget_disabled_set (cfdata->new_path_label, 1);
|
||||
e_widget_disabled_set (cfdata->new_path_entry, 1);
|
||||
e_widget_disabled_set (cfdata->cur_path_label, 1);
|
||||
e_widget_disabled_set (cfdata->cur_path_entry, 1);
|
||||
e_widget_entry_text_set (cfdata->new_path_entry, "");
|
||||
e_widget_entry_text_set (cfdata->cur_path_entry, "");
|
||||
if (cfdata->ssl)
|
||||
{
|
||||
e_widget_entry_text_set(cfdata->port_entry, "995");
|
||||
cfdata->port = strdup("995");
|
||||
e_widget_entry_text_set (cfdata->port_entry, "995");
|
||||
cfdata->port = strdup ("995");
|
||||
}
|
||||
else
|
||||
{
|
||||
e_widget_entry_text_set(cfdata->port_entry, "110");
|
||||
cfdata->port = strdup("110");
|
||||
e_widget_entry_text_set (cfdata->port_entry, "110");
|
||||
cfdata->port = strdup ("110");
|
||||
}
|
||||
}
|
||||
else if ((cfdata->type == 1) || (cfdata->type == 3))
|
||||
{
|
||||
e_widget_disabled_set(cfdata->new_path_label, 0);
|
||||
e_widget_disabled_set(cfdata->new_path_entry, 0);
|
||||
e_widget_disabled_set(cfdata->cur_path_label, 1);
|
||||
e_widget_disabled_set(cfdata->cur_path_entry, 1);
|
||||
e_widget_entry_text_set(cfdata->cur_path_entry, "");
|
||||
e_widget_entry_text_set(cfdata->new_path_entry, _("Inbox"));
|
||||
e_widget_disabled_set (cfdata->new_path_label, 0);
|
||||
e_widget_disabled_set (cfdata->new_path_entry, 0);
|
||||
e_widget_disabled_set (cfdata->cur_path_label, 1);
|
||||
e_widget_disabled_set (cfdata->cur_path_entry, 1);
|
||||
e_widget_entry_text_set (cfdata->cur_path_entry, "");
|
||||
e_widget_entry_text_set (cfdata->new_path_entry, _("Inbox"));
|
||||
if (cfdata->ssl)
|
||||
{
|
||||
e_widget_entry_text_set(cfdata->port_entry, "993");
|
||||
cfdata->port = strdup("993");
|
||||
e_widget_entry_text_set (cfdata->port_entry, "993");
|
||||
cfdata->port = strdup ("993");
|
||||
}
|
||||
else
|
||||
{
|
||||
e_widget_entry_text_set(cfdata->port_entry, "143");
|
||||
cfdata->port = strdup("143");
|
||||
e_widget_entry_text_set (cfdata->port_entry, "143");
|
||||
cfdata->port = strdup ("143");
|
||||
}
|
||||
}
|
||||
else if (cfdata->type == 2)
|
||||
{
|
||||
e_widget_disabled_set(cfdata->new_path_label, 0);
|
||||
e_widget_disabled_set(cfdata->new_path_entry, 0);
|
||||
e_widget_disabled_set(cfdata->cur_path_label, 0);
|
||||
e_widget_disabled_set(cfdata->cur_path_entry, 0);
|
||||
e_widget_entry_text_set(cfdata->port_entry, "");
|
||||
e_widget_disabled_set (cfdata->new_path_label, 0);
|
||||
e_widget_disabled_set (cfdata->new_path_entry, 0);
|
||||
e_widget_disabled_set (cfdata->cur_path_label, 0);
|
||||
e_widget_disabled_set (cfdata->cur_path_entry, 0);
|
||||
e_widget_entry_text_set (cfdata->port_entry, "");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_use_exec_cb_change(void *data, Evas_Object *obj)
|
||||
_use_exec_cb_change (void *data, Evas_Object * obj)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->exec_label, !cfdata->use_exec);
|
||||
e_widget_disabled_set(cfdata->exec_entry, !cfdata->use_exec);
|
||||
e_widget_disabled_set (cfdata->exec_label, !cfdata->use_exec);
|
||||
e_widget_disabled_set (cfdata->exec_entry, !cfdata->use_exec);
|
||||
if (!cfdata->use_exec)
|
||||
e_widget_entry_text_set(cfdata->exec_entry, "");
|
||||
e_widget_entry_text_set (cfdata->exec_entry, "");
|
||||
}
|
||||
|
|
565
e_mod_main.c
565
e_mod_main.c
|
@ -25,24 +25,29 @@
|
|||
#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 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);
|
||||
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_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);
|
||||
static Mail *_mail_new(Evas *evas);
|
||||
static void _mail_free(Mail *mail);
|
||||
static int _mail_cb_check(void *data);
|
||||
static int _mail_cb_exe_exit(void *data, int type, void *event);
|
||||
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);
|
||||
static Mail *_mail_new (Evas * evas);
|
||||
static void _mail_free (Mail * mail);
|
||||
static int _mail_cb_check (void *data);
|
||||
static int _mail_cb_exe_exit (void *data, int type, void *event);
|
||||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
static E_Config_DD *conf_item_edd = NULL;
|
||||
|
@ -52,14 +57,13 @@ 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}
|
||||
};
|
||||
|
||||
static E_Gadcon_Client *
|
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
Instance *inst;
|
||||
|
@ -68,29 +72,33 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
Evas_List *l, *j;
|
||||
int have_pop = 0, have_imap = 0;
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
ci = _mail_config_item_get(id);
|
||||
if (!ci->id) ci->id = evas_stringshare_add(id);
|
||||
inst = E_NEW (Instance, 1);
|
||||
ci = _mail_config_item_get (id);
|
||||
if (!ci->id)
|
||||
ci->id = evas_stringshare_add (id);
|
||||
|
||||
mail = _mail_new(gc->evas);
|
||||
mail = _mail_new (gc->evas);
|
||||
mail->inst = inst;
|
||||
inst->mail = mail;
|
||||
|
||||
gcc = e_gadcon_client_new(gc, name, id, style, mail->mail_obj);
|
||||
gcc = e_gadcon_client_new (gc, name, id, style, mail->mail_obj);
|
||||
gcc->data = inst;
|
||||
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", "");
|
||||
edje_object_signal_emit (inst->mail_obj, "label_active", "");
|
||||
else
|
||||
edje_object_signal_emit(inst->mail_obj, "label_passive", "");
|
||||
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
|
||||
|
||||
mail_config->instances = evas_list_append(mail_config->instances, inst);
|
||||
mail_config->instances = evas_list_append (mail_config->instances, inst);
|
||||
for (l = mail_config->items; l; l = l->next)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
@ -105,81 +113,93 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
{
|
||||
case MAIL_TYPE_IMAP:
|
||||
have_imap = 1;
|
||||
_mail_imap_add_mailbox(cb);
|
||||
_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);
|
||||
_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);
|
||||
_mail_mdir_add_mailbox (inst, cb);
|
||||
break;
|
||||
case MAIL_TYPE_MBOX:
|
||||
_mail_mbox_add_mailbox(inst, cb);
|
||||
_mail_mbox_add_mailbox (inst, cb);
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||
_gc_shutdown (E_Gadcon_Client * gcc)
|
||||
{
|
||||
Instance *inst;
|
||||
|
||||
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);
|
||||
free(inst);
|
||||
mail_config->instances = evas_list_remove (mail_config->instances, inst);
|
||||
_mail_free (inst->mail);
|
||||
free (inst);
|
||||
inst = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_orient(E_Gadcon_Client *gcc)
|
||||
_gc_orient (E_Gadcon_Client * gcc)
|
||||
{
|
||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
||||
e_gadcon_client_aspect_set (gcc, 16, 16);
|
||||
e_gadcon_client_min_size_set (gcc, 16, 16);
|
||||
}
|
||||
|
||||
static char *
|
||||
_gc_label(void)
|
||||
_gc_label (void)
|
||||
{
|
||||
return D_("Mail");
|
||||
return D_ ("Mail");
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_gc_icon(Evas *evas)
|
||||
_gc_icon (Evas * evas)
|
||||
{
|
||||
Evas_Object *o;
|
||||
char buf[4096];
|
||||
|
||||
o = edje_object_add(evas);
|
||||
snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mail_config->module));
|
||||
edje_object_file_set(o, buf, "icon");
|
||||
o = edje_object_add (evas);
|
||||
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;
|
||||
|
@ -187,100 +207,109 @@ _mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
int x, y, w, h;
|
||||
char buf[1024];
|
||||
|
||||
mn = e_menu_new();
|
||||
e_menu_post_deactivate_callback_set(mn, _mail_menu_cb_post, inst);
|
||||
mn = e_menu_new ();
|
||||
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))
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if ((ci->boxes) && (evas_list_count (ci->boxes) > 0))
|
||||
{
|
||||
E_Menu_Item *mm;
|
||||
|
||||
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");
|
||||
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");
|
||||
|
||||
sn = e_menu_new();
|
||||
sn = e_menu_new ();
|
||||
for (l = ci->boxes; l; l = l->next)
|
||||
{
|
||||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb) continue;
|
||||
mi = e_menu_item_new(sn);
|
||||
snprintf(buf, sizeof(buf), "%s: %d/%d", cb->name, cb->num_new, cb->num_total);
|
||||
e_menu_item_label_set(mi, buf);
|
||||
if (!cb)
|
||||
continue;
|
||||
mi = e_menu_item_new (sn);
|
||||
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);
|
||||
e_menu_item_callback_set (mi, _mail_menu_cb_exec, cb);
|
||||
}
|
||||
e_menu_item_submenu_set(mm, sn);
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
e_menu_item_submenu_set (mm, sn);
|
||||
mi = e_menu_item_new (mn);
|
||||
e_menu_item_separator_set (mi, 1);
|
||||
}
|
||||
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_label_set(mi, _("Configuration"));
|
||||
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
|
||||
e_menu_item_callback_set(mi, _mail_menu_cb_configure, inst);
|
||||
mi = e_menu_item_new (mn);
|
||||
e_menu_item_label_set (mi, _("Configuration"));
|
||||
e_util_menu_item_edje_icon_set (mi, "enlightenment/configuration");
|
||||
e_menu_item_callback_set (mi, _mail_menu_cb_configure, inst);
|
||||
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
mi = e_menu_item_new (mn);
|
||||
e_menu_item_separator_set (mi, 1);
|
||||
|
||||
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_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);
|
||||
}
|
||||
else if (ev->button == 1)
|
||||
_mail_cb_check(inst);
|
||||
_mail_cb_check (inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
_mail_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, void *event_info)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (!inst) return;
|
||||
edje_object_signal_emit(inst->mail_obj, "label_active", "");
|
||||
if (!inst)
|
||||
return;
|
||||
edje_object_signal_emit (inst->mail_obj, "label_active", "");
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
_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 (!inst)
|
||||
return;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if (!ci->show_label)
|
||||
edje_object_signal_emit(inst->mail_obj, "label_passive", "");
|
||||
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_menu_cb_post(void *data, E_Menu *m)
|
||||
_mail_menu_cb_post (void *data, E_Menu * m)
|
||||
{
|
||||
if (!mail_config->menu) return;
|
||||
e_object_del(E_OBJECT(mail_config->menu));
|
||||
if (!mail_config->menu)
|
||||
return;
|
||||
e_object_del (E_OBJECT (mail_config->menu));
|
||||
mail_config->menu = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
_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);
|
||||
if (!inst)
|
||||
return;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
_config_mail_module (ci);
|
||||
}
|
||||
|
||||
static Config_Item *
|
||||
_mail_config_item_get(const char *id)
|
||||
_mail_config_item_get (const char *id)
|
||||
{
|
||||
Evas_List *l;
|
||||
Config_Item *ci;
|
||||
|
@ -288,98 +317,99 @@ _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);
|
||||
ci->id = evas_stringshare_add(id);
|
||||
ci = E_NEW (Config_Item, 1);
|
||||
ci->id = evas_stringshare_add (id);
|
||||
ci->show_label = 1;
|
||||
ci->check_time = 15.0;
|
||||
ci->boxes = NULL;
|
||||
|
||||
mail_config->items = evas_list_append(mail_config->items, ci);
|
||||
mail_config->items = evas_list_append (mail_config->items, ci);
|
||||
return ci;
|
||||
}
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
EAPI E_Module_Api e_modapi = {
|
||||
E_MODULE_API_VERSION,
|
||||
"Mail"
|
||||
};
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
e_modapi_init (E_Module * m)
|
||||
{
|
||||
conf_box_edd = E_CONFIG_DD_NEW("Mail_Box_Config", Config_Box);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config_Box
|
||||
#define D conf_box_edd
|
||||
E_CONFIG_VAL(D, T, name, STR);
|
||||
E_CONFIG_VAL(D, T, type, INT);
|
||||
E_CONFIG_VAL(D, T, port, INT);
|
||||
E_CONFIG_VAL(D, T, ssl, UCHAR);
|
||||
E_CONFIG_VAL(D, T, host, STR);
|
||||
E_CONFIG_VAL(D, T, user, STR);
|
||||
E_CONFIG_VAL(D, T, pass, STR);
|
||||
E_CONFIG_VAL(D, T, new_path, STR);
|
||||
E_CONFIG_VAL(D, T, cur_path, STR);
|
||||
E_CONFIG_VAL(D, T, use_exec, UCHAR);
|
||||
E_CONFIG_VAL(D, T, exec, STR);
|
||||
conf_box_edd = E_CONFIG_DD_NEW ("Mail_Box_Config", Config_Box);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config_Box
|
||||
#define D conf_box_edd
|
||||
E_CONFIG_VAL (D, T, name, STR);
|
||||
E_CONFIG_VAL (D, T, type, INT);
|
||||
E_CONFIG_VAL (D, T, port, INT);
|
||||
E_CONFIG_VAL (D, T, ssl, UCHAR);
|
||||
E_CONFIG_VAL (D, T, host, STR);
|
||||
E_CONFIG_VAL (D, T, user, STR);
|
||||
E_CONFIG_VAL (D, T, pass, STR);
|
||||
E_CONFIG_VAL (D, T, new_path, STR);
|
||||
E_CONFIG_VAL (D, T, cur_path, STR);
|
||||
E_CONFIG_VAL (D, T, use_exec, UCHAR);
|
||||
E_CONFIG_VAL (D, T, exec, STR);
|
||||
|
||||
conf_item_edd = E_CONFIG_DD_NEW("Mail_Config_Item", Config_Item);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config_Item
|
||||
#define D conf_item_edd
|
||||
E_CONFIG_VAL(D, T, id, STR);
|
||||
E_CONFIG_VAL(D, T, show_label, UCHAR);
|
||||
E_CONFIG_VAL(D, T, check_time, DOUBLE);
|
||||
E_CONFIG_LIST(D, T, boxes, conf_box_edd);
|
||||
conf_item_edd = E_CONFIG_DD_NEW ("Mail_Config_Item", Config_Item);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config_Item
|
||||
#define D conf_item_edd
|
||||
E_CONFIG_VAL (D, T, id, STR);
|
||||
E_CONFIG_VAL (D, T, show_label, UCHAR);
|
||||
E_CONFIG_VAL (D, T, check_time, DOUBLE);
|
||||
E_CONFIG_LIST (D, T, boxes, conf_box_edd);
|
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("Mail_Config", Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_LIST(D, T, items, conf_item_edd);
|
||||
conf_edd = E_CONFIG_DD_NEW ("Mail_Config", Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_LIST (D, T, items, conf_item_edd);
|
||||
|
||||
mail_config = e_config_domain_load("module.mail", conf_edd);
|
||||
mail_config = e_config_domain_load ("module.mail", conf_edd);
|
||||
if (!mail_config)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
mail_config = E_NEW(Config, 1);
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
mail_config = E_NEW (Config, 1);
|
||||
ci = E_NEW (Config_Item, 1);
|
||||
|
||||
ci->id = evas_stringshare_add("0");
|
||||
ci->id = evas_stringshare_add ("0");
|
||||
ci->show_label = 1;
|
||||
ci->check_time = 15.0;
|
||||
ci->boxes = NULL;
|
||||
|
||||
mail_config->items = evas_list_append(mail_config->items, ci);
|
||||
mail_config->items = evas_list_append (mail_config->items, ci);
|
||||
}
|
||||
mail_config->module = m;
|
||||
e_gadcon_provider_register(&_gc_class);
|
||||
e_gadcon_provider_register (&_gc_class);
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
e_modapi_shutdown (E_Module * m)
|
||||
{
|
||||
mail_config->module = NULL;
|
||||
e_gadcon_provider_unregister(&_gc_class);
|
||||
e_gadcon_provider_unregister (&_gc_class);
|
||||
|
||||
if (exit_handler)
|
||||
ecore_event_handler_del(exit_handler);
|
||||
ecore_event_handler_del (exit_handler);
|
||||
|
||||
if (mail_config->config_dialog)
|
||||
e_object_del(E_OBJECT(mail_config->config_dialog));
|
||||
e_object_del (E_OBJECT (mail_config->config_dialog));
|
||||
if (mail_config->menu)
|
||||
{
|
||||
e_menu_post_deactivate_callback_set(mail_config->menu, NULL, NULL);
|
||||
e_object_del(E_OBJECT(mail_config->menu));
|
||||
e_menu_post_deactivate_callback_set (mail_config->menu, NULL, NULL);
|
||||
e_object_del (E_OBJECT (mail_config->menu));
|
||||
mail_config->menu = NULL;
|
||||
}
|
||||
while (mail_config->items)
|
||||
|
@ -395,48 +425,57 @@ e_modapi_shutdown(E_Module *m)
|
|||
switch (cb->type)
|
||||
{
|
||||
case MAIL_TYPE_IMAP:
|
||||
_mail_imap_del_mailbox(cb);
|
||||
_mail_imap_del_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_POP:
|
||||
_mail_pop_del_mailbox(cb);
|
||||
_mail_pop_del_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_MDIR:
|
||||
_mail_mdir_del_mailbox(cb);
|
||||
_mail_mdir_del_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_MBOX:
|
||||
_mail_mbox_del_mailbox(cb);
|
||||
_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);
|
||||
ci->boxes = evas_list_remove_list(ci->boxes, ci->boxes);
|
||||
free(cb);
|
||||
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);
|
||||
free(ci);
|
||||
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;
|
||||
}
|
||||
_mail_imap_shutdown();
|
||||
_mail_pop_shutdown();
|
||||
_mail_mdir_shutdown();
|
||||
_mail_mbox_shutdown();
|
||||
free(mail_config);
|
||||
_mail_imap_shutdown ();
|
||||
_mail_pop_shutdown ();
|
||||
_mail_mdir_shutdown ();
|
||||
_mail_mbox_shutdown ();
|
||||
free (mail_config);
|
||||
mail_config = NULL;
|
||||
E_CONFIG_DD_FREE(conf_box_edd);
|
||||
E_CONFIG_DD_FREE(conf_item_edd);
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
E_CONFIG_DD_FREE (conf_box_edd);
|
||||
E_CONFIG_DD_FREE (conf_item_edd);
|
||||
E_CONFIG_DD_FREE (conf_edd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
e_modapi_save (E_Module * m)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
|
@ -446,68 +485,75 @@ e_modapi_save(E_Module *m)
|
|||
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);
|
||||
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);
|
||||
e_config_domain_save ("module.mail", conf_edd, mail_config);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_about(E_Module *m)
|
||||
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."));
|
||||
e_module_dialog_show (m, D_ ("Enlightenment Mail Module"),
|
||||
D_
|
||||
("This is a module to notify when you have new mail."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Mail *
|
||||
_mail_new(Evas *evas)
|
||||
_mail_new (Evas * evas)
|
||||
{
|
||||
Mail *mail;
|
||||
char buf[4096];
|
||||
|
||||
mail = E_NEW(Mail, 1);
|
||||
mail->mail_obj = edje_object_add(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"))
|
||||
edje_object_file_set(mail->mail_obj, buf, "modules/mail/main");
|
||||
evas_object_show(mail->mail_obj);
|
||||
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);
|
||||
|
||||
return mail;
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_free(Mail *mail)
|
||||
_mail_free (Mail * mail)
|
||||
{
|
||||
evas_object_del(mail->mail_obj);
|
||||
free(mail);
|
||||
evas_object_del (mail->mail_obj);
|
||||
free (mail);
|
||||
mail = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_mail_cb_check(void *data)
|
||||
_mail_cb_check (void *data)
|
||||
{
|
||||
Instance *inst = data;
|
||||
Config_Item *ci;
|
||||
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;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if (!ci->boxes)
|
||||
return 1;
|
||||
|
||||
edje_object_signal_emit(inst->mail->mail_obj, "check_mail", "");
|
||||
edje_object_signal_emit (inst->mail->mail_obj, "check_mail", "");
|
||||
|
||||
for (l = ci->boxes; l; l = l->next)
|
||||
{
|
||||
Config_Box *cb;
|
||||
|
||||
cb = l->data;
|
||||
if (!cb) continue;
|
||||
if (!cb)
|
||||
continue;
|
||||
switch (cb->type)
|
||||
{
|
||||
case MAIL_TYPE_MDIR:
|
||||
|
@ -522,13 +568,15 @@ _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;
|
||||
}
|
||||
|
||||
void
|
||||
_mail_set_text(void *data)
|
||||
_mail_set_text (void *data)
|
||||
{
|
||||
Instance *inst = data;
|
||||
Config_Item *ci;
|
||||
|
@ -536,58 +584,64 @@ _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;
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
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;
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%d", count);
|
||||
edje_object_part_text_set(inst->mail->mail_obj, "new_label", buf);
|
||||
edje_object_signal_emit(inst->mail->mail_obj, "new_mail", "");
|
||||
snprintf (buf, sizeof (buf), "%d", count);
|
||||
edje_object_part_text_set (inst->mail->mail_obj, "new_label", buf);
|
||||
edje_object_signal_emit (inst->mail->mail_obj, "new_mail", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_signal_emit(inst->mail->mail_obj, "no_mail", "");
|
||||
edje_object_part_text_set(inst->mail->mail_obj, "new_label", "");
|
||||
edje_object_signal_emit (inst->mail->mail_obj, "no_mail", "");
|
||||
edje_object_part_text_set (inst->mail->mail_obj, "new_label", "");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_mail_start_exe(void *data)
|
||||
_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);
|
||||
cb->exe = ecore_exe_run(cb->exec, cb);
|
||||
exit_handler =
|
||||
ecore_event_handler_add (ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, cb);
|
||||
cb->exe = ecore_exe_run (cb->exec, cb);
|
||||
}
|
||||
|
||||
static int
|
||||
_mail_cb_exe_exit(void *data, int type, void *event)
|
||||
_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);
|
||||
ecore_event_handler_del (exit_handler);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_mail_box_added(const char *ci_name, const char *box_name)
|
||||
_mail_box_added (const char *ci_name, const char *box_name)
|
||||
{
|
||||
Evas_List *l, *b;
|
||||
|
||||
|
@ -597,29 +651,29 @@ _mail_box_added(const char *ci_name, const char *box_name)
|
|||
Config_Item *ci;
|
||||
|
||||
inst = l->data;
|
||||
ci = _mail_config_item_get(inst->gcc->id);
|
||||
if ((ci->id) && (!strcmp(ci->id, ci_name)))
|
||||
ci = _mail_config_item_get (inst->gcc->id);
|
||||
if ((ci->id) && (!strcmp (ci->id, ci_name)))
|
||||
{
|
||||
for (b = ci->boxes; b; b = b->next)
|
||||
{
|
||||
Config_Box *cb;
|
||||
|
||||
cb = b->data;
|
||||
if ((cb->name) && (!strcmp(cb->name, box_name)))
|
||||
if ((cb->name) && (!strcmp (cb->name, box_name)))
|
||||
{
|
||||
switch (cb->type)
|
||||
{
|
||||
case MAIL_TYPE_IMAP:
|
||||
_mail_imap_add_mailbox(cb);
|
||||
_mail_imap_add_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_POP:
|
||||
_mail_pop_add_mailbox(cb);
|
||||
_mail_pop_add_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_MDIR:
|
||||
_mail_mdir_add_mailbox(inst, cb);
|
||||
_mail_mdir_add_mailbox (inst, cb);
|
||||
break;
|
||||
case MAIL_TYPE_MBOX:
|
||||
_mail_mbox_add_mailbox(inst, cb);
|
||||
_mail_mbox_add_mailbox (inst, cb);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -631,7 +685,7 @@ _mail_box_added(const char *ci_name, const char *box_name)
|
|||
}
|
||||
|
||||
void
|
||||
_mail_box_deleted(const char *ci_name, const char *box_name)
|
||||
_mail_box_deleted (const char *ci_name, const char *box_name)
|
||||
{
|
||||
Evas_List *d, *i;
|
||||
Config_Box *cb;
|
||||
|
@ -642,18 +696,19 @@ _mail_box_deleted(const char *ci_name, const char *box_name)
|
|||
Instance *inst;
|
||||
|
||||
inst = i->data;
|
||||
if (!inst->gcc->id) continue;
|
||||
if (!strcmp(inst->gcc->id, ci_name))
|
||||
if (!inst->gcc->id)
|
||||
continue;
|
||||
if (!strcmp (inst->gcc->id, ci_name))
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = _mail_config_item_get(inst->gcc->id);
|
||||
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))
|
||||
if (!strcmp (cb->name, box_name))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
|
@ -665,20 +720,20 @@ _mail_box_deleted(const char *ci_name, const char *box_name)
|
|||
switch (cb->type)
|
||||
{
|
||||
case MAIL_TYPE_IMAP:
|
||||
_mail_imap_del_mailbox(cb);
|
||||
_mail_imap_del_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_POP:
|
||||
_mail_pop_del_mailbox(cb);
|
||||
_mail_pop_del_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_MDIR:
|
||||
_mail_mdir_del_mailbox(cb);
|
||||
_mail_mdir_del_mailbox (cb);
|
||||
break;
|
||||
case MAIL_TYPE_MBOX:
|
||||
_mail_mbox_del_mailbox(cb);
|
||||
_mail_mbox_del_mailbox (cb);
|
||||
break;
|
||||
}
|
||||
ci->boxes = evas_list_remove(ci->boxes, cb);
|
||||
e_config_save_queue();
|
||||
ci->boxes = evas_list_remove (ci->boxes, cb);
|
||||
e_config_save_queue ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -687,45 +742,51 @@ _mail_box_deleted(const char *ci_name, const char *box_name)
|
|||
}
|
||||
|
||||
void
|
||||
_mail_config_updated(const char *id)
|
||||
_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);
|
||||
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->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);
|
||||
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", "");
|
||||
edje_object_signal_emit (inst->mail_obj, "label_active", "");
|
||||
else
|
||||
edje_object_signal_emit(inst->mail_obj, "label_passive", "");
|
||||
edje_object_signal_emit (inst->mail_obj, "label_passive", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_mail_menu_cb_exec(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
_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);
|
||||
cb->exe = ecore_exe_run(cb->exec, cb);
|
||||
exit_handler =
|
||||
ecore_event_handler_add (ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, cb);
|
||||
cb->exe = ecore_exe_run (cb->exec, cb);
|
||||
}
|
||||
|
|
184
imap.c
184
imap.c
|
@ -2,17 +2,17 @@
|
|||
#include "e_mod_main.h"
|
||||
#include "imap.h"
|
||||
|
||||
static ImapServer *_mail_imap_server_get(Ecore_Con_Server *server);
|
||||
static ImapClient *_mail_imap_client_get(void *data);
|
||||
static int _mail_imap_server_add(void *data, int type, void *event);
|
||||
static int _mail_imap_server_del(void *data, int type, void *event);
|
||||
static int _mail_imap_server_data(void *data, int type, void *event);
|
||||
static void _mail_imap_server_logout(ImapServer *is);
|
||||
static ImapServer *_mail_imap_server_get (Ecore_Con_Server * server);
|
||||
static ImapClient *_mail_imap_client_get (void *data);
|
||||
static int _mail_imap_server_add (void *data, int type, void *event);
|
||||
static int _mail_imap_server_del (void *data, int type, void *event);
|
||||
static int _mail_imap_server_data (void *data, int type, void *event);
|
||||
static void _mail_imap_server_logout (ImapServer * is);
|
||||
|
||||
static Evas_List *iservers;
|
||||
|
||||
void
|
||||
_mail_imap_check_mail(void *data)
|
||||
_mail_imap_check_mail (void *data)
|
||||
{
|
||||
Ecore_Con_Type type = ECORE_CON_REMOTE_SYSTEM;
|
||||
Evas_List *l, *j;
|
||||
|
@ -27,78 +27,89 @@ _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)
|
||||
{
|
||||
ic = j->data;
|
||||
if (!ic->server->server)
|
||||
{
|
||||
if (ecore_con_ssl_available_get() && (ic->config->ssl))
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
is->current = evas_list_nth(is->clients, 0);
|
||||
is->current = evas_list_nth (is->clients, 0);
|
||||
ic = is->current;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_mail_imap_add_mailbox(void *data)
|
||||
_mail_imap_add_mailbox (void *data)
|
||||
{
|
||||
ImapClient *ic;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
ic = _mail_imap_client_get(cb);
|
||||
ic->server->clients = evas_list_append(ic->server->clients, ic);
|
||||
if (!cb)
|
||||
return;
|
||||
ic = _mail_imap_client_get (cb);
|
||||
ic->server->clients = evas_list_append (ic->server->clients, ic);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_imap_del_mailbox(void *data)
|
||||
_mail_imap_del_mailbox (void *data)
|
||||
{
|
||||
ImapClient *ic;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
ic = _mail_imap_client_get(cb);
|
||||
ic->server->clients = evas_list_remove(ic->server->clients, ic);
|
||||
if (!cb)
|
||||
return;
|
||||
ic = _mail_imap_client_get (cb);
|
||||
ic->server->clients = evas_list_remove (ic->server->clients, ic);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_imap_shutdown()
|
||||
_mail_imap_shutdown ()
|
||||
{
|
||||
if (!iservers) return;
|
||||
if (!iservers)
|
||||
return;
|
||||
while (iservers)
|
||||
{
|
||||
ImapServer *is;
|
||||
|
||||
is = iservers->data;
|
||||
if (is->add_handler)
|
||||
ecore_event_handler_del(is->add_handler);
|
||||
ecore_event_handler_del (is->add_handler);
|
||||
if (is->del_handler)
|
||||
ecore_event_handler_del(is->del_handler);
|
||||
ecore_event_handler_del (is->del_handler);
|
||||
if (is->data_handler)
|
||||
ecore_event_handler_del(is->data_handler);
|
||||
iservers = evas_list_remove_list(iservers, iservers);
|
||||
free(is);
|
||||
ecore_event_handler_del (is->data_handler);
|
||||
iservers = evas_list_remove_list (iservers, iservers);
|
||||
free (is);
|
||||
is = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* PRIVATES */
|
||||
static ImapServer *
|
||||
_mail_imap_server_get(Ecore_Con_Server *server)
|
||||
_mail_imap_server_get (Ecore_Con_Server * server)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
|
@ -114,7 +125,7 @@ _mail_imap_server_get(Ecore_Con_Server *server)
|
|||
}
|
||||
|
||||
static ImapClient *
|
||||
_mail_imap_client_get(void *data)
|
||||
_mail_imap_client_get (void *data)
|
||||
{
|
||||
ImapServer *is;
|
||||
ImapClient *ic;
|
||||
|
@ -123,38 +134,42 @@ _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))
|
||||
if ((!iservers) || (evas_list_count (iservers) <= 0))
|
||||
{
|
||||
is = E_NEW(ImapServer, 1);
|
||||
is = E_NEW (ImapServer, 1);
|
||||
is->server = NULL;
|
||||
is->cmd = 0;
|
||||
is->state = IMAP_STATE_DISCONNECTED;
|
||||
iservers = evas_list_append(iservers, is);
|
||||
iservers = evas_list_append (iservers, is);
|
||||
}
|
||||
|
||||
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 ((!strcmp(ic->config->host, cb->host)) &&
|
||||
(!strcmp(ic->config->user, cb->user)) &&
|
||||
(!strcmp(ic->config->pass, cb->pass)))
|
||||
if (!ic->config)
|
||||
continue;
|
||||
if ((!strcmp (ic->config->host, cb->host)) &&
|
||||
(!strcmp (ic->config->user, cb->user)) &&
|
||||
(!strcmp (ic->config->pass, cb->pass)))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
ic = E_NEW(ImapClient, 1);
|
||||
ic = E_NEW (ImapClient, 1);
|
||||
ic->config = cb;
|
||||
ic->server = is;
|
||||
ic->config->num_new = 0;
|
||||
|
@ -164,13 +179,14 @@ _mail_imap_client_get(void *data)
|
|||
}
|
||||
|
||||
static int
|
||||
_mail_imap_server_add(void *data, int type, void *event)
|
||||
_mail_imap_server_add (void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Con_Event_Server_Add *ev = event;
|
||||
ImapServer *is;
|
||||
|
||||
is = _mail_imap_server_get(ev->server);
|
||||
if (!is) return 1;
|
||||
is = _mail_imap_server_get (ev->server);
|
||||
if (!is)
|
||||
return 1;
|
||||
|
||||
is->state = IMAP_STATE_CONNECTED;
|
||||
is->cmd = 0;
|
||||
|
@ -178,28 +194,29 @@ _mail_imap_server_add(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static int
|
||||
_mail_imap_server_del(void *data, int type, void *event)
|
||||
_mail_imap_server_del (void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Con_Event_Server_Del *ev = event;
|
||||
ImapServer *is;
|
||||
|
||||
is = _mail_imap_server_get(ev->server);
|
||||
if (!is) return 1;
|
||||
is = _mail_imap_server_get (ev->server);
|
||||
if (!is)
|
||||
return 1;
|
||||
|
||||
if (is->state == IMAP_STATE_DISCONNECTED)
|
||||
printf("Imap Server Disconnected\n");
|
||||
printf ("Imap Server Disconnected\n");
|
||||
else
|
||||
is->state = IMAP_STATE_DISCONNECTED;
|
||||
|
||||
ecore_con_server_del(is->server);
|
||||
ecore_con_server_del (is->server);
|
||||
is->server = NULL;
|
||||
|
||||
_mail_set_text(is->data);
|
||||
_mail_set_text (is->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_mail_imap_server_data(void *data, int type, void *event)
|
||||
_mail_imap_server_data (void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Con_Event_Server_Data *ev = event;
|
||||
ImapServer *is;
|
||||
|
@ -208,29 +225,31 @@ _mail_imap_server_data(void *data, int type, void *event)
|
|||
char in[1024], out[1024], *spc;
|
||||
size_t slen;
|
||||
|
||||
is = _mail_imap_server_get(ev->server);
|
||||
if (!is) return 1;
|
||||
if (is->state == IMAP_STATE_DISCONNECTED) return 1;
|
||||
is = _mail_imap_server_get (ev->server);
|
||||
if (!is)
|
||||
return 1;
|
||||
if (is->state == IMAP_STATE_DISCONNECTED)
|
||||
return 1;
|
||||
|
||||
len = sizeof(in) - 1;
|
||||
len = sizeof (in) - 1;
|
||||
len = (len > ev->size) ? (ev->size) : (len);
|
||||
|
||||
memcpy(in, ev->data, len);
|
||||
memcpy (in, ev->data, len);
|
||||
in[len] = 0;
|
||||
|
||||
if ((spc = strchr(in, ' ')))
|
||||
if ((spc = strchr (in, ' ')))
|
||||
{
|
||||
slen = strlen(spc);
|
||||
if ((slen > 5) && (!strncmp(spc + 1, "NO ", 3)))
|
||||
slen = strlen (spc);
|
||||
if ((slen > 5) && (!strncmp (spc + 1, "NO ", 3)))
|
||||
{
|
||||
_mail_imap_server_logout(is);
|
||||
printf("Imap Failure: %s\n", spc + 4);
|
||||
_mail_imap_server_logout (is);
|
||||
printf ("Imap Failure: %s\n", spc + 4);
|
||||
return 0;
|
||||
}
|
||||
else if ((slen > 6) && (!strncmp(spc + 1, "BAD ", 4)))
|
||||
else if ((slen > 6) && (!strncmp (spc + 1, "BAD ", 4)))
|
||||
{
|
||||
_mail_imap_server_logout(is);
|
||||
printf("Imap Bad Command: %s\n", spc + 5);
|
||||
_mail_imap_server_logout (is);
|
||||
printf ("Imap Bad Command: %s\n", spc + 5);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -241,22 +260,27 @@ _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);
|
||||
ecore_con_server_send(ev->server, out, len);
|
||||
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);
|
||||
ecore_con_server_send(ev->server, out, len);
|
||||
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;
|
||||
_mail_set_text(is->data);
|
||||
_mail_set_text (is->data);
|
||||
|
||||
if ((num > 0) && (ic->config->use_exec) && (ic->config->exec))
|
||||
_mail_start_exe(ic->config);
|
||||
_mail_start_exe (ic->config);
|
||||
|
||||
is->clients = is->clients->next;
|
||||
if (is->clients)
|
||||
|
@ -269,17 +293,18 @@ _mail_imap_server_data(void *data, int type, void *event)
|
|||
}
|
||||
else
|
||||
{
|
||||
_mail_imap_server_logout(is);
|
||||
_mail_imap_server_logout (is);
|
||||
ic = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_mail_imap_server_logout(is);
|
||||
_mail_imap_server_logout (is);
|
||||
ic = NULL;
|
||||
}
|
||||
}
|
||||
if (!ic) break;
|
||||
if (!ic)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -287,19 +312,20 @@ _mail_imap_server_data(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static void
|
||||
_mail_imap_server_logout(ImapServer *is)
|
||||
_mail_imap_server_logout (ImapServer * is)
|
||||
{
|
||||
int len;
|
||||
char out[1024];
|
||||
|
||||
if (!is) return;
|
||||
if (!is)
|
||||
return;
|
||||
|
||||
if (is->state >= IMAP_STATE_LOGGED_IN)
|
||||
{
|
||||
len = snprintf(out, sizeof(out), "A%03i LOGOUT", ++is->cmd);
|
||||
ecore_con_server_send(is->server, out, len);
|
||||
len = snprintf (out, sizeof (out), "A%03i LOGOUT", ++is->cmd);
|
||||
ecore_con_server_send (is->server, out, len);
|
||||
}
|
||||
ecore_con_server_del(is->server);
|
||||
ecore_con_server_del (is->server);
|
||||
is->server = NULL;
|
||||
is->state = IMAP_STATE_DISCONNECTED;
|
||||
}
|
||||
|
|
73
mbox.c
73
mbox.c
|
@ -4,71 +4,79 @@
|
|||
|
||||
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)
|
||||
_mail_mbox_add_mailbox (void *data, void *data2)
|
||||
{
|
||||
MboxClient *mb;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = data2;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
mb = E_NEW(MboxClient, 1);
|
||||
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);
|
||||
mboxes = evas_list_append (mboxes, mb);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_mbox_del_mailbox(void *data)
|
||||
_mail_mbox_del_mailbox (void *data)
|
||||
{
|
||||
Config_Box *cb;
|
||||
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);
|
||||
free(mb);
|
||||
ecore_file_monitor_del (mb->monitor);
|
||||
mboxes = evas_list_remove (mboxes, mb);
|
||||
free (mb);
|
||||
mb = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_mail_mbox_shutdown()
|
||||
_mail_mbox_shutdown ()
|
||||
{
|
||||
if (!mboxes) return;
|
||||
if (!mboxes)
|
||||
return;
|
||||
while (mboxes)
|
||||
{
|
||||
MboxClient *mb;
|
||||
|
||||
mb = mboxes->data;
|
||||
if (mb->monitor)
|
||||
ecore_file_monitor_del(mb->monitor);
|
||||
mboxes = evas_list_remove_list(mboxes, mboxes);
|
||||
free(mb);
|
||||
ecore_file_monitor_del (mb->monitor);
|
||||
mboxes = evas_list_remove_list (mboxes, mboxes);
|
||||
free (mb);
|
||||
mb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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,34 +85,39 @@ _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")))
|
||||
if (!(f = fopen (cb->new_path, "r")))
|
||||
return;
|
||||
|
||||
mb->config->num_new = 0;
|
||||
mb->config->num_total = 0;
|
||||
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
while (fgets (buf, sizeof (buf), f))
|
||||
{
|
||||
if (buf[0] == '\n')
|
||||
header = 0;
|
||||
else if (!strncmp(buf, "From ", 5))
|
||||
else if (!strncmp (buf, "From ", 5))
|
||||
{
|
||||
header = 1;
|
||||
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);
|
||||
fclose (f);
|
||||
|
||||
_mail_set_text(mb->data);
|
||||
if ((mb->config->num_new > 0) && (mb->config->use_exec) && (mb->config->exec))
|
||||
_mail_start_exe(mb->config);
|
||||
_mail_set_text (mb->data);
|
||||
if ((mb->config->num_new > 0) && (mb->config->use_exec)
|
||||
&& (mb->config->exec))
|
||||
_mail_start_exe (mb->config);
|
||||
}
|
||||
|
|
73
mdir.c
73
mdir.c
|
@ -4,98 +4,109 @@
|
|||
|
||||
static Evas_List *mdirs;
|
||||
|
||||
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);
|
||||
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
|
||||
_mail_mdir_add_mailbox(void *data, void *data2)
|
||||
_mail_mdir_add_mailbox (void *data, void *data2)
|
||||
{
|
||||
MdirClient *mc;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = data2;
|
||||
if (!cb) return;
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
mc = E_NEW(MdirClient, 1);
|
||||
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);
|
||||
mdirs = evas_list_append (mdirs, mc);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_mdir_del_mailbox(void *data)
|
||||
_mail_mdir_del_mailbox (void *data)
|
||||
{
|
||||
Config_Box *cb;
|
||||
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;
|
||||
mdirs = evas_list_remove(mdirs, mc);
|
||||
free(mc);
|
||||
if (!mc)
|
||||
continue;
|
||||
if (mc->config != cb)
|
||||
continue;
|
||||
mdirs = evas_list_remove (mdirs, mc);
|
||||
free (mc);
|
||||
mc = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_mail_mdir_shutdown()
|
||||
_mail_mdir_shutdown ()
|
||||
{
|
||||
if (!mdirs) return;
|
||||
if (!mdirs)
|
||||
return;
|
||||
while (mdirs)
|
||||
{
|
||||
MdirClient *mc;
|
||||
|
||||
mc = mdirs->data;
|
||||
if (mc->monitor)
|
||||
ecore_file_monitor_del(mc->monitor);
|
||||
mdirs = evas_list_remove_list(mdirs, mdirs);
|
||||
free(mc);
|
||||
ecore_file_monitor_del (mc->monitor);
|
||||
mdirs = evas_list_remove_list (mdirs, mdirs);
|
||||
free (mc);
|
||||
mc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
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))
|
||||
_mail_start_exe(mc->config);
|
||||
_mail_set_text (mc->data);
|
||||
if ((mc->config->num_new > 0) && (mc->config->use_exec)
|
||||
&& (mc->config->exec))
|
||||
_mail_start_exe (mc->config);
|
||||
}
|
||||
|
||||
static int
|
||||
_mail_mdir_get_files(const char *path)
|
||||
_mail_mdir_get_files (const char *path)
|
||||
{
|
||||
Ecore_List *l;
|
||||
char *item;
|
||||
int i = 0;
|
||||
|
||||
l = ecore_file_ls(path);
|
||||
ecore_list_goto_first(l);
|
||||
while ((item = (char *)ecore_list_next(l)) != NULL)
|
||||
l = ecore_file_ls (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);
|
||||
ecore_list_destroy (l);
|
||||
return i;
|
||||
}
|
||||
|
|
217
pop.c
217
pop.c
|
@ -2,135 +2,151 @@
|
|||
#include "e_mod_main.h"
|
||||
#include "pop.h"
|
||||
|
||||
static int _mail_pop_server_add(void *data, int type, void *event);
|
||||
static int _mail_pop_server_del(void *data, int type, void *event);
|
||||
static int _mail_pop_server_data(void *data, int type, void *event);
|
||||
static PopClient *_mail_pop_client_get(void *data);
|
||||
static PopClient *_mail_pop_client_get_from_server(void *data);
|
||||
static void _mail_pop_client_quit(void *data);
|
||||
static int _mail_pop_server_add (void *data, int type, void *event);
|
||||
static int _mail_pop_server_del (void *data, int type, void *event);
|
||||
static int _mail_pop_server_data (void *data, int type, void *event);
|
||||
static PopClient *_mail_pop_client_get (void *data);
|
||||
static PopClient *_mail_pop_client_get_from_server (void *data);
|
||||
static void _mail_pop_client_quit (void *data);
|
||||
|
||||
static Evas_List *pclients;
|
||||
|
||||
void
|
||||
_mail_pop_check_mail(void *data)
|
||||
_mail_pop_check_mail (void *data)
|
||||
{
|
||||
Ecore_Con_Type type = ECORE_CON_REMOTE_SYSTEM;
|
||||
Evas_List *l;
|
||||
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))
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_mail_pop_add_mailbox(void *data)
|
||||
_mail_pop_add_mailbox (void *data)
|
||||
{
|
||||
PopClient *pc;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
pc = _mail_pop_client_get(cb);
|
||||
if (!cb)
|
||||
return;
|
||||
pc = _mail_pop_client_get (cb);
|
||||
pc->config->num_new = 0;
|
||||
pc->config->num_total = 0;
|
||||
pclients = evas_list_append(pclients, pc);
|
||||
pclients = evas_list_append (pclients, pc);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_pop_del_mailbox(void *data)
|
||||
_mail_pop_del_mailbox (void *data)
|
||||
{
|
||||
PopClient *pc;
|
||||
Config_Box *cb;
|
||||
|
||||
cb = data;
|
||||
if (!cb) return;
|
||||
pc = _mail_pop_client_get(cb);
|
||||
if (!cb)
|
||||
return;
|
||||
pc = _mail_pop_client_get (cb);
|
||||
if (pc->server)
|
||||
_mail_pop_client_quit(pc);
|
||||
_mail_pop_client_quit (pc);
|
||||
if (pc->add_handler)
|
||||
ecore_event_handler_del(pc->add_handler);
|
||||
ecore_event_handler_del (pc->add_handler);
|
||||
if (pc->del_handler)
|
||||
ecore_event_handler_del(pc->del_handler);
|
||||
ecore_event_handler_del (pc->del_handler);
|
||||
if (pc->data_handler)
|
||||
ecore_event_handler_del(pc->data_handler);
|
||||
pclients = evas_list_remove(pclients, pc);
|
||||
ecore_event_handler_del (pc->data_handler);
|
||||
pclients = evas_list_remove (pclients, pc);
|
||||
}
|
||||
|
||||
void
|
||||
_mail_pop_shutdown()
|
||||
_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);
|
||||
_mail_pop_client_quit (pc);
|
||||
if (pc->add_handler)
|
||||
ecore_event_handler_del(pc->add_handler);
|
||||
ecore_event_handler_del (pc->add_handler);
|
||||
if (pc->del_handler)
|
||||
ecore_event_handler_del(pc->del_handler);
|
||||
ecore_event_handler_del (pc->del_handler);
|
||||
if (pc->data_handler)
|
||||
ecore_event_handler_del(pc->data_handler);
|
||||
pclients = evas_list_remove_list(pclients, pclients);
|
||||
free(pc);
|
||||
ecore_event_handler_del (pc->data_handler);
|
||||
pclients = evas_list_remove_list (pclients, pclients);
|
||||
free (pc);
|
||||
pc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* PRIVATES */
|
||||
static int
|
||||
_mail_pop_server_add(void *data, int type, void *event)
|
||||
_mail_pop_server_add (void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Con_Event_Server_Add *ev = event;
|
||||
PopClient *pc;
|
||||
|
||||
pc = _mail_pop_client_get_from_server(ev->server);
|
||||
if (!pc) return 1;
|
||||
pc = _mail_pop_client_get_from_server (ev->server);
|
||||
if (!pc)
|
||||
return 1;
|
||||
|
||||
pc->state = POP_STATE_CONNECTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_mail_pop_server_del(void *data, int type, void *event)
|
||||
_mail_pop_server_del (void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Con_Event_Server_Del *ev = event;
|
||||
PopClient *pc;
|
||||
|
||||
pc = _mail_pop_client_get_from_server(ev->server);
|
||||
if (!pc) return 1;
|
||||
pc = _mail_pop_client_get_from_server (ev->server);
|
||||
if (!pc)
|
||||
return 1;
|
||||
|
||||
if (pc->state == POP_STATE_DISCONNECTED)
|
||||
printf("Pop Server Disconnected\n");
|
||||
printf ("Pop Server Disconnected\n");
|
||||
|
||||
ecore_con_server_del(ev->server);
|
||||
ecore_con_server_del (ev->server);
|
||||
pc->server = NULL;
|
||||
pc->state = POP_STATE_DISCONNECTED;
|
||||
|
||||
|
@ -138,32 +154,34 @@ _mail_pop_server_del(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static int
|
||||
_mail_pop_server_data(void *data, int type, void *event)
|
||||
_mail_pop_server_data (void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Con_Event_Server_Data *ev = event;
|
||||
PopClient *pc;
|
||||
char in[2048], out[2048];
|
||||
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;
|
||||
pc = _mail_pop_client_get_from_server (ev->server);
|
||||
if (!pc)
|
||||
return 1;
|
||||
if (pc->state == POP_STATE_DISCONNECTED)
|
||||
return 1;
|
||||
|
||||
len = sizeof(in) -1;
|
||||
len = sizeof (in) - 1;
|
||||
len = (((len) > (ev->size)) ? ev->size : len);
|
||||
memcpy(in, ev->data, len);
|
||||
memcpy (in, ev->data, len);
|
||||
in[len] = 0;
|
||||
|
||||
if (!strncmp(in, "-ERR", 4))
|
||||
if (!strncmp (in, "-ERR", 4))
|
||||
{
|
||||
printf("ERROR: %s\n", in);
|
||||
_mail_pop_client_quit(pc);
|
||||
printf ("ERROR: %s\n", in);
|
||||
_mail_pop_client_quit (pc);
|
||||
return 0;
|
||||
}
|
||||
else if (strncmp(in, "+OK", 3))
|
||||
else if (strncmp (in, "+OK", 3))
|
||||
{
|
||||
printf("Unexpected reply: %s\n", in);
|
||||
_mail_pop_client_quit(pc);
|
||||
printf ("Unexpected reply: %s\n", in);
|
||||
_mail_pop_client_quit (pc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -171,26 +189,26 @@ _mail_pop_server_data(void *data, int type, void *event)
|
|||
switch (pc->state)
|
||||
{
|
||||
case POP_STATE_SERVER_READY:
|
||||
len = snprintf(out, sizeof(out), "USER %s\r\n", pc->config->user);
|
||||
ecore_con_server_send(ev->server, out, len);
|
||||
len = snprintf (out, sizeof (out), "USER %s\r\n", pc->config->user);
|
||||
ecore_con_server_send (ev->server, out, len);
|
||||
break;
|
||||
case POP_STATE_USER_OK:
|
||||
len = snprintf(out, sizeof(out), "PASS %s\r\n", pc->config->pass);
|
||||
ecore_con_server_send(ev->server, out, len);
|
||||
len = snprintf (out, sizeof (out), "PASS %s\r\n", pc->config->pass);
|
||||
ecore_con_server_send (ev->server, out, len);
|
||||
break;
|
||||
case POP_STATE_PASS_OK:
|
||||
len = snprintf(out, sizeof(out), "STAT\r\n");
|
||||
ecore_con_server_send(ev->server, out, len);
|
||||
len = snprintf (out, sizeof (out), "STAT\r\n");
|
||||
ecore_con_server_send (ev->server, out, len);
|
||||
break;
|
||||
case POP_STATE_STATUS_OK:
|
||||
if (sscanf(in, "+OK %i %i", &num, &total) == 2)
|
||||
if (sscanf (in, "+OK %i %i", &num, &total) == 2)
|
||||
{
|
||||
pc->config->num_new = num;
|
||||
pc->config->num_total = num;
|
||||
}
|
||||
_mail_pop_client_quit(pc);
|
||||
_mail_pop_client_quit (pc);
|
||||
if ((num > 0) && (pc->config->use_exec) && (pc->config->exec))
|
||||
_mail_start_exe(pc->config);
|
||||
_mail_start_exe (pc->config);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -199,7 +217,7 @@ _mail_pop_server_data(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static PopClient *
|
||||
_mail_pop_client_get(void *data)
|
||||
_mail_pop_client_get (void *data)
|
||||
{
|
||||
PopClient *pc;
|
||||
Evas_List *l;
|
||||
|
@ -207,30 +225,39 @@ _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))
|
||||
if ((!pclients) || (evas_list_count (pclients) <= 0))
|
||||
{
|
||||
pc = E_NEW(PopClient, 1);
|
||||
pc = E_NEW (PopClient, 1);
|
||||
pc->server = NULL;
|
||||
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 ((!strcmp(pc->config->host, cb->host)) &&
|
||||
(!strcmp(pc->config->user, cb->user)) &&
|
||||
(!strcmp(pc->config->pass, cb->pass)))
|
||||
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)))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
|
@ -238,34 +265,43 @@ _mail_pop_client_get(void *data)
|
|||
}
|
||||
if (!found)
|
||||
{
|
||||
pc = E_NEW(PopClient, 1);
|
||||
pc = E_NEW (PopClient, 1);
|
||||
pc->server = NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
static PopClient *
|
||||
_mail_pop_client_get_from_server(void *data)
|
||||
_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;
|
||||
}
|
||||
|
@ -273,22 +309,23 @@ _mail_pop_client_get_from_server(void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
_mail_pop_client_quit(void *data)
|
||||
_mail_pop_client_quit (void *data)
|
||||
{
|
||||
PopClient *pc;
|
||||
int len;
|
||||
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");
|
||||
ecore_con_server_send(pc->server, out, len);
|
||||
len = snprintf (out, sizeof (out), "QUIT\r\n");
|
||||
ecore_con_server_send (pc->server, out, len);
|
||||
}
|
||||
ecore_con_server_del(pc->server);
|
||||
ecore_con_server_del (pc->server);
|
||||
pc->server = NULL;
|
||||
pc->state = POP_STATE_DISCONNECTED;
|
||||
|
||||
_mail_set_text(pc->data);
|
||||
_mail_set_text (pc->data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue