~jelmer/ubuntu/natty/evolution-mapi/513394-recurring-events

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
=== modified file 'configure.ac'
--- old/configure.ac	2010-09-27 10:28:11 +0000
+++ new/configure.ac	2011-01-25 18:44:56 +0000
@@ -253,6 +253,20 @@
 fi
 
 dnl ****************************
+dnl Check for MAPIInitialize function with two params
+dnl ****************************
+AC_MSG_CHECKING([libmapi MAPIInitialize function with two params])
+save_cflags=$CFLAGS; CFLAGS=$LIBMAPI_CFLAGS
+save_libs=$LIBS; LIBS="$LIBMAPI_LIBS"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(
+	[[#include <libmapi/libmapi.h>]],
+	[[MAPIInitialize (NULL, NULL)]])],
+	[AC_DEFINE(HAVE_LIBMAPI_CONTEXT_PARAM, 1, [libmapi uses context parameters]) ac_cv_have_lcp=yes],[ac_cv_have_lcp=no])
+CFLAGS=$save_cflags
+LIBS=$save_libs
+AC_MSG_RESULT([$ac_cv_have_lcp])
+
+dnl ****************************
 dnl Expose version information
 dnl ****************************
 API_VERSION=$EDS_PACKAGE

=== modified file 'src/libexchangemapi/exchange-mapi-connection.c'
--- old/src/libexchangemapi/exchange-mapi-connection.c	2010-10-19 10:33:25 +0000
+++ new/src/libexchangemapi/exchange-mapi-connection.c	2011-01-25 19:24:59 +0000
@@ -143,6 +143,10 @@
 	g_propagate_error (perror, error);
 }
 
+#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+struct mapi_context *mapi_ctx = NULL;
+#endif
+
 typedef struct _ExchangeMapiConnectionPrivate ExchangeMapiConnectionPrivate;
 
 struct _ExchangeMapiConnectionPrivate {
@@ -2808,7 +2812,11 @@
 
 	mapi_object_init(&obj_folder_src);
 	mapi_object_init(&obj_folder_dst);
-	mapi_id_array_init(&msg_id_array);
+	mapi_id_array_init (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		&msg_id_array);
 
 	for (l = mid_list; l != NULL; l = g_slist_next (l))
 		mapi_id_array_add_id (&msg_id_array, *((mapi_id_t *)l->data));
@@ -3602,7 +3610,11 @@
 		}
 	}
 
-	ms = MAPIInitialize (profpath);
+	ms = MAPIInitialize (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		&mapi_ctx,
+		#endif
+		profpath);
 	if (ms == MAPI_E_SESSION_LIMIT) {
 		/* do nothing, the profile store is already initialized */
 		/* but this shouldn't happen */
@@ -3664,15 +3676,31 @@
 	/* Initialize libmapi logger*/
 	if (g_getenv ("MAPI_DEBUG")) {
 		debug_log_level = atoi (g_getenv ("MAPI_DEBUG"));
-		SetMAPIDumpData(TRUE);
-		SetMAPIDebugLevel(debug_log_level);
+		SetMAPIDumpData (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			TRUE);
+		SetMAPIDebugLevel (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			debug_log_level);
 	}
 
 	g_debug("Loading profile %s ", profname);
 
-	ms = MapiLogonEx (&session, profname, password);
+	ms = MapiLogonEx (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		&session, profname, password);
 	if (ms == MAPI_E_NOT_FOUND && try_create_profile (profname, password))
-		ms = MapiLogonEx (&session, profname, password);
+		ms = MapiLogonEx (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			&session, profname, password);
 
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "MapiLogonEx", ms);
@@ -3717,34 +3745,60 @@
 	profname = exchange_mapi_util_profile_name (username, domain, server, TRUE);
 
 	/* Delete any existing profiles with the same profilename */
-	ms = DeleteProfile (profname);
+	ms = DeleteProfile (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		profname);
 	/* don't bother to check error - it would be valid if we got an error */
 
-	ms = CreateProfile (profname, username, password, OC_PROFILE_NOPASSWORD);
+	ms = CreateProfile (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		profname, username, password, OC_PROFILE_NOPASSWORD);
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "CreateProfile", ms);
 		goto cleanup;
 	}
 
-	mapi_profile_add_string_attr(profname, "binding", server);
-	mapi_profile_add_string_attr(profname, "workstation", workstation);
-	mapi_profile_add_string_attr(profname, "domain", domain);
+	#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+	#define add_string_attr(_prof,_aname,_val)				\
+		mapi_profile_add_string_attr (mapi_ctx, _prof, _aname, _val)
+	#else
+	#define add_string_attr(_prof,_aname,_val)				\
+		mapi_profile_add_string_attr (_prof, _aname, _val)
+	#endif
+
+	add_string_attr (profname, "binding", server);
+	add_string_attr (profname, "workstation", workstation);
+	add_string_attr (profname, "domain", domain);
 
 	if ((flags & CREATE_PROFILE_FLAG_USE_SSL) != 0)
-		mapi_profile_add_string_attr (profname, "seal", "true");
+		add_string_attr (profname, "seal", "true");
 
 	/* This is only convenient here and should be replaced at some point */
-	mapi_profile_add_string_attr(profname, "codepage", "0x4e4");
-	mapi_profile_add_string_attr(profname, "language", "0x409");
-	mapi_profile_add_string_attr(profname, "method", "0x409");
+	add_string_attr (profname, "codepage", "0x4e4");
+	add_string_attr (profname, "language", "0x409");
+	add_string_attr (profname, "method", "0x409");
+
+	#undef add_string_attr
 
 	/* Login now */
 	g_debug("Logging into the server... ");
-	ms = MapiLogonProvider (&session, profname, password, PROVIDER_ID_NSPI);
+	ms = MapiLogonProvider (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		&session, profname, password, PROVIDER_ID_NSPI);
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "MapiLogonProvider", ms);
 		g_debug ("Deleting profile %s ", profname);
-		DeleteProfile (profname);
+		DeleteProfile (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			profname);
 		goto cleanup;
 	}
 	g_debug("MapiLogonProvider : succeeded \n");
@@ -3753,7 +3807,11 @@
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "ProcessNetworkProfile", ms);
 		g_debug ("Deleting profile %s ", profname);
-		DeleteProfile (profname);
+		DeleteProfile (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			profname);
 		goto cleanup;
 	}
 	g_debug("ProcessNetworkProfile : succeeded \n");
@@ -3807,7 +3865,11 @@
 
 		g_debug ("Deleting profile %s ", profile);
 
-		ms = DeleteProfile (profile);
+		ms = DeleteProfile (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			profile);
 		if (ms == MAPI_E_SUCCESS) {
 			result = TRUE;
 		} else {
@@ -3820,4 +3882,21 @@
 	return result;
 }
 
+void
+exchange_mapi_rename_profile (const gchar *old_name, const gchar *new_name)
+{
+	g_return_if_fail (old_name != NULL);
+	g_return_if_fail (new_name != NULL);
+
+	g_static_rec_mutex_lock (&profile_mutex);
+
+	RenameProfile (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		old_name, new_name);
+
+	g_static_rec_mutex_unlock (&profile_mutex);
+}
+
 /* profile related functions - end */

=== modified file 'src/libexchangemapi/exchange-mapi-connection.h'
--- old/src/libexchangemapi/exchange-mapi-connection.h	2010-08-02 22:02:21 +0000
+++ new/src/libexchangemapi/exchange-mapi-connection.h	2011-01-25 18:44:56 +0000
@@ -240,6 +240,7 @@
 				       mapi_profile_callback_t cb, gpointer data, GError **perror);
 
 gboolean		exchange_mapi_delete_profile (const gchar *profile, GError **perror);
+void			exchange_mapi_rename_profile (const gchar *old_name, const gchar *new_name);
 
 /* utility functions */
 

=== modified file 'src/libexchangemapi/exchange-mapi-utils.c'
--- old/src/libexchangemapi/exchange-mapi-utils.c	2010-11-02 17:03:41 +0000
+++ new/src/libexchangemapi/exchange-mapi-utils.c	2011-01-25 18:44:56 +0000
@@ -947,7 +947,7 @@
 		old_name = g_strdup_printf ("%s@%s", username, domain);
 		old_name = g_strcanon (old_name, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@", '_');
 
-		RenameProfile (old_name, res);
+		exchange_mapi_rename_profile (old_name, res);
 
 		g_free (old_name);
 	}