Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
94af3a9f
Commit
94af3a9f
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#4639] Fix memory leaks in Addressbook
parent
91aa221f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-client-gnome/src/contacts/addressbook/eds.c
+48
-34
48 additions, 34 deletions
sflphone-client-gnome/src/contacts/addressbook/eds.c
with
48 additions
and
34 deletions
sflphone-client-gnome/src/contacts/addressbook/eds.c
+
48
−
34
View file @
94af3a9f
...
@@ -55,16 +55,14 @@ typedef struct _Search_Handler_And_Data {
...
@@ -55,16 +55,14 @@ typedef struct _Search_Handler_And_Data {
}
Search_Handler_And_Data
;
}
Search_Handler_And_Data
;
/**
/**
*
Size of image that will be displayed in contact
list
*
The global addressbook
list
*/
*/
static
int
pixbuf_size
=
32
;
GSList
*
books_data
=
NULL
;
/**
/**
*
Remaining books to open (asynchronous)
*
Size of image that will be displayed in contact list
*/
*/
int
remaining_books_to_open
;
static
int
pixbuf_size
=
32
;
GSList
*
books_data
=
NULL
;
/**
/**
* Current selected addressbook's uri and uid, initialized with default
* Current selected addressbook's uri and uid, initialized with default
...
@@ -88,12 +86,26 @@ free_hit (Hit *h)
...
@@ -88,12 +86,26 @@ free_hit (Hit *h)
g_free
(
h
);
g_free
(
h
);
}
}
/**
* Free a book data
*/
void
free_book_data
(
book_data_t
*
data
)
{
g_free
(
data
->
name
);
g_free
(
data
->
uid
);
g_free
(
data
->
uri
);
}
/**
/**
* Public way to know if we can perform a search
* Public way to know if we can perform a search
*/
*/
gboolean
gboolean
books_ready
()
books_ready
()
{
{
if
(
books_data
==
NULL
)
return
0
;
return
(
g_slist_length
(
books_data
)
>
0
);
return
(
g_slist_length
(
books_data
)
>
0
);
}
}
...
@@ -106,7 +118,7 @@ books_active()
...
@@ -106,7 +118,7 @@ books_active()
GSList
*
book_list_iterator
;
GSList
*
book_list_iterator
;
book_data_t
*
book_data
;
book_data_t
*
book_data
;
if
(
!
books_data
)
{
if
(
books_data
==
NULL
)
{
DEBUG
(
"Addressbook: No books data (%s:%d)"
,
__FILE__
,
__LINE__
);
DEBUG
(
"Addressbook: No books data (%s:%d)"
,
__FILE__
,
__LINE__
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -132,7 +144,7 @@ books_get_book_data_by_uid (gchar *uid)
...
@@ -132,7 +144,7 @@ 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
;
if
(
!
books_data
)
{
if
(
books_data
==
NULL
)
{
DEBUG
(
"Addressbook: No books data (%s:%d)"
,
__FILE__
,
__LINE__
);
DEBUG
(
"Addressbook: No books data (%s:%d)"
,
__FILE__
,
__LINE__
);
return
NULL
;
return
NULL
;
}
}
...
@@ -282,8 +294,6 @@ eds_query_result_cb (EBook *book, EBookStatus status, GList *contacts, gpointer
...
@@ -282,8 +294,6 @@ eds_query_result_cb (EBook *book, EBookStatus status, GList *contacts, gpointer
if
(
status
==
E_BOOK_ERROR_OK
)
{
if
(
status
==
E_BOOK_ERROR_OK
)
{
gchar
*
number
;
// make sure we have a new list of hits
// make sure we have a new list of hits
had
->
hits
=
NULL
;
had
->
hits
=
NULL
;
...
@@ -297,37 +307,17 @@ eds_query_result_cb (EBook *book, EBookStatus status, GList *contacts, gpointer
...
@@ -297,37 +307,17 @@ eds_query_result_cb (EBook *book, EBookStatus status, GList *contacts, gpointer
// Get the photo contact
// Get the photo contact
hit
->
photo
=
pixbuf_from_contact
(
E_CONTACT
(
l
->
data
));
hit
->
photo
=
pixbuf_from_contact
(
E_CONTACT
(
l
->
data
));
fetch_information_from_contact
(
E_CONTACT
(
l
->
data
),
E_CONTACT_PHONE_BUSINESS
,
&
hit
->
phone_business
);
// Get business phone information
fetch_information_from_contact
(
E_CONTACT
(
l
->
data
),
E_CONTACT_PHONE_HOME
,
&
hit
->
phone_home
);
fetch_information_from_contact
(
E_CONTACT
(
l
->
data
),
E_CONTACT_PHONE_BUSINESS
,
&
number
);
fetch_information_from_contact
(
E_CONTACT
(
l
->
data
),
E_CONTACT_PHONE_MOBILE
,
&
hit
->
phone_mobile
);
hit
->
phone_business
=
g_strdup
(
number
);
// Get home phone information
fetch_information_from_contact
(
E_CONTACT
(
l
->
data
),
E_CONTACT_PHONE_HOME
,
&
number
);
hit
->
phone_home
=
g_strdup
(
number
);
// Get mobile phone information
fetch_information_from_contact
(
E_CONTACT
(
l
->
data
),
E_CONTACT_PHONE_MOBILE
,
&
number
);
hit
->
phone_mobile
=
g_strdup
(
number
);
hit
->
name
=
g_strdup
(
(
char
*
)
e_contact_get_const
(
E_CONTACT
(
l
->
data
),
E_CONTACT_NAME_OR_ORG
));
hit
->
name
=
g_strdup
(
(
char
*
)
e_contact_get_const
(
E_CONTACT
(
l
->
data
),
E_CONTACT_NAME_OR_ORG
));
if
(
!
hit
->
name
)
if
(
!
hit
->
name
)
hit
->
name
=
""
;
hit
->
name
=
""
;
/*
DEBUG ("Addressbook: Contact Found");
DEBUG ("Addressbook: Full Name %s", hit->name);
DEBUG ("Addressbook: Phone Home %s", hit->phone_home);
DEBUG ("Addressbook: Phone Business %s", hit->phone_business);
DEBUG ("Addressbook: Phone Mobile %s", hit->phone_mobile);
*/
if
(
hit
)
if
(
hit
)
had
->
hits
=
g_list_append
(
had
->
hits
,
hit
);
had
->
hits
=
g_list_append
(
had
->
hits
,
hit
);
// DEBUG ("Addressbook: max_result_remaining %d", had->max_results_remaining);
had
->
max_results_remaining
--
;
had
->
max_results_remaining
--
;
if
(
had
->
max_results_remaining
<=
0
)
if
(
had
->
max_results_remaining
<=
0
)
...
@@ -485,7 +475,6 @@ fill_books_data ()
...
@@ -485,7 +475,6 @@ fill_books_data ()
{
{
GSList
*
list
,
*
l
;
GSList
*
list
,
*
l
;
ESourceList
*
source_list
=
NULL
;
ESourceList
*
source_list
=
NULL
;
remaining_books_to_open
=
0
;
gboolean
default_found
;
gboolean
default_found
;
source_list
=
e_source_list_new_for_gconf_default
(
"/apps/evolution/addressbook/sources"
);
source_list
=
e_source_list_new_for_gconf_default
(
"/apps/evolution/addressbook/sources"
);
...
@@ -502,6 +491,11 @@ fill_books_data ()
...
@@ -502,6 +491,11 @@ fill_books_data ()
return
;
return
;
}
}
if
(
books_data
==
NULL
)
{
empty_books_data
();
books_data
=
NULL
;
}
// in case default property is not set for any addressbook
// in case default property is not set for any addressbook
default_found
=
FALSE
;
default_found
=
FALSE
;
...
@@ -555,6 +549,26 @@ fill_books_data ()
...
@@ -555,6 +549,26 @@ fill_books_data ()
g_object_unref
(
source_list
);
g_object_unref
(
source_list
);
}
}
void
empty_books_data
()
{
GSList
*
book_list_iterator
;
book_data_t
*
book_data
;
if
(
books_data
==
NULL
)
{
DEBUG
(
"Addressbook: No books data (%s:%d)"
,
__FILE__
,
__LINE__
);
return
;
}
// Iterate throw the list
for
(
book_list_iterator
=
books_data
;
book_list_iterator
!=
NULL
;
book_list_iterator
=
book_list_iterator
->
next
)
{
book_data
=
(
book_data_t
*
)
book_list_iterator
->
data
;
free_book_data
(
book_data
);
}
}
void
void
search_async_by_contacts
(
const
char
*
query
,
int
max_results
,
SearchAsyncHandler
handler
,
gpointer
user_data
)
search_async_by_contacts
(
const
char
*
query
,
int
max_results
,
SearchAsyncHandler
handler
,
gpointer
user_data
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment