Too many conflicts during merge. Will readd the updated files.
SVN revision: 23309
This commit is contained in:
parent
81fde6e7a3
commit
1ea125de22
|
@ -20,7 +20,9 @@ pkgdir = $(datadir)/$(MODULE_ARCH)
|
||||||
pkg_LTLIBRARIES = module.la
|
pkg_LTLIBRARIES = module.la
|
||||||
module_la_SOURCES = e_mod_main.c \
|
module_la_SOURCES = e_mod_main.c \
|
||||||
e_mod_main.h \
|
e_mod_main.h \
|
||||||
e_mod_config.c
|
e_mod_config.c \
|
||||||
|
e_mod_config_box.h \
|
||||||
|
e_mod_config_box.c
|
||||||
|
|
||||||
module_la_LIBADD = @e_libs@ -lm
|
module_la_LIBADD = @e_libs@ -lm
|
||||||
module_la_LDFLAGS = -module -avoid-version
|
module_la_LDFLAGS = -module -avoid-version
|
||||||
|
|
|
@ -3,39 +3,39 @@
|
||||||
|
|
||||||
struct _E_Config_Dialog_Data
|
struct _E_Config_Dialog_Data
|
||||||
{
|
{
|
||||||
int show_label;
|
char *name;
|
||||||
int use_exec;
|
|
||||||
int use_ssl;
|
|
||||||
int type;
|
int type;
|
||||||
double check_time;
|
int use_exec;
|
||||||
|
char *port;
|
||||||
char *exec;
|
int ssl;
|
||||||
char *host;
|
char *host;
|
||||||
char *user;
|
char *user;
|
||||||
char *pass;
|
char *pass;
|
||||||
char *path;
|
char *new_path;
|
||||||
char *path_current;
|
char *cur_path;
|
||||||
char *port;
|
char *exec;
|
||||||
|
|
||||||
|
/* Evas_Object References */
|
||||||
|
Evas_Object *exec_label;
|
||||||
|
Evas_Object *exec_entry;
|
||||||
|
Evas_Object *port_entry;
|
||||||
Evas_Object *new_path_label;
|
Evas_Object *new_path_label;
|
||||||
Evas_Object *new_path_entry;
|
Evas_Object *new_path_entry;
|
||||||
Evas_Object *cur_path_label;
|
Evas_Object *cur_path_label;
|
||||||
Evas_Object *cur_path_entry;
|
Evas_Object *cur_path_entry;
|
||||||
|
|
||||||
Evas_Object *exec_label;
|
|
||||||
Evas_Object *exec_entry;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *_create_data(E_Config_Dialog *cfd);
|
static void *_create_data(E_Config_Dialog *cfd);
|
||||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
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 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 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 _use_exec_cb_change(void *data, Evas_Object *obj);
|
||||||
static void _mail_type_cb_change(void *data, Evas_Object *obj);
|
|
||||||
|
|
||||||
void
|
static E_Config_Dialog *prev_dlg;
|
||||||
_config_mail_module(Config_Item *ci)
|
|
||||||
|
void
|
||||||
|
_config_box(Config_Item *ci, Config_Box *cb, E_Config_Dialog *mcfd)
|
||||||
{
|
{
|
||||||
E_Config_Dialog *cfd;
|
E_Config_Dialog *cfd;
|
||||||
E_Config_Dialog_View *v;
|
E_Config_Dialog_View *v;
|
||||||
|
@ -43,6 +43,18 @@ _config_mail_module(Config_Item *ci)
|
||||||
|
|
||||||
v = E_NEW(E_Config_Dialog_View, 1);
|
v = E_NEW(E_Config_Dialog_View, 1);
|
||||||
if (!v) return;
|
if (!v) return;
|
||||||
|
|
||||||
|
prev_dlg = mcfd;
|
||||||
|
|
||||||
|
if (!cb)
|
||||||
|
{
|
||||||
|
cb = E_NEW(Config_Box, 1);
|
||||||
|
cb->type = 0;
|
||||||
|
cb->port = 110;
|
||||||
|
cb->ssl = 0;
|
||||||
|
ci->boxes = evas_list_append(ci->boxes, cb);
|
||||||
|
e_config_save_queue();
|
||||||
|
}
|
||||||
|
|
||||||
v->create_cfdata = _create_data;
|
v->create_cfdata = _create_data;
|
||||||
v->free_cfdata = _free_data;
|
v->free_cfdata = _free_data;
|
||||||
|
@ -50,63 +62,53 @@ _config_mail_module(Config_Item *ci)
|
||||||
v->basic.create_widgets = _basic_create_widgets;
|
v->basic.create_widgets = _basic_create_widgets;
|
||||||
|
|
||||||
con = e_container_current_get(e_manager_current_get());
|
con = e_container_current_get(e_manager_current_get());
|
||||||
cfd = e_config_dialog_new(con, _("Mail Configuration"), NULL, 0, v, ci);
|
cfd = e_config_dialog_new(con, _("Mailbox Configuration"), NULL, 0, v, cb);
|
||||||
mail_config->config_dialog = cfd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
|
_fill_data(Config_Box *cb, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
cfdata->host = NULL;
|
if (cb->name)
|
||||||
cfdata->user = NULL;
|
cfdata->name = strdup(cb->name);
|
||||||
cfdata->pass = NULL;
|
|
||||||
cfdata->exec = NULL;
|
|
||||||
cfdata->path = NULL;
|
|
||||||
cfdata->path_current = NULL;
|
|
||||||
cfdata->port = NULL;
|
|
||||||
|
|
||||||
if (ci->host)
|
|
||||||
cfdata->host = strdup(ci->host);
|
|
||||||
if (ci->user)
|
|
||||||
cfdata->user = strdup(ci->user);
|
|
||||||
if (ci->pass)
|
|
||||||
cfdata->pass = strdup(ci->pass);
|
|
||||||
if (ci->exec)
|
|
||||||
cfdata->exec = strdup(ci->exec);
|
|
||||||
if (ci->path)
|
|
||||||
cfdata->path = strdup(ci->path);
|
|
||||||
if (ci->path_current)
|
|
||||||
cfdata->path_current = strdup(ci->path_current);
|
|
||||||
|
|
||||||
cfdata->show_label = ci->show_label;
|
cfdata->type = cb->type;
|
||||||
cfdata->type = ci->type;
|
cfdata->ssl = cb->ssl;
|
||||||
cfdata->use_exec = ci->use_exec;
|
cfdata->use_exec = cb->use_exec;
|
||||||
cfdata->check_time = ci->check_time;
|
|
||||||
cfdata->use_ssl = ci->use_ssl;
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%d", ci->port);
|
snprintf(buf, sizeof(buf), "%d", cb->port);
|
||||||
cfdata->port = strdup(buf);
|
cfdata->port = strdup(buf);
|
||||||
|
|
||||||
|
if (cb->exec)
|
||||||
|
cfdata->exec = strdup(cb->exec);
|
||||||
|
if (cb->host)
|
||||||
|
cfdata->host = strdup(cb->host);
|
||||||
|
if (cb->user)
|
||||||
|
cfdata->user = strdup(cb->user);
|
||||||
|
if (cb->pass)
|
||||||
|
cfdata->pass = strdup(cb->pass);
|
||||||
|
if (cb->new_path)
|
||||||
|
cfdata->new_path = strdup(cb->new_path);
|
||||||
|
if (cb->cur_path)
|
||||||
|
cfdata->cur_path = strdup(cb->cur_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
_create_data(E_Config_Dialog *cfd)
|
_create_data(E_Config_Dialog *cfd)
|
||||||
{
|
{
|
||||||
E_Config_Dialog_Data *cfdata;
|
E_Config_Dialog_Data *cfdata;
|
||||||
Config_Item *ci;
|
Config_Box *cb;
|
||||||
|
|
||||||
ci = cfd->data;
|
cb = cfd->data;
|
||||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
_fill_data(ci, cfdata);
|
_fill_data(cb, cfdata);
|
||||||
return cfdata;
|
return cfdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
|
||||||
mail_config->config_dialog = NULL;
|
|
||||||
free(cfdata);
|
free(cfdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,18 +120,11 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
|
|
||||||
o = e_widget_list_add(evas, 0, 0);
|
o = e_widget_list_add(evas, 0, 0);
|
||||||
of = e_widget_framelist_add(evas, _("General Settings"), 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);
|
|
||||||
ob = e_widget_check_add(evas, _("Start Program When New Mail Arrives"), &(cfdata->use_exec));
|
ob = e_widget_check_add(evas, _("Start Program When New Mail Arrives"), &(cfdata->use_exec));
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
e_widget_on_change_hook_set(ob, _use_exec_cb_change, cfdata);
|
e_widget_on_change_hook_set(ob, _use_exec_cb_change, cfdata);
|
||||||
|
|
||||||
ot = e_widget_table_add(evas, 1);
|
ot = e_widget_table_add(evas, 1);
|
||||||
cfdata->exec_label = e_widget_label_add(evas, _("Mail Program:"));
|
cfdata->exec_label = e_widget_label_add(evas, _("Program:"));
|
||||||
e_widget_table_object_append(ot, cfdata->exec_label, 0, 0, 1, 1, 0, 0, 1, 0);
|
e_widget_table_object_append(ot, cfdata->exec_label, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||||
cfdata->exec_entry = e_widget_entry_add(evas, &cfdata->exec);
|
cfdata->exec_entry = e_widget_entry_add(evas, &cfdata->exec);
|
||||||
e_widget_table_object_append(ot, cfdata->exec_entry, 1, 0, 1, 1, 0, 0, 1, 0);
|
e_widget_table_object_append(ot, cfdata->exec_entry, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||||
|
@ -142,49 +137,58 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
of = e_widget_framelist_add(evas, _("Mailbox Type"), 0);
|
of = e_widget_framelist_add(evas, _("Mailbox Type"), 0);
|
||||||
rg = e_widget_radio_group_new(&(cfdata->type));
|
rg = e_widget_radio_group_new(&(cfdata->type));
|
||||||
ob = e_widget_radio_add(evas, _("Pop3"), 0, rg);
|
ob = e_widget_radio_add(evas, _("Pop3"), 0, rg);
|
||||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata);
|
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
ob = e_widget_radio_add(evas, _("Imap"), 1, rg);
|
ob = e_widget_radio_add(evas, _("Imap"), 1, rg);
|
||||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata);
|
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
ob = e_widget_radio_add(evas, _("Maildir"), 2, rg);
|
ob = e_widget_radio_add(evas, _("Maildir"), 2, rg);
|
||||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata);
|
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
ob = e_widget_radio_add(evas, _("Mbox"), 3, rg);
|
ob = e_widget_radio_add(evas, _("Mbox"), 3, rg);
|
||||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata);
|
e_widget_on_change_hook_set(ob, _type_cb_change, cfdata);
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||||
|
|
||||||
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, _("Mailbox Settings"), 1);
|
|
||||||
ob = e_widget_label_add(evas, _("Port:"));
|
ob = e_widget_label_add(evas, _("Port:"));
|
||||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 0, 0, 1, 0);
|
||||||
ob = e_widget_entry_add(evas, &cfdata->port);
|
ob = e_widget_entry_add(evas, &cfdata->port);
|
||||||
|
cfdata->port_entry = ob;
|
||||||
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 0, 0, 1, 0);
|
||||||
|
|
||||||
ob = e_widget_check_add(evas, _("Use SSL"), &(cfdata->use_ssl));
|
ob = e_widget_label_add(evas, _("Use SSL:"));
|
||||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
||||||
|
ob = e_widget_check_add(evas, _(""), &(cfdata->ssl));
|
||||||
|
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);
|
||||||
|
|
||||||
ob = e_widget_label_add(evas, _("Mail Host:"));
|
ob = e_widget_label_add(evas, _("Mail Host:"));
|
||||||
e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 0, 0, 1, 0);
|
||||||
ob = e_widget_entry_add(evas, &cfdata->host);
|
ob = e_widget_entry_add(evas, &cfdata->host);
|
||||||
e_widget_frametable_object_append(of, ob, 1, 3, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 0, 0, 1, 0);
|
||||||
|
|
||||||
ob = e_widget_label_add(evas, _("Username:"));
|
ob = e_widget_label_add(evas, _("Username:"));
|
||||||
e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 0, 0, 1, 0);
|
||||||
ob = e_widget_entry_add(evas, &cfdata->user);
|
ob = e_widget_entry_add(evas, &cfdata->user);
|
||||||
e_widget_frametable_object_append(of, ob, 1, 4, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 1, 2, 1, 1, 0, 0, 1, 0);
|
||||||
|
|
||||||
ob = e_widget_label_add(evas, _("Password:"));
|
ob = e_widget_label_add(evas, _("Password:"));
|
||||||
e_widget_frametable_object_append(of, ob, 0, 5, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 0, 0, 1, 0);
|
||||||
ob = e_widget_entry_add(evas, &cfdata->pass);
|
ob = e_widget_entry_add(evas, &cfdata->pass);
|
||||||
e_widget_entry_password_set(ob, 1);
|
e_widget_entry_password_set(ob, 1);
|
||||||
e_widget_frametable_object_append(of, ob, 1, 5, 1, 1, 0, 0, 1, 0);
|
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:"));
|
cfdata->new_path_label = e_widget_label_add(evas, _("New Mail Path:"));
|
||||||
e_widget_frametable_object_append(of, cfdata->new_path_label, 0, 6, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, cfdata->new_path_label, 0, 4, 1, 1, 0, 0, 1, 0);
|
||||||
cfdata->new_path_entry = e_widget_entry_add(evas, &cfdata->path);
|
cfdata->new_path_entry = e_widget_entry_add(evas, &cfdata->new_path);
|
||||||
e_widget_frametable_object_append(of, cfdata->new_path_entry, 1, 6, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, cfdata->new_path_entry, 1, 4, 1, 1, 0, 0, 1, 0);
|
||||||
if (cfdata->type == 0)
|
if (cfdata->type == 0)
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->new_path_label, 1);
|
e_widget_disabled_set(cfdata->new_path_label, 1);
|
||||||
|
@ -192,9 +196,9 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdata->cur_path_label = e_widget_label_add(evas, _("Current Mail Path:"));
|
cfdata->cur_path_label = e_widget_label_add(evas, _("Current Mail Path:"));
|
||||||
e_widget_frametable_object_append(of, cfdata->cur_path_label, 0, 7, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, cfdata->cur_path_label, 0, 5, 1, 1, 0, 0, 1, 0);
|
||||||
cfdata->cur_path_entry = e_widget_entry_add(evas, &cfdata->path_current);
|
cfdata->cur_path_entry = e_widget_entry_add(evas, &cfdata->cur_path);
|
||||||
e_widget_frametable_object_append(of, cfdata->cur_path_entry, 1, 7, 1, 1, 0, 0, 1, 0);
|
e_widget_frametable_object_append(of, cfdata->cur_path_entry, 1, 5, 1, 1, 0, 0, 1, 0);
|
||||||
if ((cfdata->type == 0) || (cfdata->type == 2))
|
if ((cfdata->type == 0) || (cfdata->type == 2))
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->cur_path_label, 1);
|
e_widget_disabled_set(cfdata->cur_path_label, 1);
|
||||||
|
@ -208,63 +212,105 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
static int
|
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;
|
Config_Box *cb;
|
||||||
|
|
||||||
ci = cfd->data;
|
cb = cfd->data;
|
||||||
|
|
||||||
if (ci->host) evas_stringshare_del(ci->host);
|
if (cfdata->name == NULL)
|
||||||
if (cfdata->host != NULL)
|
{
|
||||||
ci->host = evas_stringshare_add(cfdata->host);
|
e_module_dialog_show(_("Enlightenment Mail Module"),
|
||||||
|
_("You must enter a name for this mailbox."));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cb->name) evas_stringshare_del(cb->name);
|
||||||
|
if (cfdata->name != NULL)
|
||||||
|
cb->name = evas_stringshare_add(cfdata->name);
|
||||||
else
|
else
|
||||||
ci->host = evas_stringshare_add("");
|
cb->name = evas_stringshare_add("");
|
||||||
|
|
||||||
if (ci->user) evas_stringshare_del(ci->user);
|
cb->type = cfdata->type;
|
||||||
if (cfdata->user != NULL)
|
cb->port = atoi(cfdata->port);
|
||||||
ci->user = evas_stringshare_add(cfdata->user);
|
cb->ssl = cfdata->ssl;
|
||||||
else
|
cb->use_exec = cfdata->use_exec;
|
||||||
ci->user = evas_stringshare_add("");
|
if (cb->exec) evas_stringshare_del(cb->exec);
|
||||||
|
|
||||||
if (ci->pass) evas_stringshare_del(ci->pass);
|
|
||||||
if (cfdata->pass != NULL)
|
|
||||||
ci->pass = evas_stringshare_add(cfdata->pass);
|
|
||||||
else
|
|
||||||
ci->pass = evas_stringshare_add("");
|
|
||||||
|
|
||||||
if (ci->path) evas_stringshare_del(ci->path);
|
|
||||||
if (cfdata->path != NULL)
|
|
||||||
ci->path = evas_stringshare_add(cfdata->path);
|
|
||||||
else
|
|
||||||
ci->path = evas_stringshare_add("");
|
|
||||||
|
|
||||||
if (ci->path_current) evas_stringshare_del(ci->path_current);
|
|
||||||
if (cfdata->path_current != NULL)
|
|
||||||
ci->path_current = evas_stringshare_add(cfdata->path_current);
|
|
||||||
else
|
|
||||||
ci->path_current = evas_stringshare_add("");
|
|
||||||
|
|
||||||
if (ci->exec) evas_stringshare_del(ci->exec);
|
|
||||||
if (cfdata->exec != NULL)
|
if (cfdata->exec != NULL)
|
||||||
ci->exec = evas_stringshare_add(cfdata->exec);
|
cb->exec = evas_stringshare_add(cfdata->exec);
|
||||||
else
|
else
|
||||||
ci->exec = evas_stringshare_add("");
|
cb->exec = evas_stringshare_add("");
|
||||||
|
|
||||||
ci->show_label = cfdata->show_label;
|
if (cb->host) evas_stringshare_del(cb->host);
|
||||||
ci->type = cfdata->type;
|
if (cfdata->host != NULL)
|
||||||
ci->use_exec = cfdata->use_exec;
|
cb->host = evas_stringshare_add(cfdata->host);
|
||||||
ci->check_time = cfdata->check_time;
|
|
||||||
|
|
||||||
if (cfdata->port != NULL)
|
|
||||||
ci->port = atoi(cfdata->port);
|
|
||||||
else
|
else
|
||||||
ci->port = 110;
|
cb->host = evas_stringshare_add("");
|
||||||
|
|
||||||
|
if (cb->user) evas_stringshare_del(cb->user);
|
||||||
|
if (cfdata->user != NULL)
|
||||||
|
cb->user = evas_stringshare_add(cfdata->user);
|
||||||
|
else
|
||||||
|
cb->user = evas_stringshare_add("");
|
||||||
|
|
||||||
ci->use_ssl = cfdata->use_ssl;
|
if (cb->pass) evas_stringshare_del(cb->pass);
|
||||||
|
if (cfdata->pass != NULL)
|
||||||
|
cb->pass = evas_stringshare_add(cfdata->pass);
|
||||||
|
else
|
||||||
|
cb->pass = evas_stringshare_add("");
|
||||||
|
|
||||||
|
if (cb->new_path) evas_stringshare_del(cb->new_path);
|
||||||
|
if (cfdata->new_path != NULL)
|
||||||
|
cb->new_path = evas_stringshare_add(cfdata->new_path);
|
||||||
|
else
|
||||||
|
cb->new_path = evas_stringshare_add("");
|
||||||
|
|
||||||
|
if (cb->cur_path) evas_stringshare_del(cb->cur_path);
|
||||||
|
if (cfdata->cur_path != NULL)
|
||||||
|
cb->cur_path = evas_stringshare_add(cfdata->cur_path);
|
||||||
|
else
|
||||||
|
cb->cur_path = evas_stringshare_add("");
|
||||||
|
|
||||||
e_config_save_queue();
|
e_config_save_queue();
|
||||||
_mail_config_updated(ci->id);
|
|
||||||
|
_mail_box_config_updated(prev_dlg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_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_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->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_use_exec_cb_change(void *data, Evas_Object *obj)
|
_use_exec_cb_change(void *data, Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -276,44 +322,3 @@ _use_exec_cb_change(void *data, Evas_Object *obj)
|
||||||
if (!cfdata->use_exec)
|
if (!cfdata->use_exec)
|
||||||
e_widget_entry_text_set(cfdata->exec_entry, "");
|
e_widget_entry_text_set(cfdata->exec_entry, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_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, "");
|
|
||||||
}
|
|
||||||
else if (cfdata->type == 1)
|
|
||||||
{
|
|
||||||
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, "");
|
|
||||||
}
|
|
||||||
else if (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, "");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifdef E_TYPEDEFS
|
||||||
|
#else
|
||||||
|
#ifndef E_MOD_CONFIG_BOX_H
|
||||||
|
#define E_MOD_CONFIG_BOX_H
|
||||||
|
|
||||||
|
#include "e_mod_main.h"
|
||||||
|
|
||||||
|
void _config_box(Config_Box *cb);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
877
e_mod_main.c
877
e_mod_main.c
|
@ -1,877 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2006 Christopher Michael
|
|
||||||
*
|
|
||||||
* Portions of this code Copyright (C) 2004 Embrace project.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <e.h>
|
|
||||||
#include <Ecore.h>
|
|
||||||
#include <Ecore_File.h>
|
|
||||||
#include "e_mod_main.h"
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
MAIL_TYPE_POP,
|
|
||||||
MAIL_TYPE_IMAP,
|
|
||||||
MAIL_TYPE_MDIR,
|
|
||||||
MAIL_TYPE_MBOX
|
|
||||||
} MailType;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
STATE_DISCONNECTED,
|
|
||||||
STATE_CONNECTED,
|
|
||||||
STATE_SERVER_READY,
|
|
||||||
STATE_LOGGED_IN,
|
|
||||||
STATE_USER_OK,
|
|
||||||
STATE_PASS_OK,
|
|
||||||
STATE_STATUS_OK
|
|
||||||
} State;
|
|
||||||
|
|
||||||
typedef struct _Instance Instance;
|
|
||||||
typedef struct _Mail Mail;
|
|
||||||
|
|
||||||
struct _Instance
|
|
||||||
{
|
|
||||||
E_Gadcon_Client *gcc;
|
|
||||||
Evas_Object *mail_obj;
|
|
||||||
Mail *mail;
|
|
||||||
Ecore_Timer *check_timer;
|
|
||||||
Ecore_Con_Server *server;
|
|
||||||
Ecore_Event_Handler *add_handler;
|
|
||||||
Ecore_Event_Handler *del_handler;
|
|
||||||
Ecore_Event_Handler *data_handler;
|
|
||||||
Ecore_File_Monitor *monitor;
|
|
||||||
Ecore_Exe *exe;
|
|
||||||
Ecore_Event_Handler *exit_handler;
|
|
||||||
int state;
|
|
||||||
int cmd;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Mail
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Evas_Object *mail_obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
|
|
||||||
/* 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 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_server_add(void *data, int type, void *event);
|
|
||||||
static int _mail_server_del(void *data, int type, void *event);
|
|
||||||
static int _mail_server_data(void *data, int type, void *event);
|
|
||||||
static int _mail_parse_pop(void *data, void *data2);
|
|
||||||
static int _mail_parse_imap(void *data, void *data2);
|
|
||||||
static void _mail_mbox_check(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path);
|
|
||||||
static void _mail_mdir_check(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_set_text(void *data, int n, int t);
|
|
||||||
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;
|
|
||||||
|
|
||||||
Config *mail_config = NULL;
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Evas_Object *o;
|
|
||||||
E_Gadcon_Client *gcc;
|
|
||||||
Instance *inst;
|
|
||||||
Mail *mail;
|
|
||||||
Config_Item *ci;
|
|
||||||
char buf[4096];
|
|
||||||
|
|
||||||
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->inst = inst;
|
|
||||||
inst->mail = mail;
|
|
||||||
|
|
||||||
o = mail->mail_obj;
|
|
||||||
gcc = e_gadcon_client_new(gc, name, id, style, o);
|
|
||||||
gcc->data = inst;
|
|
||||||
inst->gcc = gcc;
|
|
||||||
inst->mail_obj = o;
|
|
||||||
|
|
||||||
if (ci->type == MAIL_TYPE_MDIR)
|
|
||||||
inst->monitor = ecore_file_monitor_add(ci->path, _mail_mdir_check, inst);
|
|
||||||
else if (ci->type == MAIL_TYPE_MBOX)
|
|
||||||
inst->monitor = ecore_file_monitor_add(ci->path, _mail_mbox_check, inst);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!inst->add_handler)
|
|
||||||
inst->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _mail_server_add, inst);
|
|
||||||
if (!inst->del_handler)
|
|
||||||
inst->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _mail_server_del, inst);
|
|
||||||
if (!inst->data_handler)
|
|
||||||
inst->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _mail_server_data, inst);
|
|
||||||
|
|
||||||
_mail_cb_check(inst);
|
|
||||||
if (!inst->check_timer)
|
|
||||||
inst->check_timer = ecore_timer_add((ci->check_time * 60.0), _mail_cb_check, inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mail_cb_mouse_down, inst);
|
|
||||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _mail_cb_mouse_in, inst);
|
|
||||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _mail_cb_mouse_out, inst);
|
|
||||||
|
|
||||||
if (ci->show_label)
|
|
||||||
edje_object_signal_emit(inst->mail_obj, "label_active", "");
|
|
||||||
else
|
|
||||||
edje_object_signal_emit(inst->mail_obj, "label_passive", "");
|
|
||||||
|
|
||||||
edje_object_part_text_set(inst->mail_obj, "name", ci->user);
|
|
||||||
|
|
||||||
mail_config->instances = evas_list_append(mail_config->instances, inst);
|
|
||||||
return gcc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
inst = gcc->data;
|
|
||||||
if (inst->monitor) ecore_file_monitor_del(inst->monitor);
|
|
||||||
if (inst->check_timer) ecore_timer_del(inst->check_timer);
|
|
||||||
if (inst->add_handler) ecore_event_handler_del(inst->add_handler);
|
|
||||||
if (inst->data_handler) ecore_event_handler_del(inst->data_handler);
|
|
||||||
if (inst->del_handler) ecore_event_handler_del(inst->del_handler);
|
|
||||||
if (inst->server) ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
|
|
||||||
evas_object_event_callback_del(inst->mail->mail_obj, EVAS_CALLBACK_MOUSE_DOWN, _mail_cb_mouse_down);
|
|
||||||
evas_object_event_callback_del(inst->mail->mail_obj, EVAS_CALLBACK_MOUSE_IN, _mail_cb_mouse_in);
|
|
||||||
evas_object_event_callback_del(inst->mail->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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_gc_orient(E_Gadcon_Client *gcc)
|
|
||||||
{
|
|
||||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
|
||||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
_gc_label(void)
|
|
||||||
{
|
|
||||||
return D_("Mail");
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_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");
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Evas_Event_Mouse_Down *ev;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
|
|
||||||
ev = event_info;
|
|
||||||
if ((ev->button == 3) && (!mail_config->menu))
|
|
||||||
{
|
|
||||||
E_Menu *mn;
|
|
||||||
E_Menu_Item *mi;
|
|
||||||
int x, y, w, h;
|
|
||||||
|
|
||||||
mn = e_menu_new();
|
|
||||||
e_menu_post_deactivate_callback_set(mn, _mail_menu_cb_post, inst);
|
|
||||||
mail_config->menu = mn;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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) && (inst) &&
|
|
||||||
((ci->type == 0) || (ci->type == 1)))
|
|
||||||
_mail_cb_check(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
if (!ci->show_label)
|
|
||||||
edje_object_signal_emit(inst->mail_obj, "label_passive", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_menu_cb_post(void *data, E_Menu *m)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
_config_mail_module(ci);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Config_Item *
|
|
||||||
_mail_config_item_get(const char *id)
|
|
||||||
{
|
|
||||||
Evas_List *l;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
for (l = mail_config->items; l; l = l->next)
|
|
||||||
{
|
|
||||||
ci = l->data;
|
|
||||||
if (!ci->id) continue;
|
|
||||||
if (!strcmp(ci->id, id)) return ci;
|
|
||||||
}
|
|
||||||
|
|
||||||
ci = E_NEW(Config_Item, 1);
|
|
||||||
ci->id = evas_stringshare_add(id);
|
|
||||||
ci->host = evas_stringshare_add("");
|
|
||||||
ci->port = 110;
|
|
||||||
ci->user = evas_stringshare_add("");
|
|
||||||
ci->pass = evas_stringshare_add("");
|
|
||||||
ci->exec = evas_stringshare_add("");
|
|
||||||
ci->path = evas_stringshare_add("");
|
|
||||||
ci->path_current = evas_stringshare_add("");
|
|
||||||
ci->show_label = 1;
|
|
||||||
ci->type = MAIL_TYPE_POP;
|
|
||||||
ci->use_exec = 0;
|
|
||||||
ci->check_time = 15.0;
|
|
||||||
ci->use_ssl = 0;
|
|
||||||
|
|
||||||
mail_config->items = evas_list_append(mail_config->items, ci);
|
|
||||||
return ci;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI E_Module_Api e_modapi =
|
|
||||||
{
|
|
||||||
E_MODULE_API_VERSION,
|
|
||||||
"Mail"
|
|
||||||
};
|
|
||||||
|
|
||||||
EAPI void *
|
|
||||||
e_modapi_init(E_Module *m)
|
|
||||||
{
|
|
||||||
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, host, STR);
|
|
||||||
E_CONFIG_VAL(D, T, port, INT);
|
|
||||||
E_CONFIG_VAL(D, T, user, STR);
|
|
||||||
E_CONFIG_VAL(D, T, pass, STR);
|
|
||||||
E_CONFIG_VAL(D, T, exec, STR);
|
|
||||||
E_CONFIG_VAL(D, T, path, STR);
|
|
||||||
E_CONFIG_VAL(D, T, path_current, STR);
|
|
||||||
E_CONFIG_VAL(D, T, show_label, UCHAR);
|
|
||||||
E_CONFIG_VAL(D, T, use_exec, UCHAR);
|
|
||||||
E_CONFIG_VAL(D, T, use_ssl, UCHAR);
|
|
||||||
E_CONFIG_VAL(D, T, type, INT);
|
|
||||||
E_CONFIG_VAL(D, T, check_time, DOUBLE);
|
|
||||||
|
|
||||||
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);
|
|
||||||
if (!mail_config)
|
|
||||||
{
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
mail_config = E_NEW(Config, 1);
|
|
||||||
ci = E_NEW(Config_Item, 1);
|
|
||||||
|
|
||||||
ci->id = evas_stringshare_add("0");
|
|
||||||
ci->host = evas_stringshare_add("");
|
|
||||||
ci->port = 110;
|
|
||||||
ci->user = evas_stringshare_add("");
|
|
||||||
ci->pass = evas_stringshare_add("");
|
|
||||||
ci->exec = evas_stringshare_add("");
|
|
||||||
ci->path = evas_stringshare_add("");
|
|
||||||
ci->path_current = evas_stringshare_add("");
|
|
||||||
ci->show_label = 1;
|
|
||||||
ci->type = MAIL_TYPE_POP;
|
|
||||||
ci->use_exec = 0;
|
|
||||||
ci->check_time = 15.0;
|
|
||||||
ci->use_ssl = 0;
|
|
||||||
|
|
||||||
mail_config->items = evas_list_append(mail_config->items, ci);
|
|
||||||
}
|
|
||||||
mail_config->module = m;
|
|
||||||
e_gadcon_provider_register(&_gc_class);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI int
|
|
||||||
e_modapi_shutdown(E_Module *m)
|
|
||||||
{
|
|
||||||
mail_config->module = NULL;
|
|
||||||
e_gadcon_provider_unregister(&_gc_class);
|
|
||||||
|
|
||||||
if (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));
|
|
||||||
mail_config->menu = NULL;
|
|
||||||
}
|
|
||||||
while (mail_config->items)
|
|
||||||
{
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
ci = mail_config->items->data;
|
|
||||||
if (ci->id) evas_stringshare_del(ci->id);
|
|
||||||
if (ci->host) evas_stringshare_del(ci->host);
|
|
||||||
if (ci->user) evas_stringshare_del(ci->user);
|
|
||||||
if (ci->pass) evas_stringshare_del(ci->pass);
|
|
||||||
if (ci->exec) evas_stringshare_del(ci->exec);
|
|
||||||
if (ci->path) evas_stringshare_del(ci->path);
|
|
||||||
if (ci->path_current) evas_stringshare_del(ci->path_current);
|
|
||||||
mail_config->items = evas_list_remove_list(mail_config->items, mail_config->items);
|
|
||||||
free(ci);
|
|
||||||
}
|
|
||||||
free(mail_config);
|
|
||||||
mail_config = NULL;
|
|
||||||
E_CONFIG_DD_FREE(conf_item_edd);
|
|
||||||
E_CONFIG_DD_FREE(conf_edd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI int
|
|
||||||
e_modapi_save(E_Module *m)
|
|
||||||
{
|
|
||||||
Evas_List *l;
|
|
||||||
|
|
||||||
for (l = mail_config->instances; l; l = l->next)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
inst = l->data;
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
if (ci->id) evas_stringshare_del(ci->id);
|
|
||||||
ci->id = evas_stringshare_add(inst->gcc->id);
|
|
||||||
}
|
|
||||||
e_config_domain_save("module.mail", conf_edd, mail_config);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI int
|
|
||||||
e_modapi_about(E_Module *m)
|
|
||||||
{
|
|
||||||
e_module_dialog_show(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 *mail;
|
|
||||||
char buf[4096];
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return mail;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_free(Mail *mail)
|
|
||||||
{
|
|
||||||
evas_object_del(mail->mail_obj);
|
|
||||||
free(mail);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_cb_check(void *data)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
Ecore_Con_Type type = ECORE_CON_REMOTE_SYSTEM;
|
|
||||||
inst = data;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
if ((!ci->host) || (!ci->user) || (!ci->pass)) return 0;
|
|
||||||
|
|
||||||
if (inst->server) ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
inst->cmd = 0;
|
|
||||||
|
|
||||||
if ((ci->host) && (ci->port != 0))
|
|
||||||
{
|
|
||||||
if (ci->use_ssl)
|
|
||||||
type |= ECORE_CON_USE_SSL;
|
|
||||||
inst->server = ecore_con_server_connect(type, ci->host, ci->port, inst);
|
|
||||||
inst->state = STATE_CONNECTED;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_server_add(void *data, int type, void *event)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Ecore_Con_Event_Server_Add *ev;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return 1;
|
|
||||||
|
|
||||||
ev = event;
|
|
||||||
if ((!inst->server) || (inst->server != ev->server)) return 1;
|
|
||||||
inst->state = STATE_CONNECTED;
|
|
||||||
inst->cmd = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_server_del(void *data, int type, void *event)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
Ecore_Con_Event_Server_Del *ev;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return 1;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
|
|
||||||
ev = event;
|
|
||||||
if ((!inst->server) || (inst->server != ev->server)) return 1;
|
|
||||||
if (!ci->host) return 1;
|
|
||||||
|
|
||||||
if (inst->state == STATE_DISCONNECTED)
|
|
||||||
printf("Cannot Connect to %s\n", ci->host);
|
|
||||||
else
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
|
|
||||||
ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
inst->cmd = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_server_data(void *data, int type, void *event)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
Ecore_Con_Event_Server_Data *ev;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return 1;
|
|
||||||
|
|
||||||
ev = event;
|
|
||||||
if ((!inst->server) || (inst->server != ev->server)) return 1;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
|
|
||||||
if (ci->type == MAIL_TYPE_POP)
|
|
||||||
return _mail_parse_pop(inst, ev);
|
|
||||||
else if (ci->type == MAIL_TYPE_IMAP)
|
|
||||||
return _mail_parse_imap(inst, ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_parse_pop(void *data, void *data2)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
Ecore_Con_Event_Server_Data *ev;
|
|
||||||
char in[2048], out[2048];
|
|
||||||
int num = 0, size = 0, len;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
ev = data2;
|
|
||||||
if (!ev) return;
|
|
||||||
|
|
||||||
if ((!inst->server) || (inst->server != ev->server)) return;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
|
|
||||||
len = sizeof(in) -1;
|
|
||||||
len = (((len) > (ev->size)) ? ev->size : len);
|
|
||||||
|
|
||||||
memcpy(in, ev->data, len);
|
|
||||||
in[len] = 0;
|
|
||||||
|
|
||||||
if (!strncmp(in, "-ERR", 4))
|
|
||||||
{
|
|
||||||
printf("ERROR: %s\n", in);
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (strncmp(in, "+OK", 3))
|
|
||||||
{
|
|
||||||
printf("Unexpected reply: %s\n", in);
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inst->state == STATE_CONNECTED)
|
|
||||||
inst->state++;
|
|
||||||
|
|
||||||
switch (inst->state)
|
|
||||||
{
|
|
||||||
case STATE_SERVER_READY:
|
|
||||||
len = snprintf(out, sizeof(out), "USER %s\r\n", ci->user);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
inst->state = STATE_USER_OK;
|
|
||||||
break;
|
|
||||||
case STATE_USER_OK:
|
|
||||||
len = snprintf(out, sizeof(out), "PASS %s\r\n", ci->pass);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
inst->state = STATE_PASS_OK;
|
|
||||||
break;
|
|
||||||
case STATE_PASS_OK:
|
|
||||||
len = snprintf(out, sizeof(out), "STAT\r\n");
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
inst->state = STATE_STATUS_OK;
|
|
||||||
break;
|
|
||||||
case STATE_STATUS_OK:
|
|
||||||
if (sscanf(in, "+OK %i %i", &num, &size) == 2)
|
|
||||||
_mail_set_text(inst, num, num);
|
|
||||||
else
|
|
||||||
_mail_set_text(inst, 0, 0);
|
|
||||||
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
if ((ci->use_exec) && (ci->exec != NULL))
|
|
||||||
{
|
|
||||||
if (num <= 0) break;
|
|
||||||
if (!inst->exe)
|
|
||||||
{
|
|
||||||
inst->exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _mail_cb_exe_exit, inst);
|
|
||||||
inst->exe = ecore_exe_run(ci->exec, inst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_parse_imap(void *data, void *data2)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
Ecore_Con_Event_Server_Data *ev;
|
|
||||||
char in[2048], out[2048];
|
|
||||||
int total = 0, unread = 0, len;
|
|
||||||
char *spc;
|
|
||||||
size_t slen;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
ev = data2;
|
|
||||||
if (!ev) return;
|
|
||||||
|
|
||||||
if ((!inst->server) || (inst->server != ev->server)) return;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
|
|
||||||
len = sizeof(in) -1;
|
|
||||||
len = (((len) > (ev->size)) ? ev->size : len);
|
|
||||||
|
|
||||||
memcpy(in, ev->data, len);
|
|
||||||
in[len] = 0;
|
|
||||||
|
|
||||||
if (spc = strchr(in, ' '))
|
|
||||||
{
|
|
||||||
slen = strlen(spc);
|
|
||||||
if ((slen > 5) && (!strncmp(spc + 1, "NO ", 3)))
|
|
||||||
{
|
|
||||||
len = snprintf(out, sizeof(out), "A%03i LOGOUT", ++inst->cmd);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
printf("Imap Failure: %s\n", spc + 4);
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
inst->cmd = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if ((slen > 6) && (!strncmp(spc + 1, "BAD ", 4)))
|
|
||||||
{
|
|
||||||
len = snprintf(out, sizeof(out), "A%03i LOGOUT", ++inst->cmd);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
printf("Imap Bad Command: %s\n", spc + 5);
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
inst->cmd = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inst->state == STATE_CONNECTED)
|
|
||||||
inst->state++;
|
|
||||||
|
|
||||||
switch (inst->state)
|
|
||||||
{
|
|
||||||
case STATE_SERVER_READY:
|
|
||||||
len = snprintf(out, sizeof(out), "A%03i LOGIN %s %s\r\n", ++inst->cmd, ci->user, ci->pass);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
inst->state = STATE_LOGGED_IN;
|
|
||||||
break;
|
|
||||||
case STATE_LOGGED_IN:
|
|
||||||
len = snprintf(out, sizeof(out), "A%03i STATUS %s (MESSAGES UNSEEN)\r\n",++inst->cmd, ci->path);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
inst->state = STATE_STATUS_OK;
|
|
||||||
break;
|
|
||||||
case STATE_STATUS_OK:
|
|
||||||
if (sscanf(in, "* STATUS %*s (MESSAGES %i UNSEEN %i)", &total, &unread) == 2)
|
|
||||||
_mail_set_text(inst, unread, total);
|
|
||||||
else
|
|
||||||
_mail_set_text(inst, 0, 0);
|
|
||||||
|
|
||||||
len = snprintf(out, sizeof(out), "A%03i LOGOUT", ++inst->cmd);
|
|
||||||
ecore_con_server_send(inst->server, out, len);
|
|
||||||
inst->state = STATE_DISCONNECTED;
|
|
||||||
inst->cmd = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_mbox_check(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
FILE *f;
|
|
||||||
char buf[1024];
|
|
||||||
int total = 0, unread = 0;
|
|
||||||
int header;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
_mail_set_text(inst, 0, 0);
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
if (!(f = fopen(ci->path, "r")))
|
|
||||||
return;
|
|
||||||
while (fgets(buf, sizeof(buf), f))
|
|
||||||
{
|
|
||||||
if (buf[0] == '\n')
|
|
||||||
header = 0;
|
|
||||||
else if (!strncmp(buf, "From ", 5))
|
|
||||||
{
|
|
||||||
header = 1;
|
|
||||||
total++;
|
|
||||||
unread++;
|
|
||||||
}
|
|
||||||
else if ((header) && (!strncmp(buf, "Status: ", 7)) && (strchr(buf, 'R')))
|
|
||||||
unread--;
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
_mail_set_text(inst, unread, total);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_mdir_check(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
int total = 0, unread = 0;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
_mail_set_text(inst, 0, 0);
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
|
|
||||||
total = _mail_mdir_get_files(ci->path_current);
|
|
||||||
unread = _mail_mdir_get_files(ci->path);
|
|
||||||
_mail_set_text(inst, unread, total);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_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)
|
|
||||||
{
|
|
||||||
if ((!strcmp(item, ".")) || (!strcmp(item, ".."))) continue;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ecore_list_destroy(l);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_mail_set_text(void *data, int n, int t)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Config_Item *ci;
|
|
||||||
char buf[1024];
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
ci = _mail_config_item_get(inst->gcc->id);
|
|
||||||
edje_object_part_text_set(inst->mail->mail_obj, "name", ci->user);
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%d/%d", n, t);
|
|
||||||
edje_object_part_text_set(inst->mail->mail_obj, "new_label", buf);
|
|
||||||
|
|
||||||
if (n > 0)
|
|
||||||
edje_object_signal_emit(inst->mail->mail_obj, "new_mail", "");
|
|
||||||
else
|
|
||||||
edje_object_signal_emit(inst->mail->mail_obj, "no_mail", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_mail_cb_exe_exit(void *data, int type, void *event)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
inst->exe = NULL;
|
|
||||||
ecore_event_handler_del(inst->exit_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_mail_config_updated(const char *id)
|
|
||||||
{
|
|
||||||
Evas_List *l;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
if (!mail_config) return;
|
|
||||||
ci = _mail_config_item_get(id);
|
|
||||||
for (l = mail_config->instances; l; l = l->next)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
inst = l->data;
|
|
||||||
if (!inst->gcc->id) continue;
|
|
||||||
if (!strcmp(inst->gcc->id, ci->id))
|
|
||||||
{
|
|
||||||
if (inst->check_timer) ecore_timer_del(inst->check_timer);
|
|
||||||
if ((ci->type == 0) || (ci->type == 1))
|
|
||||||
inst->check_timer = ecore_timer_add((ci->check_time * 60.0), _mail_cb_check, inst);
|
|
||||||
|
|
||||||
if (ci->show_label)
|
|
||||||
edje_object_signal_emit(inst->mail_obj, "label_active", "");
|
|
||||||
else
|
|
||||||
edje_object_signal_emit(inst->mail_obj, "label_passive", "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
49
e_mod_main.h
49
e_mod_main.h
|
@ -1,49 +0,0 @@
|
||||||
#define D_(str) dgettext(PACKAGE, str)
|
|
||||||
|
|
||||||
#ifndef E_MOD_MAIN_H
|
|
||||||
#define E_MOD_MAIN_H
|
|
||||||
|
|
||||||
typedef struct _Config Config;
|
|
||||||
typedef struct _Config_Item Config_Item;
|
|
||||||
|
|
||||||
struct _Config
|
|
||||||
{
|
|
||||||
E_Module *module;
|
|
||||||
E_Config_Dialog *config_dialog;
|
|
||||||
E_Menu *menu;
|
|
||||||
Evas_List *instances;
|
|
||||||
Evas_List *items;
|
|
||||||
Ecore_Event_Handler *exe_exit_handler;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Config_Item
|
|
||||||
{
|
|
||||||
const char *id;
|
|
||||||
|
|
||||||
unsigned char show_label;
|
|
||||||
unsigned char use_exec;
|
|
||||||
unsigned char use_ssl;
|
|
||||||
const char *exec;
|
|
||||||
double check_time;
|
|
||||||
|
|
||||||
int type;
|
|
||||||
int port;
|
|
||||||
const char *host;
|
|
||||||
const char *user;
|
|
||||||
const char *pass;
|
|
||||||
const char *path;
|
|
||||||
const char *path_current;
|
|
||||||
};
|
|
||||||
|
|
||||||
EAPI extern E_Module_Api e_modapi;
|
|
||||||
|
|
||||||
EAPI void *e_modapi_init(E_Module *m);
|
|
||||||
EAPI int e_modapi_shutdown(E_Module *m);
|
|
||||||
EAPI int e_modapi_save(E_Module *m);
|
|
||||||
EAPI int e_modapi_about(E_Module *m);
|
|
||||||
|
|
||||||
void _config_mail_module(Config_Item *ci);
|
|
||||||
void _mail_config_updated(const char *id);
|
|
||||||
extern Config *mail_config;
|
|
||||||
|
|
||||||
#endif
|
|
213
mail.edc
213
mail.edc
|
@ -1,213 +0,0 @@
|
||||||
fonts
|
|
||||||
{
|
|
||||||
font: "VeraBd.ttf" "VeraBold";
|
|
||||||
}
|
|
||||||
images
|
|
||||||
{
|
|
||||||
image: "module_icon.png" COMP;
|
|
||||||
image: "newmail.png" COMP;
|
|
||||||
}
|
|
||||||
|
|
||||||
collections
|
|
||||||
{
|
|
||||||
group
|
|
||||||
{
|
|
||||||
name: "modules/mail/main";
|
|
||||||
max: 128 128;
|
|
||||||
parts
|
|
||||||
{
|
|
||||||
part
|
|
||||||
{
|
|
||||||
name: "clip";
|
|
||||||
type: RECT;
|
|
||||||
mouse_events: 1;
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "default" 0.0;
|
|
||||||
color: 255 255 255 255;
|
|
||||||
rel1
|
|
||||||
{
|
|
||||||
relative: 0.0 0.0;
|
|
||||||
offset: 0 0;
|
|
||||||
}
|
|
||||||
rel2
|
|
||||||
{
|
|
||||||
relative: 1.0 1.0;
|
|
||||||
offset: -1 -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
part
|
|
||||||
{
|
|
||||||
name: "logo";
|
|
||||||
type: IMAGE;
|
|
||||||
clip_to: "clip";
|
|
||||||
mouse_events: 1;
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "default" 0.0;
|
|
||||||
aspect: 1.0 1.0;
|
|
||||||
rel1
|
|
||||||
{
|
|
||||||
relative: 0.0 0.0;
|
|
||||||
offset: 0 0;
|
|
||||||
}
|
|
||||||
rel2
|
|
||||||
{
|
|
||||||
relative: 1.0 1.0;
|
|
||||||
offset: -1 -1;
|
|
||||||
}
|
|
||||||
image
|
|
||||||
{
|
|
||||||
normal: "module_icon.png";
|
|
||||||
}
|
|
||||||
color: 255 255 255 255;
|
|
||||||
}
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "new" 0.0;
|
|
||||||
inherit: "default" 0.0;
|
|
||||||
image
|
|
||||||
{
|
|
||||||
normal: "newmail.png";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
part
|
|
||||||
{
|
|
||||||
name: "name";
|
|
||||||
type: TEXT;
|
|
||||||
clip_to: "clip";
|
|
||||||
effect: SOFT_SHADOW;
|
|
||||||
mouse_events: 0;
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "default" 0.0;
|
|
||||||
color: 0 0 0 255;
|
|
||||||
color3: 255 255 255 42;
|
|
||||||
visible: 0;
|
|
||||||
rel1
|
|
||||||
{
|
|
||||||
relative: 0.0 0.9;
|
|
||||||
offset: 0 0;
|
|
||||||
to: "logo";
|
|
||||||
}
|
|
||||||
rel2
|
|
||||||
{
|
|
||||||
relative: 1.0 1.0;
|
|
||||||
offset: -1 -1;
|
|
||||||
to: "logo";
|
|
||||||
}
|
|
||||||
text
|
|
||||||
{
|
|
||||||
text: "Name";
|
|
||||||
font: "VeraBold";
|
|
||||||
size: 10;
|
|
||||||
min: 1 1;
|
|
||||||
align: 1.0 0.5;
|
|
||||||
text_class: "module_normal";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "visible" 0.0;
|
|
||||||
inherit: "default" 0.0;
|
|
||||||
visible: 1;
|
|
||||||
color: 0 0 0 255;
|
|
||||||
color3: 255 255 255 42;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
part
|
|
||||||
{
|
|
||||||
name: "new_label";
|
|
||||||
type: TEXT;
|
|
||||||
clip_to: "clip";
|
|
||||||
effect: SOFT_SHADOW;
|
|
||||||
mouse_events: 0;
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "default" 0.0;
|
|
||||||
color: 0 0 0 255;
|
|
||||||
color3: 255 255 255 42;
|
|
||||||
visible: 0;
|
|
||||||
rel1
|
|
||||||
{
|
|
||||||
relative: 0.0 0.3;
|
|
||||||
offset: 0 0;
|
|
||||||
to: "logo";
|
|
||||||
}
|
|
||||||
rel2
|
|
||||||
{
|
|
||||||
relative: 1.0 0.5;
|
|
||||||
offset: -1 -1;
|
|
||||||
to: "logo";
|
|
||||||
}
|
|
||||||
text
|
|
||||||
{
|
|
||||||
text: "New:";
|
|
||||||
font: "VeraBold";
|
|
||||||
size: 9;
|
|
||||||
min: 1 1;
|
|
||||||
align: 1.0 0.5;
|
|
||||||
text_class: "module_small";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
description
|
|
||||||
{
|
|
||||||
state: "visible" 0.0;
|
|
||||||
inherit: "default" 0.0;
|
|
||||||
visible: 1;
|
|
||||||
color: 0 0 0 255;
|
|
||||||
color3: 255 255 255 42;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
programs
|
|
||||||
{
|
|
||||||
program
|
|
||||||
{
|
|
||||||
name: "go_active";
|
|
||||||
signal: "label_active";
|
|
||||||
source: "";
|
|
||||||
action: STATE_SET "visible" 0.0;
|
|
||||||
transition: SINUSOIDAL 0.5;
|
|
||||||
target: "name";
|
|
||||||
target: "new_label";
|
|
||||||
}
|
|
||||||
program
|
|
||||||
{
|
|
||||||
name: "go_passive2";
|
|
||||||
signal: "label_passive2";
|
|
||||||
source: "";
|
|
||||||
action: ACTION_STOP;
|
|
||||||
target: "go_active";
|
|
||||||
}
|
|
||||||
program
|
|
||||||
{
|
|
||||||
name: "go_passive";
|
|
||||||
signal: "label_passive";
|
|
||||||
source: "";
|
|
||||||
action: STATE_SET "default" 0.0;
|
|
||||||
transition: SINUSOIDAL 1.0;
|
|
||||||
target: "name";
|
|
||||||
target: "new_label";
|
|
||||||
}
|
|
||||||
program
|
|
||||||
{
|
|
||||||
name: "go_new";
|
|
||||||
signal: "new_mail";
|
|
||||||
action: STATE_SET "new" 0.0;
|
|
||||||
transition: SINUSOIDAL 0.5;
|
|
||||||
target: "logo";
|
|
||||||
}
|
|
||||||
program
|
|
||||||
{
|
|
||||||
name: "go_no";
|
|
||||||
signal: "no_mail";
|
|
||||||
action: STATE_SET "default" 0.0;
|
|
||||||
transition: SINUSOIDAL 1.0;
|
|
||||||
target: "logo";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue