"Fossies" - the Fresh Open Source Software archive

Member "evolution-brutus-1.2.35/camel/camel-brutus-store.h" of archive evolution-brutus-1.2.35.tar.gz:


/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *    Camel Brutus store class. 
 *
 *    Authors:
 *        Jules Colding <colding@42tools.com>
 *
 *    Copyright (C) 2005-2007 OMC Denmark ApS.
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    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 General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *    MA 02111-1307 USA
 */

#ifndef CAMEL_BRUTUS_STORE_H
#define CAMEL_BRUTUS_STORE_H 1

#include <pthread.h>

#include <camel/camel-store.h>
#include <camel/camel-offline-store.h>
#include <camel/camel-data-cache.h>

#include <idl_output/IMAPISession.h>
#include <idl_output/IMAPIFolder.h>
#include <idl_output/IMAPITable.h>
#include <idl_output/IMsgStore.h>

#include <session/brutus-proxy.h>
#include <session/brutusd-util.h>
#include <server/brutus.h>

G_BEGIN_DECLS

#define CAMEL_BRUTUS_STORE_TYPE     (camel_brutus_store_get_type ())
#define CAMEL_BRUTUS_STORE(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_BRUTUS_STORE_TYPE, CamelBrutusStore))
#define CAMEL_BRUTUS_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_BRUTUS_STORE_TYPE, CamelBrutusStoreClass))
#define CAMEL_IS_BRUTUS_STORE(o)    (CAMEL_CHECK_TYPE((o), CAMEL_BRUTUS_STORE_TYPE))

struct BrutusMsgStore {
	BRUTUS_IMsgStore msg_store;
	guint32 support_mask;
};

/* store-private data */
typedef struct _CamelBrutusStorePrivate {
	BrutusBaseClass base_class; // basic data required to connect to Brutus server

	BRUTUS_IMAPITable mapi_msg_store_table; // Table of all message stores for this account
	GPtrArray *msg_stores;                  // Array of struct BrutusMsgStore to all message stores retrieved from the table above. Must hold connect_mutex to access

	/* A tree of CamelFolderInfo structure nodes for *all* folders */
	/* accessible on Exchange. Callee must hold folder_tree_rw_mutex to access */
	CamelFolderInfo *folder_tree; 

	/* The folder_tree_rw_mutex must be acquired before */
	/* accessing any of these hash tables  */
	GHashTable *fi_from_entryid_hash;        // get folder info node pointer (value) from pointer to BRUTUS_ENTRYID (key) - entry id is freed
	GHashTable *fi_from_full_name_hash;      // get folder info node pointer (value) from full_name (key)
	GHashTable *entryid_from_full_name_hash; // get pointer to BRUTUS_ENTRYID (value) from full_name (key)

	pthread_rwlock_t folder_tree_rw_mutex; // read/write lock on the folder tree and related hash tables

	/* CamelFolderInfo cache */
	CamelDataCache *fi_cache; // indexed by md5 digest of full_name

	gchar *base_url; // base service URL

	uuid_str_t session_key; // uuid to distinguish between different run-time sessions
	
	gboolean public_folders; // support Exchange Public Folders or not
} CamelBrutusStorePrivate;

typedef struct {
	CamelOfflineStore parent_object;

	CamelBrutusStorePrivate *priv; // Misc Brutus specific data and objects
} CamelBrutusStore;

typedef struct {
	CamelOfflineStoreClass parent_class;

} CamelBrutusStoreClass;

// thread pool to hold folder summary update threads
extern GThreadPool *folder_summary_updates_thread_pool;

// queue to hold entries that must be freed in a delayed manner
extern GAsyncQueue *wait_mem_queue;

// syncronization functions to prevent asynchronous folder summary 
// updates and folder deletions to collide
extern gboolean folder_summary_update_is_a_go(const char *full_name);
extern gboolean folder_summary_post_update_may_commence(const char *full_name);
extern gboolean folder_locked(const char *full_name);
extern void folder_is_done(const char *full_name);

/* Standard Camel function */
extern CamelType camel_brutus_store_get_type(void);

/* Inserts a new folder into the folder hierarchy tree under the parent. 
 * Returns TRUE if successful, FALSE otherwise. mapi_folder is the mapi 
 * equivalent of the new folder being inserted. It will _not_ be freed.
 */
extern gboolean brutus_insert_in_folder_tree(CamelStore *store,
					     const char *parent_name,
					     const char *full_name,
					     BRUTUS_IMAPIFolder mapi_folder, 
					     CamelException *ex);

/* Rebuilds the folder tree if needed */
extern void brutus_rebuild_folder_tree(CamelStore *store,
				       CamelException *ex);

G_END_DECLS

#endif /* CAMEL_BRUTUS_STORE_H */