static void get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info) { CamelException ex; camel_exception_init (&ex); while (info) { if (camel_store_can_refresh_folder (store, info, &ex)) g_ptr_array_add (folders, g_strdup (info->uri)); camel_exception_clear (&ex); get_folders (store, folders, info->child); info = info->next; } }
static int groupwise_entry_play_append (CamelOfflineJournal *journal, CamelGroupwiseJournalEntry *entry, CamelException *ex) { CamelGroupwiseFolder *gw_folder = (CamelGroupwiseFolder *) journal->folder; CamelFolder *folder = journal->folder; CamelMimeMessage *message; CamelMessageInfo *info; CamelStream *stream; CamelException lex; /* if the message isn't in the cache, the user went behind our backs so "not our problem" */ if (!gw_folder->cache || !(stream = camel_data_cache_get (gw_folder->cache, "cache", entry->uid, ex))) goto done; message = camel_mime_message_new (); if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) { camel_object_unref (message); camel_object_unref (stream); goto done; } camel_object_unref (stream); if (!(info = camel_folder_summary_uid (folder->summary, entry->uid))) { /* Note: this should never happen, but rather than crash lets make a new info */ info = camel_message_info_new (NULL); } camel_exception_init (&lex); camel_folder_append_message (folder, message, info, NULL, &lex); camel_message_info_free (info); camel_object_unref (message); if (camel_exception_is_set (&lex)) { camel_exception_xfer (ex, &lex); return -1; } done: camel_folder_summary_remove_uid (folder->summary, entry->uid); camel_data_cache_remove (gw_folder->cache, "cache", entry->uid, NULL); return 0; }
static void *session_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size) { CamelSessionThreadMsg *m; g_assert(size >= sizeof(*m)); m = g_malloc0(size); m->ops = ops; m->session = session; camel_object_ref(session); m->op = camel_operation_new(cs_thread_status, m); camel_exception_init(&m->ex); CAMEL_SESSION_LOCK(session, thread_lock); m->id = session->priv->thread_id++; g_hash_table_insert(session->priv->thread_active, GINT_TO_POINTER(m->id), m); CAMEL_SESSION_UNLOCK(session, thread_lock); return m; }
static void impl_upgradeFromVersion (PortableServer_Servant servant, const short major, const short minor, const short revision, CORBA_Environment *ev) { MailComponent *component; CamelException ex; component = mail_component_peek (); camel_exception_init (&ex); if (em_migrate (e_get_user_data_dir (), major, minor, revision, &ex) == -1) { GNOME_Evolution_Component_UpgradeFailed *failedex; failedex = GNOME_Evolution_Component_UpgradeFailed__alloc(); failedex->what = CORBA_string_dup(_("Failed upgrading Mail settings or folders.")); failedex->why = CORBA_string_dup(ex.desc); CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex); } camel_exception_clear (&ex); }
void camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelException *ex) { CamelException lex; CamelService *service = CAMEL_SERVICE (store); gboolean network_state = camel_session_get_network_state (service->session); camel_exception_init (&lex); if (network_state) { if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) { if (((CamelStore *) store)->folders) { GPtrArray *folders; CamelFolder *folder; int i, sync; sync = camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL; folders = camel_object_bag_list (((CamelStore *) store)->folders); for (i = 0; i < folders->len; i++) { folder = folders->pdata[i]; if (CAMEL_CHECK_TYPE (folder, CAMEL_OFFLINE_FOLDER_TYPE) && (sync || ((CamelOfflineFolder *) folder)->sync_offline)) { camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex); camel_exception_clear (&lex); } camel_object_unref (folder); } g_ptr_array_free (folders, TRUE); } } camel_store_sync (CAMEL_STORE (store), FALSE, &lex); camel_exception_clear (&lex); } }
/* 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; }