From 48d14d39f2f7bc38f3830f6833b247ee1aa3e19b Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Thu, 8 Jun 2006 22:32:35 +0000 Subject: [PATCH] Many fixes: -Fix config dialog to allow changing current path for maildir. -When add/del accounts, setup those accounts to get new mail. -Mailbox list in menu now reflects accounts that have been add/del. SVN revision: 23317 --- e_mod_config.c | 4 +- e_mod_config_box.c | 46 ++++++++++++++------ e_mod_main.c | 106 +++++++++++++++++++++++++++++++++++++++++++++ e_mod_main.h | 2 + 4 files changed, 143 insertions(+), 15 deletions(-) diff --git a/e_mod_config.c b/e_mod_config.c index 0470d36..71d1821 100644 --- a/e_mod_config.c +++ b/e_mod_config.c @@ -242,6 +242,7 @@ _cb_add_box(void *data, void *data2) ci = cfd->data; cfdata = cfd->cfdata; + _config_box(ci, NULL, cfd); } @@ -303,8 +304,7 @@ _cb_del_box(void *data, void *data2) if (!cb->name) continue; if (!strcmp(s, cb->name)) { - ci->boxes = evas_list_remove(ci->boxes, cb); - e_config_save_queue(); + _mail_box_deleted(ci->id, cb->name); break; } } diff --git a/e_mod_config_box.c b/e_mod_config_box.c index 2acf7b7..a37baeb 100644 --- a/e_mod_config_box.c +++ b/e_mod_config_box.c @@ -33,6 +33,7 @@ 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) @@ -45,16 +46,7 @@ _config_box(Config_Item *ci, Config_Box *cb, E_Config_Dialog *mcfd) 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(); - } + mail_ci = ci; v->create_cfdata = _create_data; v->free_cfdata = _free_data; @@ -70,6 +62,16 @@ _fill_data(Config_Box *cb, E_Config_Dialog_Data *cfdata) { char buf[1024]; + if (!cb) + { + cfdata->type = 0; + cfdata->ssl = 0; + cfdata->use_exec = 0; + snprintf(buf, sizeof(buf), "110"); + cfdata->port = strdup(buf); + return; + } + if (cb->name) cfdata->name = strdup(cb->name); @@ -199,7 +201,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf 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 == 0) || (cfdata->type == 2)) + 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); @@ -213,8 +215,7 @@ static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { Config_Box *cb; - - cb = cfd->data; + int is_new = 0; if (cfdata->name == NULL) { @@ -223,6 +224,16 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) return 0; } + cb = cfd->data; + if (!cb) + { + 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 (cfdata->name != NULL) cb->name = evas_stringshare_add(cfdata->name); @@ -271,6 +282,15 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) e_config_save_queue(); + _mail_box_config_updated(prev_dlg); + + if (is_new) + { + 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); return 1; } diff --git a/e_mod_main.c b/e_mod_main.c index baeba40..b7f2e75 100644 --- a/e_mod_main.c +++ b/e_mod_main.c @@ -958,6 +958,112 @@ _mail_cb_exe_exit(void *data, int type, void *event) ecore_event_handler_del(mb->exit_handler); } +void +_mail_box_added(const char *ci_name, const char *box_name) +{ + Evas_List *l, *b; + + for (l = mail_config->instances; l; l = l->next) + { + Instance *inst; + Config_Item *ci; + + inst = l->data; + ci = _mail_config_item_get(inst->gcc->id); + if ((ci->id) && (!strcmp(ci->id, ci_name))) + { + for (b = ci->boxes; b; b = b->next) + { + Config_Box *cb; + + cb = b->data; + if ((cb->name) && (!strcmp(cb->name, box_name))) + { + Mailbox *mb; + + mb = E_NEW(Mailbox, 1); + mb->inst = inst; + mb->config = cb; + mb->server = NULL; + mb->state = STATE_DISCONNECTED; + mb->cmd = 0; + inst->mboxes = evas_list_append(inst->mboxes, mb); + if (cb->type == MAIL_TYPE_MDIR) + mb->monitor = ecore_file_monitor_add(cb->new_path, _mail_mdir_check, mb); + else if (cb->type == MAIL_TYPE_MBOX) + mb->monitor = ecore_file_monitor_add(cb->new_path, _mail_mbox_check, mb); + else + { + _mail_cb_check(inst); + if (!inst->check_timer) + inst->check_timer = ecore_timer_add((ci->check_time * 60.0), _mail_cb_check, inst); + } + break; + } + } + break; + } + } +} + +void +_mail_box_deleted(const char *ci_name, const char *box_name) +{ + Evas_List *l, *d, *i; + Config_Box *cb; + int found = 0; + + for (i = mail_config->instances; i; i = i->next) + { + Instance *inst; + + inst = i->data; + if (!inst->gcc->id) continue; + if (!strcmp(inst->gcc->id, ci_name)) + { + Config_Item *ci; + + 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)) + found = 1; + } + if (found) break; + } + if (found) + { + for (l = inst->mboxes; l; l = l->next) + { + Mailbox *mb; + + mb = l->data; + if (((mb->config->name) && (cb->name)) && + (!strcmp(mb->config->name, cb->name))) + { + if (mb->monitor) ecore_file_monitor_del(mb->monitor); + if (mb->add_handler) ecore_event_handler_del(mb->add_handler); + if (mb->data_handler) ecore_event_handler_del(mb->data_handler); + if (mb->del_handler) ecore_event_handler_del(mb->del_handler); + if (mb->server) ecore_con_server_del(mb->server); + mb->server = NULL; + inst->mboxes = evas_list_remove(inst->mboxes, mb); + free(mb); + break; + } + } + ci->boxes = evas_list_remove(ci->boxes, cb); + e_config_save_queue(); + break; + } + break; + } + } +} + void _mail_config_updated(const char *id) { diff --git a/e_mod_main.h b/e_mod_main.h index d18147d..f5cf8ed 100644 --- a/e_mod_main.h +++ b/e_mod_main.h @@ -65,6 +65,8 @@ 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); +void _mail_box_deleted(const char *ci_name, const char *box_name); +void _mail_box_added(const char *ci_name, const char *box_name); extern Config *mail_config;