Ok, mail module can now do multiple accounts per instance.

Remove old module.mail.cfg before running or bad things will happen.


SVN revision: 23310
This commit is contained in:
Christopher Michael 2006-06-08 20:20:07 +00:00
parent 1ea125de22
commit 1eb4de6377
4 changed files with 1697 additions and 0 deletions

352
e_mod_config.c Normal file
View File

@ -0,0 +1,352 @@
#include <e.h>
#include "e_mod_main.h"
struct _E_Config_Dialog_Data
{
int show_label;
double check_time;
Evas_List *boxes;
/* Evas Object References */
Evas_Object *il;
Evas_Object *del;
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 _use_exec_cb_change(void *data, Evas_Object *obj);
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)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
E_Container *con;
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;
con = e_container_current_get(e_manager_current_get());
cfd = e_config_dialog_new(con, _("Mail Configuration"), NULL, 0, v, ci);
mail_config->config_dialog = cfd;
}
static void
_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
{
cfdata->show_label = ci->show_label;
//cfdata->use_exec = ci->use_exec;
//cfdata->exec = NULL;
//if (ci->exec)
// cfdata->exec = strdup(ci->exec);
cfdata->check_time = ci->check_time;
cfdata->boxes = ci->boxes;
}
static void *
_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);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
if (!mail_config) return;
mail_config->config_dialog = NULL;
free(cfdata);
}
static Evas_Object *
_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, _("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);
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);
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);
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_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)
{
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);
return 1;
}
static void
_load_boxes(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
Evas_Object *il;
Config_Item *ci;
int i;
char buf[4096];
cfdata = cfd->cfdata;
il = cfdata->il;
if (!il) return;
ci = cfd->data;
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));
e_widget_ilist_clear(il);
for (i = 0; i <= 3; i++)
{
Evas_List *box;
int found = -1;
char *name;
switch (i)
{
case MAIL_TYPE_POP:
name = "Pop3";
break;
case MAIL_TYPE_IMAP:
name = "Imap";
break;
case MAIL_TYPE_MDIR:
name = "Maildir";
break;
case MAIL_TYPE_MBOX:
name = "Mailbox";
break;
}
found = _ilist_header_exists(il, name);
if (found < 0)
e_widget_ilist_header_append(il, NULL, name);
for (box = ci->boxes; box; box = box->next)
{
Config_Box *cb;
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);
}
}
e_widget_ilist_go(il);
}
static int
_ilist_header_exists(Evas_Object *il, const char *name)
{
int c, i, found = 0;
if (!il) 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))
{
found = 1;
break;
}
}
if (found) return i;
return -1;
}
static void
_ilist_cb_selected(void *data)
{
E_Config_Dialog *cfd;
E_Config_Dialog_Data *cfdata;
cfd = data;
cfdata = cfd->cfdata;
e_widget_disabled_set(cfdata->del, 0);
e_widget_disabled_set(cfdata->configure, 0);
}
static void
_cb_add_box(void *data, void *data2)
{
E_Config_Dialog *cfd;
E_Config_Dialog_Data *cfdata;
Config_Item *ci;
cfd = data;
if (!cfd) return;
ci = cfd->data;
cfdata = cfd->cfdata;
_config_box(ci, NULL, cfd);
}
static void
_cb_edit_box(void *data, void *data2)
{
E_Config_Dialog *cfd;
E_Config_Dialog_Data *cfdata;
Evas_Object *il;
Evas_List *l;
Config_Item *ci;
const char *s;
cfd = data;
if (!cfd) return;
ci = cfd->data;
cfdata = cfd->cfdata;
il = cfdata->il;
s = e_widget_ilist_selected_label_get(il);
<<<<<<< e_mod_config.c
for (l = ci->boxes; l; l = l->next)
=======
cfdata = data;
if (cfdata->type == 0)
>>>>>>> 1.5
{
Config_Box *cb;
cb = l->data;
if (!cb->name) continue;
if (!strcmp(s, cb->name))
{
_config_box(ci, cb, cfd);
break;
}
}
<<<<<<< e_mod_config.c
}
static void
_cb_del_box(void *data, void *data2)
{
E_Config_Dialog *cfd;
E_Config_Dialog_Data *cfdata;
Evas_Object *il;
Evas_List *l;
Config_Item *ci;
const char *s;
cfd = data;
if (!cfd) return;
ci = cfd->data;
cfdata = cfd->cfdata;
il = cfdata->il;
s = e_widget_ilist_selected_label_get(il);
for (l = ci->boxes; l; l = l->next)
=======
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)
>>>>>>> 1.5
{
Config_Box *cb;
cb = l->data;
if (!cb->name) continue;
if (!strcmp(s, cb->name))
{
ci->boxes = evas_list_remove(ci->boxes, cb);
e_config_save_queue();
break;
}
}
_load_boxes(cfd);
}
void
_mail_box_config_updated(E_Config_Dialog *cfd)
{
_load_boxes(cfd);
return;
}

1041
e_mod_main.c Normal file

File diff suppressed because it is too large Load Diff

71
e_mod_main.h Normal file
View File

@ -0,0 +1,71 @@
#define D_(str) dgettext(PACKAGE, str)
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
//IMAP: 143
//POP: 110
typedef enum
{
MAIL_TYPE_POP,
MAIL_TYPE_IMAP,
MAIL_TYPE_MDIR,
MAIL_TYPE_MBOX
} MailType;
typedef struct _Config Config;
typedef struct _Config_Item Config_Item;
typedef struct _Config_Box Config_Box;
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;
double check_time;
Evas_List *boxes;
};
struct _Config_Box
{
const char *name;
int type;
int port;
unsigned char ssl;
const char *host;
const char *user;
const char *pass;
const char *new_path;
const char *cur_path;
unsigned char use_exec;
const char *exec;
};
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);
void _mail_box_config_updated(E_Config_Dialog *cfd);
extern Config *mail_config;
#endif

233
mail.edc Normal file
View File

@ -0,0 +1,233 @@
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: "";
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
{
<<<<<<< mail.edc
text: "";
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;
}
}
=======
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;
}
}
>>>>>>> 1.4
}
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";
}
}
}
}