Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-private.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *  camel-private.h: Private info for class implementers.
3  *
4  * Authors: Michael Zucchi <notzed@ximian.com>
5  *
6  * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
7  *
8  * This program is free software; you can redistribute it and/or 
9  * modify it under the terms of version 2 of the GNU Lesser General Public 
10  * License as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22
23 #ifndef CAMEL_PRIVATE_H
24 #define CAMEL_PRIVATE_H 1
25
26 /* need a way to configure and save this data, if this header is to
27    be installed.  For now, dont install it */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <pthread.h>
34 #include <libedataserver/e-msgport.h>
35
36 G_BEGIN_DECLS
37
38 struct _CamelFolderPrivate {
39         GStaticRecMutex lock;
40         GStaticMutex change_lock;
41         /* must require the 'change_lock' to access this */
42         int frozen;
43         struct _CamelFolderChangeInfo *changed_frozen; /* queues changed events */
44 };
45
46 #define CAMEL_FOLDER_LOCK(f, l) \
47         (g_static_mutex_lock(&((CamelFolder *)f)->priv->l))
48 #define CAMEL_FOLDER_UNLOCK(f, l) \
49         (g_static_mutex_unlock(&((CamelFolder *)f)->priv->l))
50 #define CAMEL_FOLDER_REC_LOCK(f, l) \
51         (g_static_rec_mutex_lock(&((CamelFolder *)f)->priv->l))
52 #define CAMEL_FOLDER_REC_UNLOCK(f, l) \
53         (g_static_rec_mutex_unlock(&((CamelFolder *)f)->priv->l))
54
55
56 struct _CamelStorePrivate {
57         GStaticRecMutex folder_lock;    /* for locking folder operations */
58 };
59
60 #define CAMEL_STORE_LOCK(f, l) \
61         (g_static_rec_mutex_lock(&((CamelStore *)f)->priv->l))
62 #define CAMEL_STORE_UNLOCK(f, l) \
63         (g_static_rec_mutex_unlock(&((CamelStore *)f)->priv->l))
64
65
66 struct _CamelTransportPrivate {
67         GMutex *send_lock;   /* for locking send operations */
68 };
69
70 #define CAMEL_TRANSPORT_LOCK(f, l) (g_mutex_lock(((CamelTransport *)f)->priv->l))
71 #define CAMEL_TRANSPORT_UNLOCK(f, l) (g_mutex_unlock(((CamelTransport *)f)->priv->l))
72
73
74 struct _CamelServicePrivate {
75         GStaticRecMutex connect_lock;   /* for locking connection operations */
76         GStaticMutex connect_op_lock;   /* for locking the connection_op */
77 };
78
79 #define CAMEL_SERVICE_LOCK(f, l) \
80         (g_static_mutex_lock(&((CamelService *)f)->priv->l))
81 #define CAMEL_SERVICE_UNLOCK(f, l) \
82         (g_static_mutex_unlock(&((CamelService *)f)->priv->l))
83 #define CAMEL_SERVICE_REC_LOCK(f, l) \
84         (g_static_rec_mutex_lock(&((CamelService *)f)->priv->l))
85 #define CAMEL_SERVICE_REC_UNLOCK(f, l) \
86         (g_static_rec_mutex_unlock(&((CamelService *)f)->priv->l))
87
88
89 struct _CamelSessionPrivate {
90         GMutex *lock;           /* for locking everything basically */
91         GMutex *thread_lock;    /* locking threads */
92
93         int thread_id;
94         GHashTable *thread_active;
95         GThreadPool *thread_pool;
96
97         GHashTable *thread_msg_op;
98 };
99
100 #define CAMEL_SESSION_LOCK(f, l) (g_mutex_lock(((CamelSession *)f)->priv->l))
101 #define CAMEL_SESSION_UNLOCK(f, l) (g_mutex_unlock(((CamelSession *)f)->priv->l))
102
103
104 /* most of this stuff really is private, but the lock can be used by subordinate classes */
105 struct _CamelFolderSummaryPrivate {
106         GHashTable *filter_charset;     /* CamelMimeFilterCharset's indexed by source charset */
107
108         struct _CamelMimeFilterIndex *filter_index;
109         struct _CamelMimeFilterBasic *filter_64;
110         struct _CamelMimeFilterBasic *filter_qp;
111         struct _CamelMimeFilterBasic *filter_uu;
112         struct _CamelMimeFilterSave *filter_save;
113         struct _CamelMimeFilterHTML *filter_html;
114
115         struct _CamelStreamFilter *filter_stream;
116
117         struct _CamelIndex *index;
118         
119         GMutex *summary_lock;   /* for the summary hashtable/array */
120         GMutex *io_lock;        /* load/save lock, for access to saved_count, etc */
121         GMutex *filter_lock;    /* for accessing any of the filtering/indexing stuff, since we share them */
122         GMutex *alloc_lock;     /* for setting up and using allocators */
123         GMutex *ref_lock;       /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */
124 };
125
126 #define CAMEL_SUMMARY_LOCK(f, l) (g_mutex_lock(((CamelFolderSummary *)f)->priv->l))
127 #define CAMEL_SUMMARY_UNLOCK(f, l) (g_mutex_unlock(((CamelFolderSummary *)f)->priv->l))
128
129
130 struct _CamelStoreSummaryPrivate {
131         GMutex *summary_lock;   /* for the summary hashtable/array */
132         GMutex *io_lock;        /* load/save lock, for access to saved_count, etc */
133         GMutex *alloc_lock;     /* for setting up and using allocators */
134         GMutex *ref_lock;       /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */
135 };
136
137 #define CAMEL_STORE_SUMMARY_LOCK(f, l) (g_mutex_lock(((CamelStoreSummary *)f)->priv->l))
138 #define CAMEL_STORE_SUMMARY_UNLOCK(f, l) (g_mutex_unlock(((CamelStoreSummary *)f)->priv->l))
139
140
141 struct _CamelVeeFolderPrivate {
142         GList *folders;                 /* lock using subfolder_lock before changing/accessing */
143         GList *folders_changed;         /* for list of folders that have changed between updates */
144         
145         GMutex *summary_lock;           /* for locking vfolder summary */
146         GMutex *subfolder_lock;         /* for locking the subfolder list */
147         GMutex *changed_lock;           /* for locking the folders-changed list */
148 };
149
150 #define CAMEL_VEE_FOLDER_LOCK(f, l) (g_mutex_lock(((CamelVeeFolder *)f)->priv->l))
151 #define CAMEL_VEE_FOLDER_UNLOCK(f, l) (g_mutex_unlock(((CamelVeeFolder *)f)->priv->l))
152
153
154 struct _CamelDataWrapperPrivate {
155         pthread_mutex_t stream_lock;
156 };
157
158 #define CAMEL_DATA_WRAPPER_LOCK(dw, l)   (pthread_mutex_lock(&((CamelDataWrapper *)dw)->priv->l))
159 #define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) (pthread_mutex_unlock(&((CamelDataWrapper *)dw)->priv->l))
160
161
162 /* most of this stuff really is private, but the lock can be used by subordinate classes */
163 struct _CamelCertDBPrivate {
164         GMutex *db_lock;        /* for the db hashtable/array */
165         GMutex *io_lock;        /* load/save lock, for access to saved_count, etc */
166         GMutex *alloc_lock;     /* for setting up and using allocators */
167         GMutex *ref_lock;       /* for reffing/unreffing certs */
168 };
169
170 #define CAMEL_CERTDB_LOCK(db, l) (g_mutex_lock (((CamelCertDB *) db)->priv->l))
171 #define CAMEL_CERTDB_UNLOCK(db, l) (g_mutex_unlock (((CamelCertDB *) db)->priv->l))
172
173 #ifdef G_OS_WIN32
174 int fsync (int fd);
175
176 const char *_camel_get_localedir (void) G_GNUC_CONST;
177 const char *_camel_get_libexecdir (void) G_GNUC_CONST;
178 const char *_camel_get_providerdir (void) G_GNUC_CONST;
179
180 #undef EVOLUTION_LOCALEDIR
181 #define EVOLUTION_LOCALEDIR _camel_get_localedir ()
182
183 #undef CAMEL_LIBEXECDIR
184 #define CAMEL_LIBEXECDIR _camel_get_libexecdir ()
185
186 #undef CAMEL_PROVIDERDIR
187 #define CAMEL_PROVIDERDIR _camel_get_providerdir ()
188
189 #endif /* G_OS_WIN32 */
190
191 G_END_DECLS
192
193 #endif /* CAMEL_PRIVATE_H */