static CORBA_boolean impl_requestQuit(PortableServer_Servant servant, CORBA_Environment *ev) { /*MailComponent *mc = MAIL_COMPONENT(bonobo_object_from_servant(servant));*/ CamelFolder *folder; guint32 unsent; if (!e_msg_composer_request_close_all()) return FALSE; folder = mc_default_folders[MAIL_COMPONENT_FOLDER_OUTBOX].folder; if (folder != NULL && camel_session_is_online(session) && camel_object_get(folder, NULL, CAMEL_FOLDER_VISIBLE, &unsent, 0) == 0 && unsent > 0 && e_error_run(NULL, "mail:exit-unsaved", NULL) != GTK_RESPONSE_YES) return FALSE; return TRUE; }
/* The worker thread function with all the complex * logic in it! Big fat beast! Please watch your * children ... */ static void synch_worker (struct account_synch_msg *m) { ScalixAccountSynch *sxas; ScalixAccountSynchPrivate *priv; CamelException ex; CamelStore *store; CamelFolderInfo *ftree; CamelFolderInfo *sf; CamelSession *cs; const char *uri; gboolean res; char *sversion; char *markup; sxas = SCALIX_ACCOUNT_SYNCH (m->sxas); priv = SCALIX_ACCOUNT_SYNCH_GET_PRIVATE (sxas); uri = e_account_get_string (priv->account, E_ACCOUNT_SOURCE_URL); g_print ("SxAS: starting synch for %s\n", uri); signal_progress (sxas, 1, _("Trying to connect to server")); camel_exception_init (&ex); cs = scalix_camel_session_get_default (); camel_session_set_online (cs, TRUE); store = camel_session_get_store (cs, uri, &ex); if (store == NULL) { signal_error (sxas, _("Authentication failed. Check for correct hostname, username and password.")); return; } /* Must be online! */ camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (store), CAMEL_OFFLINE_STORE_NETWORK_AVAIL, &ex); camel_service_connect (CAMEL_SERVICE (store), &ex); if (camel_exception_is_set (&ex)) { signal_error (sxas, _("Error while trying to connect to server.")); return; } /* Always check for minimal required server version */ signal_progress (sxas, 10, _("Checking version of Scalix server")); g_print ("SxAS: Checking for minimal server version\n"); sversion = NULL; camel_object_get (store, NULL, CAMEL_SCALIX_STORE_SERVER_VERSION, &sversion, NULL); res = scalix_check_min_server_version (sversion); if (res == FALSE) { signal_error (sxas, _("Wrong version of Scalix server detected")); return; } m->sversion = g_strdup (sversion); g_print ("SxAS: sversion:%s\n", m->sversion); markup = g_markup_printf_escaped (MSG_SVER, sversion); signal_info (sxas, markup); g_free (markup); signal_progress (sxas, 20, _("Getting list of folders")); ftree = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_SCALIX_STORE_SHOW_SFOLDER, &ex); if (ftree == NULL) { camel_object_unref (store); signal_error (sxas, _("Could not obtain folder listening")); return; } /* Calendar */ signal_progress (sxas, 30, _("Loading calendar data...")); synch_data (sxas, ftree, CAMEL_SCALIX_FOLDER_CALENDAR, 30); m->esg_cals = create_group (priv->account, "Calendar"); sync_source_group (priv->account, m->esg_cals, CAMEL_SCALIX_FOLDER_CALENDAR, ftree); /* Contacts */ signal_progress (sxas, 60, _("Loading contacts...")); synch_data (sxas, ftree, CAMEL_SCALIX_FOLDER_CONTACT, 60); m->esg_cnts = create_group (priv->account, "Contacts"); sync_source_group (priv->account, m->esg_cnts, CAMEL_SCALIX_FOLDER_CONTACT, ftree); create_ldap_source (priv->account, m->esg_cnts); /* Sent Items and Drafts Folder */ if (priv->synch_dfolder) { char *url_str; CamelURL *url; url = camel_url_new (uri, NULL); signal_progress (sxas, 95, _("Synchronizing additional data")); sf = folder_tree_find_special (ftree, CAMEL_SCALIX_FOLDER_SENT); if (url && sf) { url_str = url_set_path_and_get_string (url, sf->full_name); e_account_set_string (priv->account, E_ACCOUNT_SENT_FOLDER_URI, url_str); g_free (url_str); } sf = folder_tree_find_special (ftree, CAMEL_SCALIX_FOLDER_DRAFTS); if (url && sf) { url_str = url_set_path_and_get_string (url, sf->full_name); e_account_set_string (priv->account, E_ACCOUNT_DRAFTS_FOLDER_URI, url_str); g_free (url_str); } if (url) { gboolean save_pw; camel_url_set_path (url, NULL); if (url->authmech == NULL) { camel_url_set_authmech (url, "PLAIN"); } url_str = camel_url_to_string (url, 0); e_account_set_string (priv->account, E_ACCOUNT_TRANSPORT_URL, url_str); save_pw = e_account_get_bool (priv->account, E_ACCOUNT_SOURCE_SAVE_PASSWD); e_account_set_bool (priv->account, E_ACCOUNT_TRANSPORT_SAVE_PASSWD, save_pw); } if (url) { camel_url_free (url); } } m->success = TRUE; g_print ("SxAS: DONE!\n"); camel_object_unref (store); signal_progress (sxas, 100, _("Done loading")); signal_info (sxas, _("Initial loading complete. Please click Forward.")); g_print ("SxAS: Freeing DONE\n"); return; }
static void view_changed(EMFolderView *emfv, EComponentView *component_view) { EInfoLabel *el = g_object_get_data((GObject *)component_view, "info-label"); CORBA_Environment ev; CORBA_exception_init(&ev); if (emfv->folder) { char *name, *title; const char *use_name; /* will contain localized name, if necessary */ guint32 visible, unread, deleted, junked, junked_not_deleted; GPtrArray *selected; GString *tmp = g_string_new(""); camel_object_get(emfv->folder, NULL, CAMEL_FOLDER_NAME, &name, CAMEL_FOLDER_DELETED, &deleted, CAMEL_FOLDER_VISIBLE, &visible, CAMEL_FOLDER_JUNKED, &junked, CAMEL_FOLDER_JUNKED_NOT_DELETED, &junked_not_deleted, CAMEL_FOLDER_UNREAD, &unread, NULL); selected = message_list_get_selected(emfv->list); /* This is so that if any of these are * shared/reused, we fallback to the standard * display behaviour */ if (selected->len > 1) g_string_append_printf(tmp, ngettext ("%d selected, ", "%d selected, ", selected->len), selected->len); if (CAMEL_IS_VTRASH_FOLDER(emfv->folder)) { if (((CamelVTrashFolder *)emfv->folder)->type == CAMEL_VTRASH_FOLDER_TRASH) { g_string_append_printf(tmp, ngettext ("%d deleted", "%d deleted", deleted), deleted); } else { guint32 num = junked_not_deleted; if (!emfv->hide_deleted) num = junked; g_string_append_printf (tmp, ngettext ("%d junk", "%d junk", num), num); } } else if (em_utils_folder_is_drafts(emfv->folder, emfv->folder_uri)) { g_string_append_printf(tmp, ngettext ("%d draft", "%d drafts", visible), visible); } else if (em_utils_folder_is_sent(emfv->folder, emfv->folder_uri)) { g_string_append_printf(tmp, ngettext ("%d sent", "%d sent", visible), visible); } else if (em_utils_folder_is_outbox(emfv->folder, emfv->folder_uri)) { g_string_append_printf(tmp, ngettext ("%d unsent", "%d unsent", visible), visible); /* HACK: hardcoded inbox or maildir '.' folder */ } else { if (!emfv->hide_deleted) visible += deleted - junked + junked_not_deleted; if (unread && selected->len <= 1) g_string_append_printf(tmp, ngettext ("%d unread, ", "%d unread, ", unread), unread); g_string_append_printf(tmp, ngettext ("%d total", "%d total", visible), visible); } message_list_free_uids(emfv->list, selected); if (emfv->folder->parent_store == mail_component_peek_local_store(NULL) && (!strcmp (name, "Drafts") || !strcmp (name, "Inbox") || !strcmp (name, "Outbox") || !strcmp (name, "Sent"))) use_name = _(name); else use_name = name; e_info_label_set_info (el, use_name, tmp->str); title = g_strdup_printf ("%s (%s)", use_name, tmp->str); e_component_view_set_title(component_view, title); g_free(title); g_string_free(tmp, TRUE); camel_object_free(emfv->folder, CAMEL_FOLDER_NAME, name); } else { e_info_label_set_info(el, _("Mail"), ""); e_component_view_set_title(component_view, _("Mail")); } }