Skip to content
Snippets Groups Projects
Commit ced9d1e5 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #5695 : addressbook : remove unused stuff, use static mutex

parent bc2ebf3a
No related branches found
No related tags found
No related merge requests found
...@@ -131,8 +131,6 @@ addressbook_init(gchar **book_list) ...@@ -131,8 +131,6 @@ addressbook_init(gchar **book_list)
{ {
printf("Addressbook: Initialize addressbook\n"); printf("Addressbook: Initialize addressbook\n");
init_eds_mutex();
fill_books_data(); fill_books_data();
addressbook_config_books(book_list); addressbook_config_books(book_list);
determine_default_addressbook(); determine_default_addressbook();
......
...@@ -64,7 +64,7 @@ authenticate_source (EBook *); ...@@ -64,7 +64,7 @@ authenticate_source (EBook *);
* The global addressbook list * The global addressbook list
*/ */
GSList *books_data = NULL; GSList *books_data = NULL;
GMutex *books_data_mutex = NULL; static GStaticMutex books_data_mutex = G_STATIC_MUTEX_INIT;
/** /**
* Size of image that will be displayed in contact list * Size of image that will be displayed in contact list
...@@ -106,15 +106,15 @@ books_ready() ...@@ -106,15 +106,15 @@ books_ready()
{ {
gboolean returnValue; gboolean returnValue;
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
if (books_data == NULL) { if (books_data == NULL) {
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return FALSE; return FALSE;
} }
returnValue = (g_slist_length (books_data) > 0); returnValue = (g_slist_length (books_data) > 0);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return returnValue; return returnValue;
} }
...@@ -128,11 +128,11 @@ books_active() ...@@ -128,11 +128,11 @@ books_active()
GSList *book_list_iterator; GSList *book_list_iterator;
book_data_t *book_data; book_data_t *book_data;
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
if (books_data == NULL) { if (books_data == NULL) {
printf("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); printf("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return FALSE; return FALSE;
} }
...@@ -142,12 +142,12 @@ books_active() ...@@ -142,12 +142,12 @@ books_active()
book_data = (book_data_t *) book_list_iterator->data; book_data = (book_data_t *) book_list_iterator->data;
if (book_data->active) { if (book_data->active) {
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return TRUE; return TRUE;
} }
} }
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
// If no result // If no result
return FALSE; return FALSE;
...@@ -161,11 +161,11 @@ books_get_book_data_by_uid (gchar *uid) ...@@ -161,11 +161,11 @@ books_get_book_data_by_uid (gchar *uid)
GSList *book_list_iterator; GSList *book_list_iterator;
book_data_t *book_data; book_data_t *book_data;
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
if (books_data == NULL) { if (books_data == NULL) {
printf("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); printf("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return NULL; return NULL;
} }
...@@ -178,12 +178,12 @@ books_get_book_data_by_uid (gchar *uid) ...@@ -178,12 +178,12 @@ books_get_book_data_by_uid (gchar *uid)
if (strcmp (book_data->uid, uid) == 0) { if (strcmp (book_data->uid, uid) == 0) {
printf("Addressbook: Book %s found\n", uid); printf("Addressbook: Book %s found\n", uid);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return book_data; return book_data;
} }
} }
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
printf("Addressbook: Could not found Book %s\n", uid); printf("Addressbook: Could not found Book %s\n", uid);
// If no result // If no result
...@@ -440,11 +440,11 @@ init_eds () ...@@ -440,11 +440,11 @@ init_eds ()
printf ("Addressbook: Init evolution data server\n"); printf ("Addressbook: Init evolution data server\n");
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
if (books_data == NULL) { if (books_data == NULL) {
printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return; return;
} }
...@@ -469,13 +469,7 @@ init_eds () ...@@ -469,13 +469,7 @@ init_eds ()
printf("END EVOLUTION INIT %s, %s, %s\n", current_uri, current_uid, current_name); printf("END EVOLUTION INIT %s, %s, %s\n", current_uri, current_uid, current_name);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
}
void
init_eds_mutex() {
books_data_mutex = g_mutex_new();
} }
/** /**
...@@ -565,7 +559,7 @@ fill_books_data () ...@@ -565,7 +559,7 @@ fill_books_data ()
return; return;
} }
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
if (books_data != NULL) { if (books_data != NULL) {
empty_books_data(); empty_books_data();
...@@ -613,7 +607,7 @@ fill_books_data () ...@@ -613,7 +607,7 @@ fill_books_data ()
g_free (absuri); g_free (absuri);
} }
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
g_object_unref (source_list); g_object_unref (source_list);
} }
...@@ -621,7 +615,7 @@ fill_books_data () ...@@ -621,7 +615,7 @@ fill_books_data ()
void void
determine_default_addressbook() determine_default_addressbook()
{ {
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
GSList *list_element = books_data; GSList *list_element = books_data;
gboolean default_found = FALSE; gboolean default_found = FALSE;
...@@ -657,7 +651,7 @@ determine_default_addressbook() ...@@ -657,7 +651,7 @@ determine_default_addressbook()
list_element = g_slist_next (list_element); list_element = g_slist_next (list_element);
} }
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
} }
void void
...@@ -759,11 +753,11 @@ set_current_addressbook (const gchar *name) ...@@ -759,11 +753,11 @@ set_current_addressbook (const gchar *name)
if(name == NULL) if(name == NULL)
return; return;
g_mutex_lock(books_data_mutex); g_static_mutex_lock(&books_data_mutex);
if (!books_data) { if (!books_data) {
printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
return; return;
} }
...@@ -781,7 +775,7 @@ set_current_addressbook (const gchar *name) ...@@ -781,7 +775,7 @@ set_current_addressbook (const gchar *name)
printf("Addressbook: Set current addressbook %s, %s, %s\n", current_uri, current_uid, current_name); printf("Addressbook: Set current addressbook %s, %s, %s\n", current_uri, current_uid, current_name);
g_mutex_unlock(books_data_mutex); g_static_mutex_unlock(&books_data_mutex);
} }
......
...@@ -50,55 +50,12 @@ ...@@ -50,55 +50,12 @@
G_BEGIN_DECLS G_BEGIN_DECLS
/**
* Current search id used to prevent processing
* of previous search
*/
int current_search_id;
/**
* Represent a contact entry
*/
/*
typedef struct _Hit {
gchar *name;
GdkPixbuf *photo;
gchar *phone_business;
gchar *phone_home;
gchar *phone_mobile;
} Hit;
*/
/**
* Book structure for "outside world"
*/
/*
typedef struct {
gchar *uid;
gchar *uri;
gchar *name;
gboolean active;
gboolean isdefault;
} book_data_t;
*/
/**
* Free a contact entry
*/
void
free_hit (Hit *h);
/** /**
* Template callback function for the asynchronous search * Template callback function for the asynchronous search
*/ */
typedef void typedef void
(* SearchAsyncHandler) (GList *hits, gpointer user_data); (* SearchAsyncHandler) (GList *hits, gpointer user_data);
/**
* Template callback function for the asynchronous open
*/
typedef void
(* OpenAsyncHandler) ();
/** /**
* Initialize the address book. * Initialize the address book.
* Connection to evolution data server * Connection to evolution data server
...@@ -106,13 +63,6 @@ typedef void ...@@ -106,13 +63,6 @@ typedef void
void void
init_eds (); init_eds ();
/**
* We need to initialize multi-threading capabilities
* due to asynchronous callbacks
*/
void
init_eds_mutex(void);
/** /**
* Fill list of addressbooks * Fill list of addressbooks
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment