[evolution-mapi] Moved notification functions to camel-mapi-notifcations.[ch]
- From: Johnny Jacob <jjohnny src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Moved notification functions to camel-mapi-notifcations.[ch]
- Date: Tue, 19 Jan 2010 08:51:56 +0000 (UTC)
commit fcdb250052e55b735bba9d08e6abc9583c08e540
Author: Johnny Jacob <jjohnny novell com>
Date: Tue Nov 10 15:44:58 2009 +0530
Moved notification functions to camel-mapi-notifcations.[ch]
src/camel/Makefile.am | 2 +
src/camel/camel-mapi-notifications.c | 160 ++++++++++++++++++++++++++++++++++
src/camel/camel-mapi-notifications.h | 36 ++++++++
src/camel/camel-mapi-store.c | 111 ++----------------------
4 files changed, 206 insertions(+), 103 deletions(-)
---
diff --git a/src/camel/Makefile.am b/src/camel/Makefile.am
index b2f710c..d3116d6 100644
--- a/src/camel/Makefile.am
+++ b/src/camel/Makefile.am
@@ -19,6 +19,7 @@ libcamelmapi_la_SOURCES = \
camel-mapi-store-summary.c \
camel-mapi-summary.c \
camel-mapi-utils.c \
+ camel-mapi-notifications.c \
camel-mapi-transport.c
noinst_HEADERS = \
@@ -28,6 +29,7 @@ noinst_HEADERS = \
camel-mapi-summary.h \
camel-mapi-transport.h \
camel-mapi-utils.h \
+ camel-mapi-notifications.h \
camel-mapi-private.h \
camel-private.h
diff --git a/src/camel/camel-mapi-notifications.c b/src/camel/camel-mapi-notifications.c
new file mode 100644
index 0000000..0643e5b
--- /dev/null
+++ b/src/camel/camel-mapi-notifications.c
@@ -0,0 +1,160 @@
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Johnny Jacob <jjohnny novell com>
+ *
+ * Copyright (C) 1999-2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include <glib/gstdio.h>
+
+#include <camel/camel-private.h>
+#include <camel/camel-session.h>
+#include <camel/camel-service.h>
+#include <camel/camel-store-summary.h>
+#include <camel/camel-i18n.h>
+#include <camel/camel-net-utils.h>
+
+#include "camel-mapi-store.h"
+#include "camel-mapi-folder.h"
+#include "camel-mapi-store-summary.h"
+#include "camel-mapi-summary.h"
+#include "camel-mapi-notifications.h"
+
+#include <exchange-mapi-utils.h>
+
+#define d_notifications(x) x
+
+static void
+mapi_push_notification_listener (CamelSession *session, CamelSessionThreadMsg *msg);
+static void
+mapi_push_notification_listener_close (CamelSession *session, CamelSessionThreadMsg *msg);
+
+struct mapi_push_notification_msg {
+ CamelSessionThreadMsg msg;
+
+ guint16 event_mask;
+ guint32 *connection;
+ guint32 event_options;
+ gpointer event_data;
+};
+
+static gint
+mapi_notifications_filter (guint16 type, void *event, void *private_data)
+{
+ switch(type) {
+ /* -- Folder Events -- */
+ case fnevObjectCreated:
+ d_notifications(printf ("Event : Folder Created\n"));
+ d_notifications(mapidump_foldercreated (event, "\t"));
+ break;
+ case fnevObjectDeleted:
+ d_notifications(printf ("Event : Folder Deleted\n"));
+ d_notifications(mapidump_folderdeleted (event, "\t"));
+ break;
+ case fnevObjectMoved:
+ d_notifications(printf ("Event : Folder Moved\n"));
+ d_notifications(mapidump_foldermoved (event, "\t"));
+ break;
+ case fnevObjectCopied:
+ d_notifications(printf ("Event : Folder Copied\n"));
+ d_notifications(mapidump_foldercopied (event, "\t"));
+ break;
+ /* -- Message Events -- */
+ case fnevNewMail:
+ case fnevNewMail|fnevMbit:
+ d_notifications(printf ("Event : New mail\n"));
+ new_mail_handler (event);
+ break;
+ case fnevMbit|fnevObjectCreated:
+ d_notifications(printf ("Event : Message created\n"));
+ d_notifications(mapidump_messagecreated (event, "\t"));
+ break;
+ case fnevMbit|fnevObjectDeleted:
+ d_notifications(printf ("Event : Message deleted\n"));
+ d_notifications(mapidump_messagedeleted (event, "\t"));
+ case fnevMbit|fnevObjectModified:
+ d_notifications(printf ("Event : Message modified\n"));
+ d_notifications(mapidump_messagemodified (event, "\t"));
+ case fnevMbit|fnevObjectMoved:
+ d_notifications(printf ("Event : Message moved\n"));
+ d_notifications(mapidump_messagemoved (event, "\t"));
+ case fnevMbit|fnevObjectCopied:
+ d_notifications(printf ("Event : Message copied\n"));
+ d_notifications(mapidump_messagecopied (event, "\t"));
+ default:
+ /* Unsupported */
+ break;
+ }
+ return 0;
+}
+
+
+static CamelSessionThreadOps mapi_push_notification_ops = {
+ mapi_push_notification_listener,
+ mapi_push_notification_listener_close,
+};
+
+static void
+mapi_push_notification_listener (CamelSession *session, CamelSessionThreadMsg *msg)
+{
+ struct mapi_push_notification_msg *m = (struct mapi_push_notification_msg *)msg;
+
+ if (exchange_mapi_events_init ()) {
+ exchange_mapi_events_subscribe (0, m->event_options, m->event_mask,
+ &m->connection, mapi_notifications_filter,
+ m->event_data);
+
+ /* Need a better API for canceling this operation*/
+ exchange_mapi_events_monitor (NULL);
+ }
+
+}
+
+static void
+mapi_push_notification_listener_close (CamelSession *session, CamelSessionThreadMsg *msg)
+{
+ /*TODO*/
+}
+
+void
+camel_mapi_notfication_listener_start (CamelMapiStore *store, guint16 mask,
+ guint32 options)
+{
+ CamelSession *session = ((CamelService *)store)->session;
+ struct mapi_push_notification_msg *mapi_push_notification_msg_op;
+
+ mapi_push_notification_msg_op =
+ camel_session_thread_msg_new (session, &mapi_push_notification_ops,
+ sizeof (*mapi_push_notification_msg_op));
+
+ mapi_push_notification_msg_op->event_options = options;
+ mapi_push_notification_msg_op->event_mask = mask;
+ mapi_push_notification_msg_op->event_data = NULL;
+
+ camel_session_thread_queue (session, &mapi_push_notification_msg_op->msg, 0);
+}
diff --git a/src/camel/camel-mapi-notifications.h b/src/camel/camel-mapi-notifications.h
new file mode 100644
index 0000000..4c72aef
--- /dev/null
+++ b/src/camel/camel-mapi-notifications.h
@@ -0,0 +1,36 @@
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Johnny Jacob <jjohnny novell com>
+ *
+ * Copyright (C) 1999-2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/* For push notification listener*/
+
+#ifndef _CAMEL_MAPI_NOTIFICATIONS_H
+#define _CAMEL_MAPI_NOTIFICATIONS_H
+
+G_BEGIN_DECLS
+
+void
+camel_mapi_notfication_listener_start (CamelMapiStore *store, guint16 mask,
+ guint32 options);
+G_END_DECLS
+
+#endif
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 0110fcd..a668f11 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -51,10 +51,11 @@
#include "camel-mapi-folder.h"
#include "camel-mapi-store-summary.h"
#include "camel-mapi-summary.h"
+#include "camel-mapi-notifications.h"
#include <exchange-mapi-utils.h>
//#define d(x) x
-#define d_notifications(x) x
+
/* This definition should be in-sync with those in exchange-mapi-account-setup.c and exchange-account-listener.c */
#define E_PASSWORD_COMPONENT "ExchangeMAPI"
@@ -119,10 +120,6 @@ static const gchar* mapi_folders_hash_table_pfid_lookup (CamelMapiStore *store,
static const gchar* mapi_folders_hash_table_fid_lookup (CamelMapiStore *store, const gchar *name, gboolean use_cache);
#endif
-static void
-mapi_push_notification_listener (CamelSession *session, CamelSessionThreadMsg *msg);
-static void
-mapi_push_notification_listener_close (CamelSession *session, CamelSessionThreadMsg *msg);
static guint
mapi_hash_folder_name(gconstpointer key)
@@ -1210,93 +1207,6 @@ mapi_folders_hash_table_pfid_lookup (CamelMapiStore *store, const gchar *fid,
return pfid;
}
-static gint
-notifications_filter (guint16 type, void *data,
- void *private_data)
-{
- switch(type) {
- /* -- Folder Events -- */
- case fnevObjectCreated:
- d_notifications(printf ("Event : Folder Created\n"));
- d_notifications(mapidump_foldercreated (data, "\t"));
- break;
- case fnevObjectDeleted:
- d_notifications(printf ("Event : Folder Deleted\n"));
- d_notifications(mapidump_folderdeleted (data, "\t"));
- break;
- case fnevObjectMoved:
- d_notifications(printf ("Event : Folder Moved\n"));
- d_notifications(mapidump_foldermoved (data, "\t"));
- break;
- case fnevObjectCopied:
- d_notifications(printf ("Event : Folder Copied\n"));
- d_notifications(mapidump_foldercopied (data, "\t"));
- break;
- /* -- Message Events -- */
- case fnevNewMail:
- case fnevNewMail|fnevMbit:
- d_notifications(printf ("Event : New mail\n"));
- d_notifications(mapidump_newmail (data, "\t"));
- break;
- case fnevMbit|fnevObjectCreated:
- d_notifications(printf ("Event : Message created\n"));
- d_notifications(mapidump_messagecreated (data, "\t"));
- break;
- case fnevMbit|fnevObjectDeleted:
- d_notifications(printf ("Event : Message deleted\n"));
- d_notifications(mapidump_messagedeleted (data, "\t"));
- case fnevMbit|fnevObjectModified:
- d_notifications(printf ("Event : Message modified\n"));
- d_notifications(mapidump_messagemodified (data, "\t"));
- case fnevMbit|fnevObjectMoved:
- d_notifications(printf ("Event : Message moved\n"));
- d_notifications(mapidump_messagemoved (data, "\t"));
- case fnevMbit|fnevObjectCopied:
- d_notifications(printf ("Event : Message copied\n"));
- d_notifications(mapidump_messagecopied (data, "\t"));
- default:
- /* Unsupported */
- break;
- }
- return 0;
-}
-
-/* For push notification listener*/
-struct mapi_push_notification_msg {
- CamelSessionThreadMsg msg;
-
- guint16 event_mask;
- guint32 *connection;
- guint32 event_options;
- gpointer event_data;
-};
-
-static CamelSessionThreadOps mapi_push_notification_ops = {
- mapi_push_notification_listener,
- mapi_push_notification_listener_close,
-};
-
-static void
-mapi_push_notification_listener (CamelSession *session, CamelSessionThreadMsg *msg)
-{
- struct mapi_push_notification_msg *m = (struct mapi_push_notification_msg *)msg;
-
- if (exchange_mapi_events_init ()) {
- exchange_mapi_events_subscribe (0, m->event_options, m->event_mask,
- &m->connection,
- notifications_filter, m->event_data);
-
- exchange_mapi_events_monitor (NULL);
- }
-
-}
-
-static void
-mapi_push_notification_listener_close (CamelSession *session, CamelSessionThreadMsg *msg)
-{
- /*TODO*/
-}
-
static void
mapi_folders_sync (CamelMapiStore *store, const char *top, guint32 flags, CamelException *ex)
{
@@ -1310,7 +1220,7 @@ mapi_folders_sync (CamelMapiStore *store, const char *top, guint32 flags, CamelE
guint32 count, i;
CamelStoreInfo *si = NULL;
CamelSession *session = ((CamelService *)store)->session;
- struct mapi_push_notification_msg *mapi_push_notification_msg_op;
+ guint16 event_mask = 0;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
if (((CamelService *)store)->status == CAMEL_SERVICE_DISCONNECTED){
@@ -1444,20 +1354,15 @@ mapi_folders_sync (CamelMapiStore *store, const char *top, guint32 flags, CamelE
// g_hash_table_foreach (present, get_folders_free, NULL);
// g_hash_table_destroy (present);
+ /* FIXME : This place is not right! */
/* Start Push Notification listener */
- mapi_push_notification_msg_op =
- camel_session_thread_msg_new (session,
- &mapi_push_notification_ops,
- sizeof (*mapi_push_notification_msg_op));
-
- mapi_push_notification_msg_op->event_options = MAPI_EVENTS_USE_STORE;
- mapi_push_notification_msg_op->event_mask = fnevNewMail | fnevObjectCreated |
- fnevObjectDeleted | fnevObjectModified |
- fnevObjectMoved | fnevObjectCopied;
+ event_mask = fnevNewMail | fnevObjectCreated | fnevObjectDeleted |
+ fnevObjectModified | fnevObjectMoved | fnevObjectCopied;
- camel_session_thread_queue (session, &mapi_push_notification_msg_op->msg, 0);
+ camel_mapi_notfication_listener_start (store, event_mask, MAPI_EVENTS_USE_STORE);
}
+
static CamelFolderInfo*
mapi_get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelException *ex)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]