[evolution-mapi] Bug #614480 - Avoid using G_TYPE_INSTANCE_GET_PRIVATE repeatedly
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Bug #614480 - Avoid using G_TYPE_INSTANCE_GET_PRIVATE repeatedly
- Date: Thu, 24 Feb 2011 12:53:54 +0000 (UTC)
commit dbc429ed1eaa485ba9f8673eabde6adc2ac18298
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 24 13:53:24 2011 +0100
Bug #614480 - Avoid using G_TYPE_INSTANCE_GET_PRIVATE repeatedly
src/addressbook/e-book-backend-mapi.c | 17 ++++--------
src/camel/camel-mapi-folder.c | 6 +---
src/camel/camel-mapi-store.c | 10 ++-----
src/libexchangemapi/em-operation-queue.c | 4 +--
src/libexchangemapi/exchange-mapi-connection.c | 32 +++++++++--------------
src/libexchangemapi/exchange-mapi-connection.h | 3 ++
6 files changed, 27 insertions(+), 45 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 9d49c79..737641b 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -1335,19 +1335,14 @@ ebbm_op_authenticate_user (EBookBackend *backend, EDataBook *book, guint32 opid,
static void
e_book_backend_mapi_init (EBookBackendMAPI *ebma)
{
- EBookBackendMAPIPrivate *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (ebma, E_TYPE_BOOK_BACKEND_MAPI, EBookBackendMAPIPrivate);
-
- /* Priv Struct init */
- ebma->priv = priv;
+ ebma->priv = G_TYPE_INSTANCE_GET_PRIVATE (ebma, E_TYPE_BOOK_BACKEND_MAPI, EBookBackendMAPIPrivate);
- priv->op_queue = em_operation_queue_new ((EMOperationQueueFunc) ebbm_operation_cb, ebma);
- priv->running_book_views = g_hash_table_new (g_direct_hash, g_direct_equal);
- priv->conn_lock = g_mutex_new ();
+ ebma->priv->op_queue = em_operation_queue_new ((EMOperationQueueFunc) ebbm_operation_cb, ebma);
+ ebma->priv->running_book_views = g_hash_table_new (g_direct_hash, g_direct_equal);
+ ebma->priv->conn_lock = g_mutex_new ();
- priv->update_cache = g_cancellable_new ();
- priv->update_cache_thread = NULL;
+ ebma->priv->update_cache = g_cancellable_new ();
+ ebma->priv->update_cache_thread = NULL;
}
static void
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 2ca1bf5..04853d2 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -48,10 +48,6 @@
#define SUMMARY_FETCH_BATCH_COUNT 150
#define d(x)
-#define CAMEL_MAPI_FOLDER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), CAMEL_TYPE_MAPI_FOLDER, CamelMapiFolderPrivate))
-
struct _CamelMapiFolderPrivate {
//#ifdef ENABLE_THREADS
@@ -1829,7 +1825,7 @@ camel_mapi_folder_init (CamelMapiFolder *mapi_folder)
{
CamelFolder *folder = CAMEL_FOLDER (mapi_folder);
- mapi_folder->priv = CAMEL_MAPI_FOLDER_GET_PRIVATE (mapi_folder);
+ mapi_folder->priv = G_TYPE_INSTANCE_GET_PRIVATE (mapi_folder, CAMEL_TYPE_MAPI_FOLDER, CamelMapiFolderPrivate);
folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_DELETED |
CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_JUNK;
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index b6b5f33..4dff0fc 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -54,10 +54,6 @@
#define d(x) printf("%s:%s:%s \n", G_STRLOC, G_STRFUNC, x)
-#define CAMEL_MAPI_STORE_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), CAMEL_TYPE_MAPI_STORE, CamelMapiStorePrivate))
-
struct _CamelMapiStorePrivate {
gchar *profile;
ExchangeMapiConnection *conn;
@@ -758,7 +754,7 @@ mapi_store_dispose (GObject *object)
{
CamelMapiStorePrivate *priv;
- priv = CAMEL_MAPI_STORE_GET_PRIVATE (object);
+ priv = CAMEL_MAPI_STORE (object)->priv;
if (priv->conn != NULL) {
g_object_unref (priv->conn);
@@ -774,7 +770,7 @@ mapi_store_finalize (GObject *object)
{
CamelMapiStorePrivate *priv;
- priv = CAMEL_MAPI_STORE_GET_PRIVATE (object);
+ priv = CAMEL_MAPI_STORE (object)->priv;
g_free (priv->profile);
g_free (priv->storage_path);
@@ -1489,7 +1485,7 @@ camel_mapi_store_class_init (CamelMapiStoreClass *class)
static void
camel_mapi_store_init (CamelMapiStore *mapi_store)
{
- mapi_store->priv = CAMEL_MAPI_STORE_GET_PRIVATE (mapi_store);
+ mapi_store->priv = G_TYPE_INSTANCE_GET_PRIVATE (mapi_store, CAMEL_TYPE_MAPI_STORE, CamelMapiStorePrivate);
}
/* service methods */
diff --git a/src/libexchangemapi/em-operation-queue.c b/src/libexchangemapi/em-operation-queue.c
index 28a74e3..ad3a6b9 100644
--- a/src/libexchangemapi/em-operation-queue.c
+++ b/src/libexchangemapi/em-operation-queue.c
@@ -34,8 +34,6 @@ static void thread_func_cb (gpointer data, gpointer pqueue);
G_DEFINE_TYPE (EMOperationQueue, em_operation_queue, G_TYPE_OBJECT)
-#define EM_OPERATION_QUEUE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EM_TYPE_OPERATION_QUEUE, EMOperationQueuePrivate))
-
struct _EMOperationQueuePrivate
{
GMutex *lock;
@@ -95,7 +93,7 @@ em_operation_queue_init (EMOperationQueue *queue)
g_return_if_fail (queue != NULL);
g_return_if_fail (EM_IS_OPERATION_QUEUE (queue));
- queue->priv = EM_OPERATION_QUEUE_GET_PRIVATE (queue);
+ queue->priv = G_TYPE_INSTANCE_GET_PRIVATE (queue, EM_TYPE_OPERATION_QUEUE, EMOperationQueuePrivate);
priv = queue->priv;
g_return_if_fail (priv != NULL);
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 92dbda5..bf7806f 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -52,8 +52,6 @@ static void ema_global_unlock (void);
G_DEFINE_TYPE (ExchangeMapiConnection, exchange_mapi_connection, G_TYPE_OBJECT)
-#define EXCHANGE_MAPI_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EXCHANGE_TYPE_MAPI_CONNECTION, ExchangeMapiConnectionPrivate))
-
/* These two macros require 'priv' variable of type ExchangeMapiConnectionPrivate */
#define LOCK() g_debug ("%s: %s: lock(session/global_lock)", G_STRLOC, G_STRFUNC); g_static_rec_mutex_lock (&priv->session_lock); ema_global_lock();
#define UNLOCK() g_debug ("%s: %s: unlock(session/global_lock)", G_STRLOC, G_STRFUNC); g_static_rec_mutex_unlock (&priv->session_lock); ema_global_unlock();
@@ -147,8 +145,6 @@ make_mapi_error (GError **perror, const gchar *context, enum MAPISTATUS mapi_sta
struct mapi_context *mapi_ctx = NULL;
#endif
-typedef struct _ExchangeMapiConnectionPrivate ExchangeMapiConnectionPrivate;
-
struct _ExchangeMapiConnectionPrivate {
struct mapi_session *session;
GStaticRecMutex session_lock;
@@ -226,7 +222,7 @@ exchange_mapi_connection_finalize (GObject *object)
unregister_connection (EXCHANGE_MAPI_CONNECTION (object));
- priv = EXCHANGE_MAPI_CONNECTION_GET_PRIVATE (object);
+ priv = EXCHANGE_MAPI_CONNECTION (object)->priv;
if (priv) {
LOCK ();
@@ -261,20 +257,18 @@ exchange_mapi_connection_class_init (ExchangeMapiConnectionClass *klass)
static void
exchange_mapi_connection_init (ExchangeMapiConnection *conn)
{
- ExchangeMapiConnectionPrivate *priv;
-
- priv = EXCHANGE_MAPI_CONNECTION_GET_PRIVATE (conn);
- g_return_if_fail (priv != NULL);
+ conn->priv = G_TYPE_INSTANCE_GET_PRIVATE (conn, EXCHANGE_TYPE_MAPI_CONNECTION, ExchangeMapiConnectionPrivate);
+ g_return_if_fail (conn->priv != NULL);
- g_static_rec_mutex_init (&priv->session_lock);
- g_static_rec_mutex_init (&priv->folders_lock);
+ g_static_rec_mutex_init (&conn->priv->session_lock);
+ g_static_rec_mutex_init (&conn->priv->folders_lock);
- priv->session = NULL;
- priv->profile = NULL;
- priv->has_public_store = FALSE;
- priv->folders = NULL;
+ conn->priv->session = NULL;
+ conn->priv->profile = NULL;
+ conn->priv->has_public_store = FALSE;
+ conn->priv->folders = NULL;
- priv->named_ids = g_hash_table_new_full (g_int64_hash, g_int64_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
+ conn->priv->named_ids = g_hash_table_new_full (g_int64_hash, g_int64_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
register_connection (conn);
}
@@ -330,7 +324,7 @@ exchange_mapi_connection_find (const gchar *profile)
G_LOCK (known_connections);
for (l = known_connections; l != NULL && res == NULL; l = l->next) {
ExchangeMapiConnection *conn = EXCHANGE_MAPI_CONNECTION (l->data);
- ExchangeMapiConnectionPrivate *priv = EXCHANGE_MAPI_CONNECTION_GET_PRIVATE (conn);
+ ExchangeMapiConnectionPrivate *priv = conn->priv;
if (priv && priv->profile && g_str_equal (profile, priv->profile))
res = conn;
@@ -360,7 +354,7 @@ exchange_mapi_connection_find (const gchar *profile)
e_return_val_mapi_error_if_fail (_conn != NULL, MAPI_E_INVALID_PARAMETER, _val); \
e_return_val_mapi_error_if_fail (EXCHANGE_IS_MAPI_CONNECTION (_conn), MAPI_E_INVALID_PARAMETER, _val); \
\
- priv = EXCHANGE_MAPI_CONNECTION_GET_PRIVATE (_conn); \
+ priv = (_conn)->priv; \
e_return_val_mapi_error_if_fail (priv != NULL, MAPI_E_INVALID_PARAMETER, _val);
/* Creates a new connection object and connects to a server as defined in 'profile' */
@@ -381,7 +375,7 @@ exchange_mapi_connection_new (const gchar *profile, const gchar *password, GErro
}
conn = g_object_new (EXCHANGE_TYPE_MAPI_CONNECTION, NULL);
- priv = EXCHANGE_MAPI_CONNECTION_GET_PRIVATE (conn);
+ priv = conn->priv;
e_return_val_mapi_error_if_fail (priv != NULL, MAPI_E_INVALID_PARAMETER, conn);
LOCK ();
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index 4287dc1..6c3d298 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -45,6 +45,7 @@ GQuark e_mapi_error_quark (void);
typedef struct _ExchangeMapiConnection ExchangeMapiConnection;
typedef struct _ExchangeMapiConnectionClass ExchangeMapiConnectionClass;
+typedef struct _ExchangeMapiConnectionPrivate ExchangeMapiConnectionPrivate;
typedef enum {
MAPI_OPTIONS_FETCH_ATTACHMENTS = 1<<0,
@@ -143,6 +144,8 @@ typedef gboolean (*BuildReadPropsCB) (ExchangeMapiConnection *conn, mapi_id_t fi
struct _ExchangeMapiConnection {
GObject parent;
+
+ ExchangeMapiConnectionPrivate *priv;
};
struct _ExchangeMapiConnectionClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]