Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
3eb4d41a
Commit
3eb4d41a
authored
Sep 12, 2011
by
Emmanuel Lepage
Browse files
Merge branch 'master' of
git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone
parents
c270b1d6
53622593
Changes
36
Expand all
Show whitespace changes
Inline
Side-by-side
daemon/src/main.cpp
View file @
3eb4d41a
...
...
@@ -113,14 +113,14 @@ main (int argc, char **argv)
if
(
fp
)
{
// PID file exists. Check the former process still alive or not. If alive, give user a hint.
int
oldPid
;
if
(
fscanf
(
fp
,
"%d"
,
&
oldPid
)
!=
1
)
{
fprintf
(
stderr
,
"Couldn't read pidfile
%s
\n
"
,
pidfile
.
c_str
())
;
std
::
cerr
<<
"Couldn't read pidfile
"
<<
pidfile
<<
std
::
endl
;
return
1
;
}
fclose
(
fp
);
if
(
kill
(
oldPid
,
0
)
==
0
)
{
fprintf
(
stderr
,
"There is already a sflphoned daemon running in the system. Starting Failed."
)
;
std
::
cerr
<<
"There is already a sflphoned daemon running in the system. Starting Failed."
<<
std
::
endl
;
return
1
;
}
}
...
...
@@ -140,11 +140,11 @@ main (int argc, char **argv)
try
{
Manager
::
instance
().
init
();
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
e
.
what
()
<<
std
::
endl
;
return
1
;
}
catch
(...)
{
fprintf
(
stderr
,
"An exception occured when initializing the system."
)
;
std
::
cerr
<<
"An exception occured when initializing the system."
<<
std
::
endl
;
return
1
;
}
...
...
gnome/.cproject
View file @
3eb4d41a
...
...
@@ -31,7 +31,6 @@
<listOptionValue
builtIn=
"false"
value=
"/usr/include/libgnome-2.0"
/>
<listOptionValue
builtIn=
"false"
value=
"/usr/include/libgnomeui-2.0"
/>
<listOptionValue
builtIn=
"false"
value=
"/usr/include"
/>
<listOptionValue
builtIn=
"false"
value=
"/usr/include/evolution-data-server-2.30"
/>
</option>
<option
id=
"gnu.c.compiler.option.preprocessor.def.symbols.1676995808"
name=
"Defined symbols (-D)"
superClass=
"gnu.c.compiler.option.preprocessor.def.symbols"
valueType=
"definedSymbols"
>
<listOptionValue
builtIn=
"false"
value=
""ICONS_DIR="/usr/share/sflphone\""
/>
...
...
gnome/src/actions.c
View file @
3eb4d41a
...
...
@@ -62,7 +62,7 @@
#include
"widget/imwidget.h"
static
GHashTable
*
ip2ip_profile
=
NULL
;
static
GHashTable
*
ip2ip_profile
;
static
gchar
**
sflphone_order_history_hash_table
(
GHashTable
*
result
)
{
...
...
@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
static
gboolean
_is_direct_call
(
callable_obj_t
*
c
)
{
if
(
g_strcasecmp
(
c
->
_accountID
,
EMPTY_ENTRY
)
==
0
)
{
if
(
g_strcasecmp
(
c
->
_accountID
,
"empty"
)
==
0
)
{
if
(
!
g_str_has_prefix
(
c
->
_peer_number
,
"sip:"
))
{
gchar
*
new_number
=
g_strconcat
(
"sip:"
,
c
->
_peer_number
,
NULL
);
g_free
(
c
->
_peer_number
);
...
...
@@ -333,7 +333,7 @@ gboolean sflphone_init (GError **error)
if
(
!
dbus_connect
(
error
)
||
!
dbus_register
(
getpid
(),
"Gtk+ Client"
,
error
))
return
FALSE
;
abook
factory_init_factory
();
abook
_init
();
// Init icons factory
init_icon_factory
();
...
...
@@ -414,7 +414,6 @@ sflphone_hang_up()
call_remove_all_errors
(
selectedCall
);
selectedCall
->
_state
=
CALL_STATE_DIALING
;
DEBUG
(
"from sflphone_hang_up : "
);
stop_notification
();
break
;
case
CALL_STATE_TRANSFER
:
dbus_hang_up
(
selectedCall
);
...
...
@@ -465,7 +464,6 @@ sflphone_pick_up()
}
dbus_accept
(
selectedCall
);
stop_notification
();
break
;
case
CALL_STATE_TRANSFER
:
dbus_transfer
(
selectedCall
);
...
...
@@ -766,11 +764,9 @@ sflphone_keypad (guint keyval, gchar * key)
c
->
_history_state
=
INCOMING
;
calltree_update_call
(
history
,
c
,
NULL
);
dbus_accept
(
c
);
stop_notification
();
break
;
case
GDK_Escape
:
dbus_refuse
(
c
);
stop_notification
();
break
;
}
...
...
@@ -825,15 +821,14 @@ sflphone_keypad (guint keyval, gchar * key)
break
;
}
}
else
{
}
else
sflphone_new_call
();
}
}
static
void
place_direct_call
(
const
callable_obj_t
*
c
)
{
assert
(
c
->
_state
==
CALL_STATE_DIALING
);
dbus_place_call
(
c
);
g_
assert
(
c
->
_state
==
CALL_STATE_DIALING
);
dbus_place_call
(
c
);
}
static
int
place_registered_call
(
callable_obj_t
*
c
)
...
...
@@ -861,7 +856,7 @@ static int place_registered_call (callable_obj_t * c)
DEBUG
(
"Actions: Get account for this call"
);
if
(
g_
str
casecmp
(
c
->
_accountID
,
""
)
!=
0
)
{
if
(
str
len
(
c
->
_accountID
)
!=
0
)
{
DEBUG
(
"Actions: Account %s already set for this call"
,
c
->
_accountID
);
current
=
account_list_get_by_id
(
c
->
_accountID
);
}
else
{
...
...
@@ -1055,40 +1050,29 @@ sflphone_rec_call()
void
sflphone_fill_codec_list
()
{
guint
account_list_size
;
guint
i
;
account_t
*
current
=
NULL
;
DEBUG
(
"SFLphone: Fill codec list"
);
account_list_size
=
account_list_get_size
();
guint
account_list_size
=
account_list_get_size
();
for
(
i
=
0
;
i
<
account_list_size
;
i
++
)
{
current
=
account_list_get_nth
(
i
);
for
(
guint
i
=
0
;
i
<
account_list_size
;
i
++
)
{
account_t
*
current
=
account_list_get_nth
(
i
);
if
(
current
)
sflphone_fill_codec_list_per_account
(
&
current
);
sflphone_fill_codec_list_per_account
(
current
);
}
}
void
sflphone_fill_codec_list_per_account
(
account_t
*
*
account
)
void
sflphone_fill_codec_list_per_account
(
account_t
*
account
)
{
gchar
**
order
;
gchar
**
pl
;
GQueue
*
codeclist
;
order
=
(
gchar
**
)
dbus_get_active_audio_codec_list
(
(
*
account
)
->
accountID
);
gchar
**
order
=
dbus_get_active_audio_codec_list
(
account
->
accountID
);
codeclist
=
(
*
account
)
->
codecs
;
GQueue
*
codeclist
=
account
->
codecs
;
// First clean the list
codec_list_clear
(
&
codeclist
);
codec_list_clear
(
&
codeclist
);
if
(
!
(
*
order
))
ERROR
(
"SFLphone: No codec list provided"
);
else
{
for
(
pl
=
order
;
*
pl
;
pl
++
)
{
for
(
gchar
**
pl
=
order
;
*
pl
;
pl
++
)
{
codec_t
*
cpy
=
NULL
;
// Each account will have a copy of the system-wide capabilities
...
...
@@ -1104,8 +1088,7 @@ void sflphone_fill_codec_list_per_account (account_t **account)
guint
caps_size
=
codec_list_get_size
();
guint
i
;
for
(
i
=
0
;
i
<
caps_size
;
i
++
)
{
for
(
guint
i
=
0
;
i
<
caps_size
;
i
++
)
{
codec_t
*
current_cap
=
capabilities_get_nth
(
i
);
// Check if this codec has already been enabled for this account
...
...
@@ -1114,7 +1097,7 @@ void sflphone_fill_codec_list_per_account (account_t **account)
codec_list_add
(
current_cap
,
&
codeclist
);
}
}
(
*
account
)
->
codecs
=
codeclist
;
account
->
codecs
=
codeclist
;
}
void
sflphone_fill_call_list
(
void
)
...
...
@@ -1367,9 +1350,8 @@ sflphone_request_go_clear (void)
{
callable_obj_t
*
selectedCall
=
calltab_get_selected_call
(
current_calls
);
if
(
selectedCall
)
{
if
(
selectedCall
)
dbus_request_go_clear
(
selectedCall
);
}
}
void
...
...
@@ -1389,37 +1371,3 @@ sflphone_call_state_changed (callable_obj_t * c, const gchar * description, cons
update_actions
();
}
void
sflphone_get_interface_addr_from_name
(
char
*
iface_name
,
char
**
iface_addr
,
int
size
)
{
struct
ifreq
ifr
;
int
fd
;
// static char iface_addr[18];
char
*
tmp_addr
;
struct
sockaddr_in
*
saddr_in
;
struct
in_addr
*
addr_in
;
if
(
(
fd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
DEBUG
(
"getInterfaceAddrFromName error could not open socket
\n
"
);
memset
(
&
ifr
,
0
,
sizeof
(
struct
ifreq
));
strcpy
(
ifr
.
ifr_name
,
iface_name
);
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
if
(
ioctl
(
fd
,
SIOCGIFADDR
,
&
ifr
)
<
0
)
DEBUG
(
"getInterfaceAddrFromName use default interface (0.0.0.0)
\n
"
);
saddr_in
=
(
struct
sockaddr_in
*
)
&
ifr
.
ifr_addr
;
addr_in
=
&
(
saddr_in
->
sin_addr
);
tmp_addr
=
(
char
*
)
addr_in
;
snprintf
(
*
iface_addr
,
size
,
"%d.%d.%d.%d"
,
UC
(
tmp_addr
[
0
]),
UC
(
tmp_addr
[
1
]),
UC
(
tmp_addr
[
2
]),
UC
(
tmp_addr
[
3
]));
close
(
fd
);
}
gnome/src/actions.h
View file @
3eb4d41a
...
...
@@ -35,13 +35,10 @@
#include
<libintl.h>
#include
<locale.h>
#include
<accountlist.h>
#include
<codeclist.h>
#include
<sflphone_const.h>
#include
<conference_obj.h>
#define UC(b) (((int)b)&0xff)
#include
"accountlist.h"
#include
"codeclist.h"
#include
"sflphone_const.h"
#include
"conference_obj.h"
/** @file actions.h
* @brief General functions that change the state of the application.
...
...
@@ -191,8 +188,7 @@ void sflphone_set_current_account();
*/
void
sflphone_fill_codec_list
();
void
sflphone_fill_codec_list_per_account
(
account_t
**
);
void
sflphone_fill_codec_list_per_account
(
account_t
*
);
void
sflphone_add_participant
();
...
...
@@ -278,11 +274,6 @@ void sflphone_request_go_clear (void);
*/
void
sflphone_call_state_changed
(
callable_obj_t
*
c
,
const
gchar
*
description
,
const
guint
code
);
/**
* Resolve an interface address given its name
*/
void
sflphone_get_interface_addr_from_name
(
char
*
iface_name
,
char
**
iface_addr
,
int
size
);
void
sflphone_add_main_participant
(
const
conference_obj_t
*
c
);
void
...
...
gnome/src/callable_obj.c
View file @
3eb4d41a
...
...
@@ -177,7 +177,7 @@ callable_obj_t *create_history_entry_from_serialized_form (const gchar *entry)
gint
token
;
for
(
ptr
=
ptr_orig
,
token
=
0
;
ptr
&&
token
<
10
;
token
++
,
ptr
++
)
switch
(
token
)
{
case
0
:
history_state
=
get_history_state_from_id
(
*
ptr
);
break
;
case
0
:
history_state
=
get_history_state_from_id
(
*
ptr
);
break
;
case
1
:
peer_number
=
*
ptr
;
break
;
case
2
:
peer_name
=
*
ptr
;
break
;
case
3
:
time_start
=
*
ptr
;
break
;
...
...
gnome/src/config/accountconfigdialog.c
View file @
3eb4d41a
This diff is collapsed.
Click to expand it.
gnome/src/config/addressbook-config.c
View file @
3eb4d41a
...
...
@@ -31,7 +31,6 @@
#include
"addressbook-config.h"
#include
"searchbar.h"
#include
"contacts/addrbookfactory.h"
// #include "contacts/addressbook/eds.h"
#include
<string.h>
#include
<stdlib.h>
...
...
@@ -44,44 +43,33 @@ enum {
COLUMN_BOOK_ACTIVE
,
COLUMN_BOOK_NAME
,
COLUMN_BOOK_UID
};
void
addressbook_config_load_parameters
(
AddressBook_Config
**
settings
)
AddressBook_Config
*
addressbook_config_load_parameters
()
{
GHashTable
*
_params
=
NULL
;
AddressBook_Config
*
_settings
;
// Allocate a struct
_settings
=
g_new0
(
AddressBook_Config
,
1
);
// Fetch the settings from D-Bus
_params
=
(
GHashTable
*
)
dbus_get_addressbook_settings
();
if
(
_params
==
NULL
)
{
DEBUG
(
"Addressbook: No parameters received, use default"
);
_settings
->
enable
=
1
;
_settings
->
max_results
=
30
;
_settings
->
display_contact_photo
=
0
;
_settings
->
search_phone_business
=
1
;
_settings
->
search_phone_home
=
1
;
_settings
->
search_phone_mobile
=
1
;
AddressBook_Config
*
config
=
g_new0
(
AddressBook_Config
,
1
);
GHashTable
*
params
=
dbus_get_addressbook_settings
();
if
(
params
==
NULL
)
{
config
->
enable
=
1
;
config
->
max_results
=
30
;
config
->
display_contact_photo
=
0
;
config
->
search_phone_business
=
1
;
config
->
search_phone_home
=
1
;
config
->
search_phone_mobile
=
1
;
}
else
{
_settings
->
enable
=
(
size_t
)
(
g_hash_table_lookup
(
_
params
,
ADDRESSBOOK_ENABLE
));
_settings
->
max_results
=
(
size_t
)
(
g_hash_table_lookup
(
_
params
,
ADDRESSBOOK_MAX_RESULTS
));
_settings
->
display_contact_photo
=
(
size_t
)
(
g_hash_table_lookup
(
_
params
,
ADDRESSBOOK_DISPLAY_CONTACT_PHOTO
));
_settings
->
search_phone_business
=
(
size_t
)
(
g_hash_table_lookup
(
_
params
,
ADDRESSBOOK_DISPLAY_PHONE_BUSINESS
));
_settings
->
search_phone_home
=
(
size_t
)
(
g_hash_table_lookup
(
_
params
,
ADDRESSBOOK_DISPLAY_PHONE_HOME
));
_settings
->
search_phone_mobile
=
(
size_t
)
(
g_hash_table_lookup
(
_
params
,
ADDRESSBOOK_DISPLAY_PHONE_MOBILE
));
config
->
enable
=
(
size_t
)
(
g_hash_table_lookup
(
params
,
ADDRESSBOOK_ENABLE
));
config
->
max_results
=
(
size_t
)
(
g_hash_table_lookup
(
params
,
ADDRESSBOOK_MAX_RESULTS
));
config
->
display_contact_photo
=
(
size_t
)
(
g_hash_table_lookup
(
params
,
ADDRESSBOOK_DISPLAY_CONTACT_PHOTO
));
config
->
search_phone_business
=
(
size_t
)
(
g_hash_table_lookup
(
params
,
ADDRESSBOOK_DISPLAY_PHONE_BUSINESS
));
config
->
search_phone_home
=
(
size_t
)
(
g_hash_table_lookup
(
params
,
ADDRESSBOOK_DISPLAY_PHONE_HOME
));
config
->
search_phone_mobile
=
(
size_t
)
(
g_hash_table_lookup
(
params
,
ADDRESSBOOK_DISPLAY_PHONE_MOBILE
));
}
DEBUG
(
"Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d"
,
_settings
->
enable
,
_settings
->
max_results
,
_settings
->
display_contact_photo
,
_settings
->
search_phone_business
,
_settings
->
search_phone_home
,
_settings
->
search_phone_mobile
);
config
->
enable
,
config
->
max_results
,
config
->
display_contact_photo
,
config
->
search_phone_business
,
config
->
search_phone_home
,
config
->
search_phone_mobile
);
*
settings
=
_settings
;
return
config
;
}
void
...
...
@@ -211,9 +199,8 @@ addressbook_config_book_active_toggled (
gchar
*
name
;
gchar
*
uid
;
if
(
!
a
bookfactory_is_addressbook_loaded
())
{
if
(
!
a
ddrbook
)
return
;
}
// Get path of clicked book active toggle box
treePath
=
gtk_tree_path_new_from_string
(
path
);
...
...
@@ -223,8 +210,6 @@ addressbook_config_book_active_toggled (
return
;
}
AddrBookFactory
*
factory
=
abookfactory_get_factory
();
gtk_tree_model_get_iter
(
model
,
&
iter
,
treePath
);
// Get active value at iteration
...
...
@@ -240,7 +225,7 @@ addressbook_config_book_active_toggled (
gtk_tree_path_free
(
treePath
);
// Update current memory stored books data
book_data
=
factory
->
addrbook
->
get_book_data_by_uid
(
uid
);
book_data
=
addrbook
->
get_book_data_by_uid
(
uid
);
if
(
book_data
==
NULL
)
{
ERROR
(
"Addressbook: Error: Could not find addressbook %s"
,
uid
);
}
...
...
@@ -292,14 +277,11 @@ addressbook_config_fill_book_list()
book_data_t
*
book_data
;
gchar
**
book_list
;
if
(
!
a
bookfactory_is_addressbook_loaded
())
{
if
(
!
a
ddrbook
)
return
;
}
AddrBookFactory
*
factory
=
abookfactory_get_factory
();
book_list
=
dbus_get_addressbook_list
();
GSList
*
books_data
=
factory
->
addrbook
->
get_books_data
(
book_list
);
GSList
*
books_data
=
addrbook
->
get_books_data
(
book_list
);
if
(
!
books_data
)
{
DEBUG
(
"Addressbook: No valid books data (%s:%d)"
,
__FILE__
,
__LINE__
);
...
...
@@ -338,7 +320,7 @@ create_addressbook_settings()
GtkTreeViewColumn
*
tree_view_column
;
// Load the user value
addressbook_config
_load_parameters
(
&
addressbook_config
);
addressbook_config
=
addressbook_config
_load_parameters
(
);
ret
=
gtk_vbox_new
(
FALSE
,
10
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
ret
),
10
);
...
...
gnome/src/config/addressbook-config.h
View file @
3eb4d41a
...
...
@@ -67,12 +67,9 @@ void
addressbook_config_save_parameters
(
void
);
/**
* Initialize the address book structure, and retrieve the saved parameters through D-Bus
*
* @param settings The addressbook structure
* Return the saved parameters through D-Bus
*/
void
addressbook_config_load_parameters
(
AddressBook_Config
**
settings
);
AddressBook_Config
*
addressbook_config_load_parameters
();
gboolean
addressbook_display
(
AddressBook_Config
*
settings
,
const
gchar
*
field
);
...
...
gnome/src/config/preferencesdialog.c
View file @
3eb4d41a
...
...
@@ -285,7 +285,7 @@ create_general_settings ()
void
save_configuration_parameters
(
void
)
{
if
(
abook
factory_is_addressbook_loaded
()
)
{
if
(
a
ddr
book
)
{
// Address book config
addressbook_config_save_parameters
();
}
...
...
@@ -410,7 +410,7 @@ show_preferences_dialog ()
gtk_notebook_append_page
(
GTK_NOTEBOOK
(
notebook
),
tab
,
gtk_label_new
(
_
(
"Shortcuts"
)));
gtk_notebook_page_num
(
GTK_NOTEBOOK
(
notebook
),
tab
);
if
(
abook
factory_is_addressbook_loaded
()
)
{
if
(
a
ddr
book
)
{
// Addressbook tab
tab
=
create_addressbook_settings
();
gtk_notebook_append_page
(
GTK_NOTEBOOK
(
notebook
),
tab
,
gtk_label_new
(
_
(
"Address Book"
)));
...
...
@@ -451,7 +451,7 @@ GtkTreeModel* createModel()
GError
*
error
=
NULL
;
gint
i
,
nb_entries
;
nb_entries
=
abook
factory_is_addressbook_loaded
()
?
5
:
4
;
nb_entries
=
a
ddr
book
?
5
:
4
;
store
=
gtk_list_store_new
(
3
,
GDK_TYPE_PIXBUF
,
G_TYPE_STRING
,
G_TYPE_INT
);
GtkIconTheme
*
theme
=
gtk_icon_theme_get_default
();
...
...
gnome/src/contacts/addrbookfactory.c
View file @
3eb4d41a
...
...
@@ -37,93 +37,8 @@
#include
<glib.h>
#include
<dlfcn.h>
static
void
handler_async_search
(
GList
*
hits
,
gpointer
user_data
)
;
AddrBookHandle
*
addrbook
=
NULL
;
AddrBookFactory
addressbookFactory
=
{
.
addrbook
=
NULL
};
AddrBookFactory
*
abookfactory_get_factory
(
void
)
{
return
&
addressbookFactory
;
}
gboolean
abookfactory_is_addressbook_loaded
(
void
)
{
return
(
addressbookFactory
.
addrbook
!=
NULL
)
?
TRUE
:
FALSE
;
}
void
abookfactory_init_factory
()
{
abookfactory_load_module
(
&
addressbookFactory
);
}
void
abookfactory_scan_directory
(
AddrBookFactory
*
factory
UNUSED
)
{
}
void
abookfactory_load_module
(
AddrBookFactory
*
factory
)
{
gchar
*
plugindir
=
PLUGINS_DIR
;
gchar
*
pluginpath
=
g_strdup_printf
(
"%s/libevladdrbook.so"
,
plugindir
);
DEBUG
(
"AddressbookFactory: Loading addressbook: %s"
,
pluginpath
);
void
*
handle
=
dlopen
(
pluginpath
,
RTLD_LAZY
);
g_free
(
pluginpath
);
if
(
handle
==
NULL
)
{
ERROR
(
"AddressbookFactory: Error: Could not load addressbook"
);
return
;
}
AddrBookHandle
*
ab
=
g_malloc
(
sizeof
(
AddrBookHandle
));
ab
->
init
=
dlsym
(
handle
,
"addressbook_init"
);
if
(
ab
->
init
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook_init function"
);
ab
->
is_ready
=
dlsym
(
handle
,
"addressbook_is_ready"
);
if
(
ab
->
is_ready
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_is_ready function"
);
ab
->
is_enabled
=
dlsym
(
handle
,
"addressbook_is_enabled"
);
if
(
ab
->
is_enabled
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_is_enabled function"
);
ab
->
is_active
=
dlsym
(
handle
,
"addressbook_is_active"
);
if
(
ab
->
is_active
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_is_active function"
);
ab
->
search
=
dlsym
(
handle
,
"addressbook_search"
);
if
(
ab
->
search
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_search function"
);
ab
->
get_books_data
=
dlsym
(
handle
,
"addressbook_get_books_data"
);
if
(
ab
->
get_books_data
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_get_books_data function"
);
ab
->
get_book_data_by_uid
=
dlsym
(
handle
,
"addressbook_get_book_data_by_uid"
);
if
(
ab
->
get_book_data_by_uid
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_get_books_data_by_uid function"
);
ab
->
set_current_book
=
dlsym
(
handle
,
"addressbook_set_current_book"
);
if
(
ab
->
set_current_book
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_ser_current_book"
);
ab
->
set_search_type
=
dlsym
(
handle
,
"addressbook_set_search_type"
);
if
(
ab
->
set_search_type
==
NULL
)
ERROR
(
"AddressbookFactory: Error: Could not load addressbook addressbook_set_search_type"
);
ab
->
search_cb
=
handler_async_search
;
DEBUG
(
"AddressbookFactory: Loading done"
);
factory
->
addrbook
=
ab
;
}
void
free_hit
(
Hit
*
h
)
{
g_free
(
h
->
name
);
g_free
(
h
->
phone_business
);
g_free
(
h
->
phone_home
);
g_free
(
h
->
phone_mobile
);
g_free
(
h
);
}
/**
* Callback called after all book have been processed
...
...
@@ -131,52 +46,73 @@ free_hit (Hit *h)
static
void
handler_async_search
(
GList
*
hits
,
gpointer
user_data
)
{
GList
*
i
;
// Retrieve the address book parameters
AddressBook_Config
*
addressbook_config
=
user_data
;
// reset previous results
calltree_reset
(
contacts
);
calllist_reset
(
contacts
);
for
(
i
=
hits
;
i
!=
NULL
;
i
=
i
->
next
)
{
for
(
GList
*
i
=
hits
;
i
!=
NULL
;
i
=
i
->
next
)
{
GdkPixbuf
*
photo
=
NULL
;
Hit
*
entry
=
i
->
data
;
if
(
!
entry
)
continue
;
// Get the photo
if
(
addressbook_display
(
addressbook_config
,
ADDRESSBOOK_DISPLAY_CONTACT_PHOTO
))
photo
=
entry
->
photo
;
// Create entry for business phone information
if
(
addressbook_display
(
addressbook_config
,
ADDRESSBOOK_DISPLAY_PHONE_BUSINESS
))
calllist_add_contact
(
entry
->
name
,
entry
->
phone_business
,
CONTACT_PHONE_BUSINESS
,
photo
);
// Create entry for home phone information
if
(
addressbook_display
(
addressbook_config
,
ADDRESSBOOK_DISPLAY_PHONE_HOME
))
calllist_add_contact
(
entry
->
name
,
entry
->
phone_home
,
CONTACT_PHONE_HOME
,
photo
);
// Create entry for mobile phone iddnformation
if
(
addressbook_display
(
addressbook_config
,
ADDRESSBOOK_DISPLAY_PHONE_MOBILE
))
calllist_add_contact
(
entry
->
name
,
entry
->
phone_mobile
,
CONTACT_PHONE_MOBILE
,
photo
);
free_hit
(
entry
);
g_free
(
entry
->
name
);
g_free
(
entry
->
phone_business
);
g_free
(
entry
->
phone_home
);
g_free
(
entry
->
phone_mobile
);
g_free
(
entry
);
}
g_list_free
(
hits
);
gtk_widget_grab_focus
(
GTK_WIDGET
(
contacts
->
view
));
}
void
abook_init
()
{
void
*
handle
=
dlopen
(
PLUGINS_DIR
"/libevladdrbook.so"
,
RTLD_LAZY
);
if
(
handle
==
NULL
)
{
ERROR
(
"Addressbook: Error: Could not load addressbook"
);
return
;