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
01abacdc
Commit
01abacdc
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
Make the search asynchronous
parent
a7154567
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
sflphone-gtk/src/calltree.c
+37
-29
37 additions, 29 deletions
sflphone-gtk/src/calltree.c
sflphone-gtk/src/contactlist/eds.c
+230
-114
230 additions, 114 deletions
sflphone-gtk/src/contactlist/eds.c
sflphone-gtk/src/contactlist/eds.h
+7
-0
7 additions, 0 deletions
sflphone-gtk/src/contactlist/eds.h
with
274 additions
and
143 deletions
sflphone-gtk/src/calltree.c
+
37
−
29
View file @
01abacdc
...
...
@@ -225,34 +225,12 @@ show_history_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
}
static
void
show_contacts_tab
(
GtkToggleToolButton
*
toggle_tool_button
UNUSED
,
gpointer
user_data
UNUSED
)
{
handler_async_search
(
GList
*
hits
,
gpointer
user_data
)
{
GtkTreeSelection
*
sel
;
GList
*
results
;
GList
*
i
;
call_t
*
j
;
gchar
*
msg
;
// temporary display in status bar
msg
=
g_strdup
(
"Contacts"
);
statusbar_push_message
(
msg
,
__MSG_ACCOUNT_DEFAULT
);
g_free
(
msg
);
// freeing calls
while
((
j
=
(
call_t
*
)
g_queue_pop_tail
(
contacts
->
callQueue
))
!=
NULL
)
{
free_call_t
(
j
);
}
// reset previous results
reset_call_tree
(
contacts
);
call_list_reset
(
contacts
);
// do a synchronous search
results
=
search_sync
(
gtk_entry_get_text
(
GTK_ENTRY
(
filter_entry
)),
50
);
for
(
i
=
results
;
i
!=
NULL
;
i
=
i
->
next
)
for
(
i
=
hits
;
i
!=
NULL
;
i
=
i
->
next
)
{
Hit
*
entry
;
entry
=
i
->
data
;
...
...
@@ -267,7 +245,7 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
}
free_hit
(
entry
);
}
g_list_free
(
resul
ts
);
g_list_free
(
hi
ts
);
active_calltree
=
contacts
;
gtk_widget_hide
(
current_calls
->
tree
);
...
...
@@ -277,6 +255,36 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
sel
=
gtk_tree_view_get_selection
(
GTK_TREE_VIEW
(
active_calltree
->
view
));
g_signal_emit_by_name
(
sel
,
"changed"
);
toolbar_update_buttons
();
}
static
void
show_contacts_tab
(
GtkToggleToolButton
*
toggle_tool_button
UNUSED
,
gpointer
user_data
UNUSED
)
{
call_t
*
j
;
gchar
*
msg
;
// temporary display in status bar
msg
=
g_strdup
(
"Contacts"
);
statusbar_push_message
(
msg
,
__MSG_ACCOUNT_DEFAULT
);
g_free
(
msg
);
// freeing calls
while
((
j
=
(
call_t
*
)
g_queue_pop_tail
(
contacts
->
callQueue
))
!=
NULL
)
{
free_call_t
(
j
);
}
// reset previous results
reset_call_tree
(
contacts
);
call_list_reset
(
contacts
);
// do a synchronous search
//results = search_sync (gtk_entry_get_text(GTK_ENTRY(filter_entry)), 50);
// do an asynchronous search
search_async
(
gtk_entry_get_text
(
GTK_ENTRY
(
filter_entry
)),
50
,
&
handler_async_search
,
NULL
);
}
void
create_new_entry_in_contactlist
(
gchar
*
contact_name
,
gchar
*
contact_phone
,
contact_type_t
type
){
...
...
This diff is collapsed.
Click to expand it.
sflphone-gtk/src/contactlist/eds.c
+
230
−
114
View file @
01abacdc
...
...
@@ -30,6 +30,14 @@
#include
<pango/pango.h>
#include
"eds.h"
typedef
struct
_Handler_And_Data
{
SearchAsyncHandler
handler
;
gpointer
user_data
;
GList
*
hits
;
int
max_results_remaining
;
int
book_views_remaining
;
}
Handler_And_Data
;
static
GSList
*
books
=
NULL
;
static
EContactField
search_fields
[]
=
{
E_CONTACT_FULL_NAME
,
E_CONTACT_PHONE_BUSINESS
,
E_CONTACT_NICKNAME
,
0
};
...
...
@@ -198,6 +206,114 @@ search_sync (const char *query,
return
hits
;
}
static
void
view_finish
(
EBookView
*
book_view
,
Handler_And_Data
*
had
)
{
SearchAsyncHandler
had_handler
=
had
->
handler
;
GList
*
had_hits
=
had
->
hits
;
gpointer
had_user_data
=
had
->
user_data
;
g_free
(
had
);
g_return_if_fail
(
book_view
!=
NULL
);
g_object_unref
(
book_view
);
had_handler
(
had_hits
,
had_user_data
);
}
static
void
view_contacts_added_cb
(
EBookView
*
book_view
,
GList
*
contacts
,
gpointer
user_data
)
{
Handler_And_Data
*
had
=
(
Handler_And_Data
*
)
user_data
;
if
(
had
->
max_results_remaining
<=
0
)
{
e_book_view_stop
(
book_view
);
had
->
book_views_remaining
--
;
if
(
had
->
book_views_remaining
==
0
)
{
view_finish
(
book_view
,
had
);
return
;
}
}
for
(;
contacts
!=
NULL
;
contacts
=
g_list_next
(
contacts
))
{
EContact
*
contact
;
Hit
*
hit
;
gchar
*
number
;
contact
=
E_CONTACT
(
contacts
->
data
);
hit
=
g_new
(
Hit
,
1
);
//hit->pixbuf = pixbuf_from_contact (contact);
/* Get business phone information */
fetch_information_from_contact
(
contact
,
E_CONTACT_PHONE_BUSINESS
,
&
number
);
hit
->
phone_business
=
g_strdup
(
number
);
/* Get home phone information */
fetch_information_from_contact
(
contact
,
E_CONTACT_PHONE_HOME
,
&
number
);
hit
->
phone_home
=
g_strdup
(
number
);
/* Get mobile phone information */
fetch_information_from_contact
(
contact
,
E_CONTACT_PHONE_MOBILE
,
&
number
);
hit
->
phone_mobile
=
g_strdup
(
number
);
hit
->
name
=
g_strdup
((
char
*
)
e_contact_get_const
(
contact
,
E_CONTACT_NAME_OR_ORG
));
if
(
!
hit
->
name
)
hit
->
name
=
""
;
had
->
hits
=
g_list_append
(
had
->
hits
,
hit
);
had
->
max_results_remaining
--
;
if
(
had
->
max_results_remaining
<=
0
)
{
e_book_view_stop
(
book_view
);
had
->
book_views_remaining
--
;
if
(
had
->
book_views_remaining
==
0
)
{
view_finish
(
book_view
,
had
);
}
break
;
}
}
}
static
void
view_completed_cb
(
EBookView
*
book_view
,
EBookViewStatus
status
,
gpointer
user_data
)
{
Handler_And_Data
*
had
=
(
Handler_And_Data
*
)
user_data
;
had
->
book_views_remaining
--
;
if
(
had
->
book_views_remaining
==
0
)
{
view_finish
(
book_view
,
had
);
}
}
void
search_async
(
const
char
*
query
,
int
max_results
,
SearchAsyncHandler
handler
,
gpointer
user_data
)
{
GSList
*
iter
;
EBookQuery
*
book_query
=
create_query
(
query
);
Handler_And_Data
*
had
=
g_new
(
Handler_And_Data
,
1
);
had
->
handler
=
handler
;
had
->
user_data
=
user_data
;
had
->
hits
=
NULL
;
had
->
max_results_remaining
=
max_results
;
had
->
book_views_remaining
=
0
;
for
(
iter
=
books
;
iter
!=
NULL
;
iter
=
iter
->
next
)
{
EBook
*
book
=
(
EBook
*
)
iter
->
data
;
EBookView
*
book_view
=
NULL
;
e_book_get_book_view
(
book
,
book_query
,
NULL
,
max_results
,
&
book_view
,
NULL
);
if
(
book_view
!=
NULL
)
{
had
->
book_views_remaining
++
;
g_signal_connect
(
book_view
,
"contacts_added"
,
(
GCallback
)
view_contacts_added_cb
,
had
);
g_signal_connect
(
book_view
,
"sequence_complete"
,
(
GCallback
)
view_completed_cb
,
had
);
e_book_view_start
(
book_view
);
}
}
if
(
had
->
book_views_remaining
==
0
)
{
g_free
(
had
);
}
e_book_query_unref
(
book_query
);
}
void
fetch_information_from_contact
(
EContact
*
contact
,
EContactField
field
,
gchar
**
info
){
gchar
*
to_fetch
;
...
...
This diff is collapsed.
Click to expand it.
sflphone-gtk/src/contactlist/eds.h
+
7
−
0
View file @
01abacdc
...
...
@@ -44,8 +44,15 @@ typedef struct _Hit
void
free_hit
(
Hit
*
h
);
typedef
void
(
*
SearchAsyncHandler
)
(
GList
*
hits
,
gpointer
user_data
);
void
init
(
void
);
void
search_async
(
const
char
*
query
,
int
max_results
,
SearchAsyncHandler
handler
,
gpointer
user_data
);
GList
*
search_sync
(
const
char
*
query
,
int
max_results
);
void
fetch_information_from_contact
(
EContact
*
contact
,
EContactField
field
,
gchar
**
info
);
...
...
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