evolution-data-server r8421 - in branches/EXCHANGE_MAPI_BRANCH: camel/providers/mapi servers/mapi
- From: jjohnny svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8421 - in branches/EXCHANGE_MAPI_BRANCH: camel/providers/mapi servers/mapi
- Date: Fri, 25 Jan 2008 10:49:38 +0000 (GMT)
Author: jjohnny
Date: Fri Jan 25 10:49:38 2008
New Revision: 8421
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8421&view=rev
Log:
Added rename_folder support.
Modified:
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h
Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c Fri Jan 25 10:49:38 2008
@@ -594,7 +594,69 @@
static void
mapi_rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex)
{
+ CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
+ CamelMapiStorePrivate *priv = mapi_store->priv;
+ char *oldpath, *newpath, *storepath;
+ const char *folder_id;
+ char *temp_new = NULL;
+ mapi_id_t fid;
+
+ if (mapi_is_system_folder (old_name)) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename Mapi folder `%s' to `%s'"),
+ old_name, new_name);
+ return;
+ }
+
+ CAMEL_SERVICE_REC_LOCK (mapi_store, connect_lock);
+
+ if (!camel_mapi_store_connected ((CamelMapiStore *)store, ex)) {
+ CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
+ return;
+ }
+
+ folder_id = camel_mapi_store_folder_id_lookup (mapi_store, old_name);
+ if (!folder_id) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename MAPI folder `%s'. Folder doesn't exist"),
+ old_name);
+ CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
+ return;
+ }
+
+ exchange_mapi_util_mapi_id_from_string (folder_id, &fid);
+
+ temp_new = strrchr (new_name, '/');
+ if (temp_new)
+ temp_new++;
+ else
+ temp_new = (char *)new_name;
+
+ if (!exchange_mapi_rename_folder (NULL, fid , temp_new))
+ {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename MAPI folder `%s' to `%s'"),
+ old_name, new_name);
+ CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
+ return;
+ }
+
+ g_hash_table_replace (priv->id_hash, g_strdup(folder_id), g_strdup(temp_new));
+
+ g_hash_table_insert (priv->name_hash, g_strdup(new_name), g_strdup(folder_id));
+ g_hash_table_remove (priv->name_hash, old_name);
+
+ storepath = g_strdup_printf ("%s/folders", priv->storage_path);
+ oldpath = e_path_to_physical (storepath, old_name);
+ newpath = e_path_to_physical (storepath, new_name);
+ g_free (storepath);
+
+ /*XXX: make sure the summary is also renamed*/
+ if (g_rename (oldpath, newpath) == -1) {
+ g_warning ("Could not rename message cache '%s' to '%s': %s: cache reset",
+ oldpath, newpath, strerror (errno));
+ }
+ g_free (oldpath);
+ g_free (newpath);
+ CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
}
char *
Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c Fri Jan 25 10:49:38 2008
@@ -1171,6 +1171,62 @@
return result;
}
+/*FixME : Why are we still having olFolder in our APIs ?? - Johnny */
+gboolean
+exchange_mapi_rename_folder (uint32_t olFolder, mapi_id_t fid, const char *new_name)
+{
+ enum MAPISTATUS retval;
+ mapi_object_t obj_store;
+ mapi_object_t obj_folder;
+ ExchangeMAPIFolder *folder;
+ struct SPropValue *props = NULL;
+ TALLOC_CTX *mem_ctx;
+ gboolean result = FALSE;
+
+ mem_ctx = talloc_init("ExchangeMAPI_RenameFolder");
+
+ folder = exchange_mapi_folder_get_folder (fid);
+
+ g_return_val_if_fail (folder != NULL, FALSE);
+
+ LOCK ();
+
+ mapi_object_init(&obj_store);
+ mapi_object_init(&obj_folder);
+
+ retval = OpenMsgStore(&obj_store);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("OpenMsgStore", GetLastError());
+ goto cleanup;
+ }
+
+ /* Open the folder to be renamed */
+ retval = OpenFolder(&obj_store, fid, &obj_folder);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("OpenFolder", GetLastError());
+ goto cleanup;
+ }
+
+ props = talloc_zero(mem_ctx, struct SPropValue);
+ set_SPropValue_proptag (props, PR_DISPLAY_NAME, new_name );
+
+ retval = SetProps(&obj_folder, props, 1);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("SetProps", GetLastError());
+ goto cleanup;
+ }
+
+ result = TRUE;
+
+cleanup:
+ mapi_object_release(&obj_folder);
+ mapi_object_release(&obj_store);
+ talloc_free(mem_ctx);
+ UNLOCK ();
+
+ return result;
+}
+
mapi_id_t
exchange_mapi_create_item (uint32_t olFolder, mapi_id_t fid,
BuildNameID build_name_id, gpointer ni_data,
Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h (original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h Fri Jan 25 10:49:38 2008
@@ -91,6 +91,8 @@
exchange_mapi_create_folder (uint32_t olFolder, mapi_id_t pfid, const char *name);
gboolean
exchange_mapi_remove_folder (uint32_t olFolder, mapi_id_t fid);
+gboolean
+exchange_mapi_rename_folder (uint32_t olFolder, mapi_id_t fid, const char *new_name);
mapi_id_t
exchange_mapi_create_item (uint32_t olFolder, mapi_id_t fid,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]