[evolution-mapi/free-busy] FreeBusy feature initial check-in



commit a76b4e9db6e93850f12a1c75bfe5ae8b803882ce
Author: Bharath Acharya <abharath novell com>
Date:   Fri Mar 26 13:47:42 2010 +0530

    FreeBusy feature initial check-in
    
    Fetches the freebusy information of all the attendees added in the meeting editor.
    Dumps the data on the terminal.

 src/calendar/e-cal-backend-mapi.c              |    5 +-
 src/libexchangemapi/exchange-mapi-connection.c |  110 ++++++++++++++++++++++++
 src/libexchangemapi/exchange-mapi-connection.h |    3 +
 3 files changed, 117 insertions(+), 1 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index f4c6e6b..79a88a7 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -2153,8 +2153,11 @@ static ECalBackendSyncStatus
 e_cal_backend_mapi_get_free_busy (ECalBackendSync *backend, EDataCal *cal, 
 				  GList *users, time_t start, time_t end, GList **freebusy)
 {
+	GList *l;
 
-	return GNOME_Evolution_Calendar_Success;	
+	for ( l = users; l != NULL; l = g_list_next (l))
+		exchange_mapi_util_get_free_busy_data (l->data, start, end, freebusy);
+	return GNOME_Evolution_Calendar_Success;
 
 }
 
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 7ae454d..f3d476f 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -801,6 +801,114 @@ mapidump_PAB_gal_entry (struct SRow *aRow)
 }
 
 gboolean
+exchange_mapi_util_get_free_busy_data (const gchar *user, time_t start, time_t end, GList **freebusy)//, icaltimezone *default_zone)
+{
+	struct SPropTagArray	*SPropTagArray;
+	struct SRowSet		*SRowSet;
+	struct SRow		aRow;
+	const struct BinaryArray_r	*all_events;
+	enum MAPISTATUS		retval;
+	uint32_t		i;
+	uint32_t		count;
+	uint8_t			ulFlags;
+	const char     		*message_name;
+	mapi_object_t		obj_store;
+	GList *l;
+
+	const uint32_t			*publish_start;
+	const uint32_t			*publish_end;
+	const struct LongArray_r       	*busy_months;
+	const struct BinaryArray_r	*busy_events;
+	const struct LongArray_r       	*tentative_months;
+	const struct BinaryArray_r	*tentative_events;
+	const struct LongArray_r       	*oof_months;
+	const struct BinaryArray_r	*oof_events;
+	uint32_t			year;
+	uint32_t			event_year;
+
+/*	session = mapi_object_get_session(obj_store);
+	OPENCHANGE_RETVAL_IF(!session, MAPI_E_SESSION_LIMIT, NULL);
+*/	
+	TALLOC_CTX *mem_ctx;
+
+	mem_ctx = talloc_init ("ExchangeMAPI_GetFreeBusy");
+
+	mapi_object_init (&obj_store);
+
+	retval = OpenPublicFolder (global_mapi_session, &obj_store);
+
+	if (retval != MAPI_E_SUCCESS) {
+		mapi_errstr ("OpenPublicFolder", GetLastError());
+		exit(1);
+	}
+
+	g_print ("\n The user is %s\n", user);
+
+	retval = GetUserFreeBusyData (&obj_store, user, &aRow);
+
+//	all_events = (const struct BinaryArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_ALL_EVENTS);
+		/* Step 1. Retrieve FreeBusy data for the given user */
+	if (retval != MAPI_E_SUCCESS) return false;
+
+	/* Step 2. Dump properties */
+	message_name = (const char *) find_SPropValue_data(&aRow, PR_NORMALIZED_SUBJECT);
+	publish_start = (const uint32_t *) find_SPropValue_data(&aRow, PR_FREEBUSY_START_RANGE);
+	publish_end = (const uint32_t *) find_SPropValue_data(&aRow, PR_FREEBUSY_END_RANGE);
+	busy_months = (const struct LongArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_BUSY_MONTHS);
+	busy_events = (const struct BinaryArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_BUSY_EVENTS);
+	tentative_months = (const struct LongArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_TENTATIVE_MONTHS);
+	tentative_events = (const struct BinaryArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_TENTATIVE_EVENTS);
+	oof_months = (const struct LongArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_OOF_MONTHS);
+	oof_events = (const struct BinaryArray_r *) find_SPropValue_data(&aRow, PR_FREEBUSY_OOF_EVENTS);
+
+	year = GetFreeBusyYear(publish_start);
+
+	DEBUG(0, ("FreeBusy (%s):\n", message_name));
+//	mapidump_date_SPropValue(aRow.lpProps[1], "* FreeBusy Last Modification Time");
+	mapidump_freebusy_date(*publish_start, "\t* FreeBusy Publishing Start:");
+	mapidump_freebusy_date(*publish_end, "\t *FreeBusy Publishing End:  ");
+
+	DEBUG(0, ("FreeBusy (%s):\n", message_name));
+//	mapidump_date_SPropValue(aRow.lpProps[1], "* FreeBusy Last Modification Time");
+	mapidump_freebusy_date(*publish_start, "\t* FreeBusy Publishing Start:");
+	mapidump_freebusy_date(*publish_end, "\t *FreeBusy Publishing End:  ");
+
+	if (busy_months && ((*(const uint32_t *) busy_months) != MAPI_E_NOT_FOUND) &&
+	    busy_events && ((*(const uint32_t *) busy_events) != MAPI_E_NOT_FOUND)) {
+		DEBUG(0, ("\t* Busy Events:\n"));
+		for (i = 0; i < busy_months->cValues; i++) {
+			event_year = mapidump_freebusy_year(busy_months->lpl[i], year);
+			DEBUG(0, ("\t\t* %s %u:\n", mapidump_freebusy_month(busy_months->lpl[i], event_year), event_year)); 
+			mapidump_freebusy_event(&busy_events->lpbin[i], busy_months->lpl[i], event_year, "\t\t\t* ");
+		}
+	}
+
+	if (tentative_months && ((*(const uint32_t *) tentative_months) != MAPI_E_NOT_FOUND) &&
+	    tentative_events && ((*(const uint32_t *) tentative_events) != MAPI_E_NOT_FOUND)) {
+		DEBUG(0, ("\t* Tentative Events:\n"));
+		for (i = 0; i < tentative_months->cValues; i++) {
+			event_year = mapidump_freebusy_year(tentative_months->lpl[i], year);
+			DEBUG(0, ("\t\t* %s %u:\n", mapidump_freebusy_month(tentative_months->lpl[i], event_year), event_year));
+			mapidump_freebusy_event(&tentative_events->lpbin[i], tentative_months->lpl[i], event_year, "\t\t\t* ");
+		}
+	}
+
+	if (oof_months && ((*(const uint32_t *) oof_months) != MAPI_E_NOT_FOUND) &&
+	    oof_events && ((*(const uint32_t *) oof_events) != MAPI_E_NOT_FOUND)) {
+		DEBUG(0, ("\t* Out Of Office Events:\n"));
+		for (i = 0; i < oof_months->cValues; i++) {
+			event_year = mapidump_freebusy_year(oof_months->lpl[i], year);
+			DEBUG(0, ("\t\t* %s %u:\n", mapidump_freebusy_month(oof_months->lpl[i], event_year), event_year));
+			mapidump_freebusy_event(&oof_events->lpbin[i], oof_months->lpl[i], event_year, "\t\t\t* ");
+		}
+	}
+
+	MAPIFreeBuffer(aRow.lpProps);
+
+//	mapidump_freebusy_event (all_events, 34117, 2010, "hello");
+}
+
+gboolean
 exchange_mapi_util_get_gal (GPtrArray *contacts_array)
 {
 	struct SPropTagArray	*SPropTagArray;
@@ -1327,6 +1435,8 @@ GetProps_cleanup:
 
 //			exchange_mapi_util_get_gal (contacts_array);
 
+//			exchange_mapi_util_get_free_busy_data (&obj_message);
+
 			/* get the main body stream no matter what */
 			if (options & MAPI_OPTIONS_FETCH_BODY_STREAM)
 				exchange_mapi_util_read_body_stream (&obj_message, &stream_list, 
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index e2b06b6..95062a1 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -147,6 +147,9 @@ exchange_mapi_connection_fetch_items   (mapi_id_t fid,
 gboolean
 exchange_mapi_util_get_gal (GPtrArray *contacts_array);
 
+gboolean
+exchange_mapi_util_get_free_busy_data (const gchar *user, time_t start, time_t end, GList **freebusy);
+
 mapi_id_t 
 exchange_mapi_create_folder (uint32_t olFolder, mapi_id_t pfid, const char *name);
 



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