[evolution-mapi] Added push notification event APIs.



commit 6ce26399985aa0668a4a833f6fd1e88ee8b27bbe
Author: Johnny Jacob <jjohnny novell com>
Date:   Fri Nov 6 10:30:52 2009 +0530

    Added push notification event APIs.

 src/libexchangemapi/exchange-mapi-connection.c |   60 ++++++++++++++++++++++++
 src/libexchangemapi/exchange-mapi-connection.h |   25 +++++++++-
 2 files changed, 84 insertions(+), 1 deletions(-)
---
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index b0fe61a..4f50166 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -3007,6 +3007,66 @@ exchange_mapi_util_ex_to_smtp (const gchar *ex_address)
 	return smtp_addr;
 }
 
+gboolean
+exchange_mapi_events_init ()
+{
+	enum MAPISTATUS retval;
+
+	retval = RegisterNotification(0);
+
+	return (retval == MAPI_E_SUCCESS);
+}
+
+gboolean
+exchange_mapi_events_subscribe (mapi_id_t *obj_id, guint32 options,
+				guint16 event_mask, guint32 *connection,
+				mapi_notify_callback_t callback, gpointer data)
+{
+	enum MAPISTATUS	retval;
+	mapi_object_t obj_target;
+	gboolean use_store = ((options & MAPI_EVENTS_USE_STORE) ||
+			      (options & MAPI_EVENTS_USE_PF_STORE));
+
+	mapi_object_init(&obj_target);
+
+	if (options & MAPI_EVENTS_USE_STORE) {
+		retval = OpenMsgStore(global_mapi_session, &obj_target);
+		if (retval != MAPI_E_SUCCESS) {
+			mapi_errstr("OpenMsgStore", GetLastError());
+			return false;
+		}
+	} else if (options & MAPI_EVENTS_USE_PF_STORE) {
+		/* TODO */
+	} else if (options & MAPI_EVENTS_FOLDER) {
+		/* TODO */
+	}
+
+	retval = Subscribe(&obj_target, connection, event_mask, use_store,
+			   (mapi_notify_callback_t) callback, data);
+
+	return (retval == MAPI_E_SUCCESS);
+}
+
+gboolean exchange_mapi_events_unsubscribe (mapi_object_t *obj, guint32 connection)
+{
+	enum MAPISTATUS	retval;
+
+	retval = Unsubscribe(mapi_object_get_session(obj), connection);
+
+	return (retval == MAPI_E_SUCCESS);
+}
+
+/* Note : Blocking infinite loop. */
+gboolean exchange_mapi_events_monitor (gpointer data)
+{
+	enum MAPISTATUS	retval;
+
+	/*Fixme : If we do multiple sessions. Fix this */
+	retval = MonitorNotification(global_mapi_session, (void *)data);
+
+	return (retval == MAPI_E_SUCCESS);
+}
+
 /* Shows error message on the console, and, if error_msg is not NULL, then
    sets it to the similar error message as well. */
 static void
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index 8a2e0bb..3363472 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -42,12 +42,18 @@ typedef enum {
 	MAPI_OPTIONS_DELETE_ON_SUBMIT_FAILURE = 1<<9
 } ExchangeMAPIOptions;
 
+/* Flags for push notification APIs*/
+typedef enum {
+	MAPI_EVENTS_USE_STORE = 1<<0,
+	MAPI_EVENTS_USE_PF_STORE = 1<<1,
+	MAPI_EVENTS_FOLDER = 1<<2,
+} ExchangeMAPIEventsOptions;
+
 #define MAPI_OPTIONS_FETCH_ALL MAPI_OPTIONS_FETCH_ATTACHMENTS | \
 	                       MAPI_OPTIONS_FETCH_RECIPIENTS | \
 	                       MAPI_OPTIONS_FETCH_BODY_STREAM | \
 	                       MAPI_OPTIONS_FETCH_GENERIC_STREAMS
 
-
 typedef struct {
 	GByteArray *value;
 	uint32_t proptag;
@@ -206,4 +212,21 @@ gboolean exchange_mapi_create_profile (const char *username, const char *passwor
 				       char **error_msg, mapi_profile_callback_t cb, gpointer data);
 gboolean exchange_mapi_delete_profile (const char *profile);
 
+
+/* Push notifications APIs */
+gboolean exchange_mapi_events_init ();
+
+gboolean exchange_mapi_events_monitor (gpointer data);
+
+gboolean exchange_mapi_events_subscribe (mapi_id_t *obj_id, guint32 options,
+					 guint16 event_mask, guint32 *connection,
+					 mapi_notify_callback_t callback, gpointer data);
+
+gboolean exchange_mapi_events_unsubscribe (mapi_object_t *obj, guint32 connection);
+
+gboolean
+exchange_mapi_events_subscribe_and_monitor (mapi_id_t *obj_id, guint32 options,
+					    guint16 event_mask, guint32 *connection,
+					    gboolean use_store, mapi_notify_callback_t callback,
+					    gpointer data);
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]