Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
717db9fd
Commit
717db9fd
authored
Sep 11, 2014
by
Gautier Pelloux-Prayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved strict compilation flags
parent
fcce4b4b
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
362 additions
and
259 deletions
+362
-259
configure.ac
configure.ac
+20
-20
console/commands.c
console/commands.c
+4
-2
console/linphonec.c
console/linphonec.c
+3
-2
coreapi/chat.c
coreapi/chat.c
+7
-4
coreapi/help/buddy_status.c
coreapi/help/buddy_status.c
+3
-2
coreapi/help/chatroom.c
coreapi/help/chatroom.c
+4
-4
coreapi/help/filetransfer.c
coreapi/help/filetransfer.c
+8
-5
coreapi/help/notify.c
coreapi/help/notify.c
+20
-18
coreapi/help/registration.c
coreapi/help/registration.c
+21
-19
coreapi/lpc2xml.c
coreapi/lpc2xml.c
+29
-19
coreapi/message_storage.c
coreapi/message_storage.c
+21
-11
coreapi/misc.c
coreapi/misc.c
+6
-5
gtk/audio_assistant.c
gtk/audio_assistant.c
+24
-16
gtk/calllogs.c
gtk/calllogs.c
+13
-11
gtk/chat.c
gtk/chat.c
+22
-21
gtk/conference.c
gtk/conference.c
+14
-12
gtk/friendlist.c
gtk/friendlist.c
+12
-12
gtk/incall_view.c
gtk/incall_view.c
+20
-10
gtk/main.c
gtk/main.c
+9
-6
gtk/propertybox.c
gtk/propertybox.c
+7
-5
gtk/setupwizard.c
gtk/setupwizard.c
+72
-39
gtk/singleinstance.c
gtk/singleinstance.c
+3
-2
mediastreamer2
mediastreamer2
+1
-1
oRTP
oRTP
+1
-1
tester/message_tester.c
tester/message_tester.c
+6
-4
tester/tester.c
tester/tester.c
+1
-1
tester/upnp_tester.c
tester/upnp_tester.c
+2
-1
tools/lpc2xml_test.c
tools/lpc2xml_test.c
+5
-3
tools/xml2lpc_test.c
tools/xml2lpc_test.c
+4
-3
No files found.
configure.ac
View file @
717db9fd
...
...
@@ -135,7 +135,7 @@ AC_DEFINE_UNQUOTED(LINPHONE_ALL_LANGS, "$ALL_LINGUAS", [All supported languages]
if test "$mingw_found" != "yes" ; then
dnl gettext macro does not work properly under mingw. And we want to use the one provided by GTK.
dnl AM_GNU_GETTEXT pollutes CPPFLAGS: workaround this.
CPPFLAGS_save=$CPPFLAGS
AM_GNU_GETTEXT([external])
...
...
@@ -185,25 +185,25 @@ if test "$enable_ldap" = "true"; then
[AC_MSG_ERROR([You need libldap for LDAP support])]
)
AC_CHECK_HEADERS(ldap.h, [foo=bar], [AC_MSG_ERROR( [ldap.h not found] ) ] )
found_ldap=yes
found_ldap=yes
fi
PKG_CHECK_MODULES(SASL, [libsasl2],[found_sasl=yes],[found_sasl=no] )
if test "$found_sasl" = "no"; then
AC_CHECK_LIB(sasl2, sasl_client_init , [SASL_LIBS="-lsasl2"],
[AC_MSG_ERROR([You need SASL for LDAP support] ) ]
)
AC_CHECK_HEADERS(sasl/sasl.h,foo=bar, [AC_MSG_ERROR([sasl/sasl.h not found])])
found_sasl=yes
found_sasl=yes
fi
AC_SUBST(LDAP_CFLAGS)
AC_SUBST(LDAP_LIBS)
AC_SUBST(SASL_CFLAGS)
AC_SUBST(SASL_LIBS)
if test "$found_ldap$found_sasl" = "yesyes"; then
AC_DEFINE(BUILD_LDAP,1,[Defined if LDAP build option enabled])
else
...
...
@@ -248,7 +248,7 @@ AC_ARG_ENABLE(upnp,
)
if test "$build_upnp" != "false" ; then
PKG_CHECK_MODULES([LIBUPNP], [libupnp],
PKG_CHECK_MODULES([LIBUPNP], [libupnp],
[if pkg-config --atleast-version=1.6 "libupnp < 1.7"; then
build_upnp=true
else
...
...
@@ -277,7 +277,7 @@ fi
AM_CONDITIONAL(BUILD_TOOLS, test x$build_tools != xfalse)
if test "$build_tools" != "false" ; then
build_tools=true
AC_DEFINE(BUILD_TOOLS, 1, [Define if tools enabled] )
AC_DEFINE(BUILD_TOOLS, 1, [Define if tools enabled] )
fi
dnl conditionnal build of gtk interface.
...
...
@@ -553,10 +553,10 @@ AC_ARG_WITH(ffmpeg,
)
if test "$video" = "true"; then
if test "$enable_x11" = "true"; then
AC_CHECK_HEADERS(X11/Xlib.h)
if test "$build_macos" = "yes"; then
if test "$build_macos" = "yes"; then
X11_LIBS="-L/usr/X11/lib -lX11"
else
AC_CHECK_LIB(X11,XUnmapWindow, X11_LIBS="-lX11")
...
...
@@ -644,7 +644,7 @@ AC_SUBST(LIBSOUP_LIBS)
AM_CONDITIONAL(BUILD_WIZARD, test x$build_wizard != xfalse)
if test "$build_wizard" != "false" ; then
build_wizard=true
AC_DEFINE(BUILD_WIZARD, 1, [Define if wizard enabled] )
AC_DEFINE(BUILD_WIZARD, 1, [Define if wizard enabled] )
fi
AC_CHECK_HEADERS(libudev.h)
...
...
@@ -656,18 +656,18 @@ AC_CHECK_LIB(udev,udev_new)
AC_ARG_ENABLE(strict,
AC_HELP_STRING([--enable-strict], [Build with stricter options
(gcc only)
@<:@yes@:>@]),
AC_HELP_STRING([--enable-strict], [Build with stricter options @<:@yes@:>@]),
[strictness="${enableval}"],
[strictness=yes]
)
STRICT_OPTIONS="-Wall"
STRICT_OPTIONS="-Wall
-Wdeclaration-after-statement -Wuninitialized
"
#for clang
case $CC in
case $CC in
*clang*)
STRICT_OPTIONS="$STRICT_OPTIONS -Qunused-arguments"
STRICT_OPTIONS="$STRICT_OPTIONS -Qunused-arguments
"
;;
esac
...
...
@@ -783,13 +783,13 @@ if test x$enable_msg_storage != xfalse; then
fi
enable_msg_storage=false
fi
AC_SUBST(SQLITE3_CFLAGS)
AC_SUBST(SQLITE3_LIBS)
fi
PKG_CHECK_MODULES(BELLESIP, [belle-sip >= 1.3.1])
SIPSTACK_CFLAGS="$BELLESIP_CFLAGS"
...
...
@@ -887,7 +887,7 @@ AC_PATH_PROG(DOXYGEN,doxygen,false)
AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false)
AC_CONFIG_FILES([
AC_CONFIG_FILES([
Makefile
build/Makefile
build/macos/Makefile
...
...
console/commands.c
View file @
717db9fd
...
...
@@ -603,6 +603,7 @@ lpc_cmd_chat(LinphoneCore *lc, char *args)
char
*
arg1
=
args
;
char
*
arg2
=
NULL
;
char
*
ptr
=
args
;
LinphoneChatRoom
*
cr
;
if
(
!
args
)
return
0
;
...
...
@@ -619,7 +620,7 @@ lpc_cmd_chat(LinphoneCore *lc, char *args)
/* missing one parameter */
return
0
;
}
LinphoneChatRoom
*
cr
=
linphone_core_create_chat_room
(
lc
,
arg1
);
cr
=
linphone_core_create_chat_room
(
lc
,
arg1
);
linphone_chat_room_send_message
(
cr
,
arg2
);
return
1
;
}
...
...
@@ -2441,8 +2442,9 @@ static void lpc_display_call_states(LinphoneCore *lc){
}
else
{
for
(;
elem
!=
NULL
;
elem
=
elem
->
next
){
const
char
*
flag
;
bool_t
in_conference
;
call
=
(
LinphoneCall
*
)
elem
->
data
;
bool_t
in_conference
=
linphone_call_params_get_local_conference_mode
(
linphone_call_get_current_params
(
call
));
in_conference
=
linphone_call_params_get_local_conference_mode
(
linphone_call_get_current_params
(
call
));
tmp
=
linphone_call_get_remote_address_as_string
(
call
);
flag
=
in_conference
?
"conferencing"
:
""
;
flag
=
linphone_call_has_transfer_pending
(
call
)
?
"transfer pending"
:
flag
;
...
...
console/linphonec.c
View file @
717db9fd
...
...
@@ -367,8 +367,8 @@ static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, L
if
(
auto_answer
)
{
answer_call
=
TRUE
;
}
else
if
(
real_early_media_sending
)
{
linphonec_out
(
"Sending early media using real hardware
\n
"
);
LinphoneCallParams
*
callparams
=
linphone_core_create_default_call_parameters
(
lc
);
linphonec_out
(
"Sending early media using real hardware
\n
"
);
linphone_call_params_enable_early_media_sending
(
callparams
,
TRUE
);
if
(
vcap_enabled
)
linphone_call_params_enable_video
(
callparams
,
TRUE
);
linphone_core_accept_early_media_with_params
(
lc
,
call
,
callparams
);
...
...
@@ -828,12 +828,13 @@ linphonec_prompt_for_auth_final(LinphoneCore *lc)
#ifdef HAVE_READLINE
rl_hook_func_t
*
old_event_hook
;
#endif
LinphoneAuthInfo
*
pending_auth
;
if
(
reentrancy
!=
0
)
return
0
;
reentrancy
++
;
LinphoneAuthInfo
*
pending_auth
=
auth_stack
.
elem
[
auth_stack
.
nitems
-
1
];
pending_auth
=
auth_stack
.
elem
[
auth_stack
.
nitems
-
1
];
snprintf
(
auth_prompt
,
256
,
"Password for %s on %s: "
,
pending_auth
->
username
,
pending_auth
->
realm
);
...
...
coreapi/chat.c
View file @
717db9fd
...
...
@@ -100,7 +100,7 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_
char
*
buf
=
(
char
*
)
buffer
;
/* if we've not reach the end of file yet, ask for more data*/
if
(
offset
<
chatMsg
->
file_transfer_information
->
size
){
if
(
offset
<
chatMsg
->
file_transfer_information
->
size
){
/* get data from call back */
lc
->
vtable
.
file_transfer_send
(
lc
,
chatMsg
,
chatMsg
->
file_transfer_information
,
buf
,
size
);
}
...
...
@@ -130,13 +130,16 @@ static void linphone_chat_message_process_response_from_post_file(void *data, co
belle_http_request_t
*
req
;
belle_sip_multipart_body_handler_t
*
bh
;
char
*
ua
;
char
*
content_type
;
char
*
first_part_header
;
belle_sip_user_body_handler_t
*
first_part_bh
;
/* temporary storage of the header of the message part header */
char
*
content_type
=
belle_sip_strdup_printf
(
"%s/%s"
,
msg
->
file_transfer_information
->
type
,
msg
->
file_transfer_information
->
subtype
);
char
*
first_part_header
=
belle_sip_strdup_printf
(
"Content-Disposition: form-data; name=
\"
File
\"
; filename=
\"
%s
\"\r\n
Content-Type: %s
\r\n\r\n
"
,
msg
->
file_transfer_information
->
name
,
content_type
);
content_type
=
belle_sip_strdup_printf
(
"%s/%s"
,
msg
->
file_transfer_information
->
type
,
msg
->
file_transfer_information
->
subtype
);
first_part_header
=
belle_sip_strdup_printf
(
"Content-Disposition: form-data; name=
\"
File
\"
; filename=
\"
%s
\"\r\n
Content-Type: %s
\r\n\r\n
"
,
msg
->
file_transfer_information
->
name
,
content_type
);
/* create a user body handler to take care of the file */
belle_sip_user_body_handler_t
*
first_part_bh
=
belle_sip_user_body_handler_new
(
msg
->
file_transfer_information
->
size
,
NULL
,
NULL
,
linphone_chat_message_file_transfer_on_send_body
,
msg
);
first_part_bh
=
belle_sip_user_body_handler_new
(
msg
->
file_transfer_information
->
size
,
NULL
,
NULL
,
linphone_chat_message_file_transfer_on_send_body
,
msg
);
belle_sip_body_handler_set_header
((
belle_sip_body_handler_t
*
)
first_part_bh
,
first_part_header
);
/* set the header for this part */
belle_sip_free
(
first_part_header
);
...
...
coreapi/help/buddy_status.c
View file @
717db9fd
...
...
@@ -87,6 +87,8 @@ int main(int argc, char *argv[]){
char
*
identity
=
NULL
;
char
*
password
=
NULL
;
LinphoneFriend
*
my_friend
=
NULL
;
/* takes sip uri identity from the command line arguments */
if
(
argc
>
1
){
dest_friend
=
argv
[
1
];
...
...
@@ -123,11 +125,11 @@ int main(int argc, char *argv[]){
LinphoneProxyConfig
*
proxy_cfg
=
linphone_proxy_config_new
();
/*parse identity*/
LinphoneAddress
*
from
=
linphone_address_new
(
identity
);
LinphoneAuthInfo
*
info
;
if
(
from
==
NULL
){
printf
(
"%s not a valid sip uri, must be like sip:toto@sip.linphone.org
\n
"
,
identity
);
goto
end
;
}
LinphoneAuthInfo
*
info
;
if
(
password
!=
NULL
){
info
=
linphone_auth_info_new
(
linphone_address_get_username
(
from
),
NULL
,
password
,
NULL
,
NULL
,
NULL
);
/*create authentication structure from identity*/
linphone_core_add_auth_info
(
lc
,
info
);
/*add authentication info to LinphoneCore*/
...
...
@@ -152,7 +154,6 @@ int main(int argc, char *argv[]){
while
(
running
&&
linphone_proxy_config_get_state
(
proxy_cfg
)
==
LinphoneRegistrationProgress
);
}
LinphoneFriend
*
my_friend
=
NULL
;
if
(
dest_friend
)
{
my_friend
=
linphone_friend_new_with_address
(
dest_friend
);
/*creates friend object from dest*/
...
...
coreapi/help/chatroom.c
View file @
717db9fd
/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
Copyright (C) 2010 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
...
...
@@ -55,7 +55,7 @@ int main(int argc, char *argv[]){
LinphoneCoreVTable
vtable
=
{
0
};
char
*
dest_friend
=
NULL
;
LinphoneChatRoom
*
chat_room
;
/* takes sip uri identity from the command line arguments */
if
(
argc
>
1
){
...
...
@@ -67,7 +67,7 @@ int main(int argc, char *argv[]){
#ifdef DEBUG
linphone_core_enable_logs
(
NULL
);
/*enable liblinphone logs.*/
#endif
/*
/*
Fill the LinphoneCoreVTable with application callbacks.
All are optional. Here we only use the text_received callback
in order to get notifications about incoming message.
...
...
@@ -81,7 +81,7 @@ int main(int argc, char *argv[]){
/*Next step is to create a chat root*/
LinphoneChatRoom
*
chat_room
=
linphone_core_create_chat_room
(
lc
,
dest_friend
);
chat_room
=
linphone_core_create_chat_room
(
lc
,
dest_friend
);
linphone_chat_room_send_message
(
chat_room
,
"Hello world"
);
/*sending message*/
...
...
coreapi/help/filetransfer.c
View file @
717db9fd
/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
Copyright (C) 2010 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
...
...
@@ -144,6 +144,10 @@ int main(int argc, char *argv[]){
const
char
*
dest_friend
=
NULL
;
int
i
;
const
char
*
big_file_content
=
"big file"
;
LinphoneChatRoom
*
chat_room
;
LinphoneContent
content
;
LinphoneChatMessage
*
chat_message
;
/*seting dummy file content to something*/
for
(
i
=
0
;
i
<
sizeof
(
big_file
);
i
+=
strlen
(
big_file_content
))
memcpy
(
big_file
+
i
,
big_file_content
,
strlen
(
big_file_content
));
...
...
@@ -156,7 +160,7 @@ int main(int argc, char *argv[]){
#ifdef DEBUG
linphone_core_enable_logs
(
NULL
);
/*enable liblinphone logs.*/
#endif
/*
/*
Fill the LinphoneCoreVTable with application callbacks.
All are optional. Here we only use the file_transfer_received callback
in order to get notifications about incoming file receive, file_transfer_send to feed file to be transfered
...
...
@@ -183,9 +187,8 @@ int main(int argc, char *argv[]){
/*Next step is to create a chat room*/
LinphoneChatRoom
*
chat_room
=
linphone_core_create_chat_room
(
lc
,
dest_friend
);
chat_room
=
linphone_core_create_chat_room
(
lc
,
dest_friend
);
LinphoneContent
content
;
memset
(
&
content
,
0
,
sizeof
(
content
));
content
.
type
=
"text"
;
content
.
subtype
=
"plain"
;
...
...
@@ -193,7 +196,7 @@ int main(int argc, char *argv[]){
content
.
name
=
"bigfile.txt"
;
/*now create a chat message with custom content*/
LinphoneChatMessage
*
chat_message
=
linphone_chat_room_create_file_transfer_message
(
chat_room
,
&
content
);
chat_message
=
linphone_chat_room_create_file_transfer_message
(
chat_room
,
&
content
);
if
(
chat_message
==
NULL
)
{
printf
(
"returned message is null
\n
"
);
}
...
...
coreapi/help/notify.c
View file @
717db9fd
/*
linphone
Copyright (C) 2013 Belledonne Communications SARL
Copyright (C) 2013 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
...
...
@@ -89,6 +89,10 @@ int main(int argc, char *argv[]){
char
*
identity
=
NULL
;
char
*
password
=
NULL
;
int
i
;
LinphoneProxyConfig
*
proxy_cfg
;
LinphoneAddress
*
from
;
LinphoneAuthInfo
*
info
;
const
char
*
server_addr
;
/* takes sip uri identity from the command line arguments */
if
(
argc
>
1
){
...
...
@@ -105,7 +109,7 @@ int main(int argc, char *argv[]){
#ifdef DEBUG
linphone_core_enable_logs
(
NULL
);
/*enable liblinphone logs.*/
#endif
/*
/*
Fill the LinphoneCoreVTable with application callbacks.
All are optional. Here we only use the registration_state_changed callbacks
in order to get notifications about the progress of the registration.
...
...
@@ -118,30 +122,28 @@ int main(int argc, char *argv[]){
*/
lc
=
linphone_core_new
(
&
vtable
,
NULL
,
NULL
,
data
);
LinphoneProxyConfig
*
proxy_cfg
;
/*create proxy config*/
proxy_cfg
=
linphone_proxy_config_new
();
/*parse identity*/
LinphoneAddress
*
from
=
linphone_address_new
(
identity
);
from
=
linphone_address_new
(
identity
);
if
(
from
==
NULL
){
printf
(
"%s not a valid sip uri, must be like sip:toto@sip.linphone.org
\n
"
,
identity
);
goto
end
;
}
LinphoneAuthInfo
*
info
;
if
(
password
!=
NULL
){
info
=
linphone_auth_info_new
(
linphone_address_get_username
(
from
),
NULL
,
password
,
NULL
,
NULL
,
NULL
);
/*create authentication structure from identity*/
linphone_core_add_auth_info
(
lc
,
info
);
/*add authentication info to LinphoneCore*/
}
if
(
password
!=
NULL
){
info
=
linphone_auth_info_new
(
linphone_address_get_username
(
from
),
NULL
,
password
,
NULL
,
NULL
,
NULL
);
/*create authentication structure from identity*/
linphone_core_add_auth_info
(
lc
,
info
);
/*add authentication info to LinphoneCore*/
}
// configure proxy entries
linphone_proxy_config_set_identity
(
proxy_cfg
,
identity
);
/*set identity with user name and domain*/
const
char
*
server_addr
=
linphone_address_get_domain
(
from
);
/*extract domain address from identity*/
linphone_proxy_config_set_server_addr
(
proxy_cfg
,
server_addr
);
/* we assume domain = proxy server address*/
linphone_proxy_config_enable_register
(
proxy_cfg
,
TRUE
);
/*activate registration for this proxy config*/
linphone_address_destroy
(
from
);
/*release resource*/
// configure proxy entries
linphone_proxy_config_set_identity
(
proxy_cfg
,
identity
);
/*set identity with user name and domain*/
server_addr
=
linphone_address_get_domain
(
from
);
/*extract domain address from identity*/
linphone_proxy_config_set_server_addr
(
proxy_cfg
,
server_addr
);
/* we assume domain = proxy server address*/
linphone_proxy_config_enable_register
(
proxy_cfg
,
TRUE
);
/*activate registration for this proxy config*/
linphone_address_destroy
(
from
);
/*release resource*/
linphone_core_add_proxy_config
(
lc
,
proxy_cfg
);
/*add proxy config to linphone core*/
linphone_core_set_default_proxy
(
lc
,
proxy_cfg
);
/*set to default proxy*/
linphone_core_add_proxy_config
(
lc
,
proxy_cfg
);
/*add proxy config to linphone core*/
linphone_core_set_default_proxy
(
lc
,
proxy_cfg
);
/*set to default proxy*/
i
=
0
;
/* main loop for receiving notifications and doing background linphonecore work: */
...
...
@@ -163,7 +165,7 @@ int main(int argc, char *argv[]){
linphone_proxy_config_edit
(
proxy_cfg
);
/*start editing proxy configuration*/
linphone_proxy_config_enable_register
(
proxy_cfg
,
FALSE
);
/*de-activate registration for this proxy config*/
linphone_proxy_config_done
(
proxy_cfg
);
/*initiate REGISTER with expire = 0*/
if
(
data
->
ev
){
linphone_event_terminate
(
data
->
ev
);
}
...
...
coreapi/help/registration.c
View file @
717db9fd
/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
Copyright (C) 2010 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
...
...
@@ -60,9 +60,13 @@ static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyCo
LinphoneCore
*
lc
;
int
main
(
int
argc
,
char
*
argv
[]){
LinphoneCoreVTable
vtable
=
{
0
};
LinphoneProxyConfig
*
proxy_cfg
;
LinphoneAddress
*
from
;
LinphoneAuthInfo
*
info
;
char
*
identity
=
NULL
;
char
*
password
=
NULL
;
const
char
*
server_addr
;
/* takes sip uri identity from the command line arguments */
if
(
argc
>
1
){
...
...
@@ -79,7 +83,7 @@ int main(int argc, char *argv[]){
#ifdef DEBUG
linphone_core_enable_logs
(
NULL
);
/*enable liblinphone logs.*/
#endif
/*
/*
Fill the LinphoneCoreVTable with application callbacks.
All are optional. Here we only use the registration_state_changed callbacks
in order to get notifications about the progress of the registration.
...
...
@@ -91,30 +95,28 @@ int main(int argc, char *argv[]){
*/
lc
=
linphone_core_new
(
&
vtable
,
NULL
,
NULL
,
NULL
);
LinphoneProxyConfig
*
proxy_cfg
;
/*create proxy config*/
proxy_cfg
=
linphone_proxy_config_new
();
/*parse identity*/
LinphoneAddress
*
from
=
linphone_address_new
(
identity
);
from
=
linphone_address_new
(
identity
);
if
(
from
==
NULL
){
printf
(
"%s not a valid sip uri, must be like sip:toto@sip.linphone.org
\n
"
,
identity
);
goto
end
;
}
LinphoneAuthInfo
*
info
;
if
(
password
!=
NULL
){
info
=
linphone_auth_info_new
(
linphone_address_get_username
(
from
),
NULL
,
password
,
NULL
,
NULL
,
NULL
);
/*create authentication structure from identity*/
linphone_core_add_auth_info
(
lc
,
info
);
/*add authentication info to LinphoneCore*/
}
// configure proxy entries
linphone_proxy_config_set_identity
(
proxy_cfg
,
identity
);
/*set identity with user name and domain*/
const
char
*
server_addr
=
linphone_address_get_domain
(
from
);
/*extract domain address from identity*/
linphone_proxy_config_set_server_addr
(
proxy_cfg
,
server_addr
);
/* we assume domain = proxy server address*/
linphone_proxy_config_enable_register
(
proxy_cfg
,
TRUE
);
/*activate registration for this proxy config*/
linphone_address_destroy
(
from
);
/*release resource*/
linphone_core_add_proxy_config
(
lc
,
proxy_cfg
);
/*add proxy config to linphone core*/
linphone_core_set_default_proxy
(
lc
,
proxy_cfg
);
/*set to default proxy*/
if
(
password
!=
NULL
){
info
=
linphone_auth_info_new
(
linphone_address_get_username
(
from
),
NULL
,
password
,
NULL
,
NULL
,
NULL
);
/*create authentication structure from identity*/
linphone_core_add_auth_info
(
lc
,
info
);
/*add authentication info to LinphoneCore*/
}
// configure proxy entries
linphone_proxy_config_set_identity
(
proxy_cfg
,
identity
);
/*set identity with user name and domain*/
server_addr
=
linphone_address_get_domain
(
from
);
/*extract domain address from identity*/
linphone_proxy_config_set_server_addr
(
proxy_cfg
,
server_addr
);
/* we assume domain = proxy server address*/
linphone_proxy_config_enable_register
(
proxy_cfg
,
TRUE
);
/*activate registration for this proxy config*/
linphone_address_destroy
(
from
);
/*release resource*/
linphone_core_add_proxy_config
(
lc
,
proxy_cfg
);
/*add proxy config to linphone core*/
linphone_core_set_default_proxy
(
lc
,
proxy_cfg
);
/*set to default proxy*/
/* main loop for receiving notifications and doing background linphonecore work: */
...
...
coreapi/lpc2xml.c
View file @
717db9fd
...
...
@@ -29,7 +29,7 @@ struct _lpc2xml_context {
const
LpConfig
*
lpc
;
lpc2xml_function
cbf
;
void
*
ctx
;
xmlDoc
*
doc
;
char
errorBuffer
[
LPC2XML_BZ
];
char
warningBuffer
[
LPC2XML_BZ
];
...
...
@@ -42,7 +42,7 @@ lpc2xml_context* lpc2xml_context_new(lpc2xml_function cbf, void *ctx) {
xmlCtx
->
lpc
=
NULL
;
xmlCtx
->
cbf
=
cbf
;
xmlCtx
->
ctx
=
ctx
;
xmlCtx
->
doc
=
NULL
;
xmlCtx
->
errorBuffer
[
0
]
=
'\0'
;
xmlCtx
->
warningBuffer
[
0
]
=
'\0'
;
...
...
@@ -64,8 +64,8 @@ static void lpc2xml_context_clear_logs(lpc2xml_context *ctx) {
}
static
void
lpc2xml_log
(
lpc2xml_context
*
xmlCtx
,
int
level
,
const
char
*
fmt
,
...)
{
va_list
args
;
va_start
(
args
,
fmt
);
va_list
args
;
va_start
(
args
,
fmt
);
if
(
xmlCtx
->
cbf
!=
NULL
)
{
xmlCtx
->
cbf
((
xmlCtx
)
->
ctx
,
level
,
fmt
,
args
);
}
...
...
@@ -75,8 +75,8 @@ static void lpc2xml_log(lpc2xml_context *xmlCtx, int level, const char *fmt, ...
static
void
lpc2xml_genericxml_error
(
void
*
ctx
,
const
char
*
fmt
,
...)
{
lpc2xml_context
*
xmlCtx
=
(
lpc2xml_context
*
)
ctx
;
int
sl
=
strlen
(
xmlCtx
->
errorBuffer
);
va_list
args
;
va_start
(
args
,
fmt
);
va_list
args
;
va_start
(
args
,
fmt
);
vsnprintf
(
xmlCtx
->
errorBuffer
+
sl
,
LPC2XML_BZ
-
sl
,
fmt
,
args
);
va_end
(
args
);
}
...
...
@@ -85,8 +85,8 @@ static void lpc2xml_genericxml_error(void *ctx, const char *fmt, ...) {
static void lpc2xml_genericxml_warning(void *ctx, const char *fmt, ...) {
lpc2xml_context *xmlCtx = (lpc2xml_context *)ctx;
int sl = strlen(xmlCtx->warningBuffer);
va_list args;
va_start(args, fmt);
va_list args;
va_start(args, fmt);
vsnprintf(xmlCtx->warningBuffer + sl, LPC2XML_BZ-sl, fmt, args);
va_end(args);
}
...
...
@@ -114,25 +114,27 @@ struct __processSectionCtx {
static
void
processSection_cb
(
const
char
*
entry
,
struct
__processSectionCtx
*
ctx
)
{
if
(
ctx
->
ret
==
0
)
{
const
char
*
comment
=
"#"
;
xmlNode
*
node
;
xmlAttr
*
name_attr
;
if
(
strncmp
(
comment
,
entry
,
strlen
(
comment
))
==
0
)
{
lpc2xml_log
(
ctx
->
ctx
,
LPC2XML_WARNING
,
"Skipped commented entry %s"
,
entry
);
ctx
->
ret
=
0
;
return
;
}
xmlNode
*
node
=
xmlNewChild
(
ctx
->
node
,
NULL
,
(
const
xmlChar
*
)
"entry"
,
NULL
);
node
=
xmlNewChild
(
ctx
->
node
,
NULL
,
(
const
xmlChar
*
)
"entry"
,
NULL
);
if
(
node
==
NULL
)
{
lpc2xml_log
(
ctx
->
ctx
,
LPC2XML_ERROR
,
"Can't create
\"
entry
\"
element"
);
ctx
->
ret
=
-
1
;
return
;
}
xmlAttr
*
name_attr
=
xmlSetProp
(
node
,
(
const
xmlChar
*
)
"name"
,
(
const
xmlChar
*
)
entry
);
name_attr
=
xmlSetProp
(
node
,
(
const
xmlChar
*
)
"name"
,
(
const
xmlChar
*
)
entry
);
if
(
name_attr
==
NULL
)
{
lpc2xml_log
(
ctx
->
ctx
,
LPC2XML_ERROR
,
"Can't create name attribute for
\"
entry
\"
element"
);
ctx
->
ret
=
-
1
;
return
;
}
ctx
->
ret
=
processEntry
(
ctx
->
section
,
entry
,
node
,
ctx
->
ctx
);
}
}
...
...
@@ -154,12 +156,13 @@ struct __processConfigCtx {
static
void
processConfig_cb
(
const
char
*
section
,
struct
__processConfigCtx
*
ctx
)
{
if
(
ctx
->
ret
==
0
)
{
xmlNode
*
node
=
xmlNewChild
(
ctx
->
node
,
NULL
,
(
const
xmlChar
*
)
"section"
,
NULL
);
xmlAttr
*
name_attr
;
if
(
node
==
NULL
)
{
lpc2xml_log
(
ctx
->
ctx
,
LPC2XML_ERROR
,
"Can't create
\"
section
\"
element"
);
ctx
->
ret
=
-
1
;
return
;
}
xmlAttr
*
name_attr
=
xmlSetProp
(
node
,
(
const
xmlChar
*
)
"name"
,
(
const
xmlChar
*
)
section
);
name_attr
=
xmlSetProp
(
node
,
(
const
xmlChar
*
)
"name"
,
(
const
xmlChar
*
)
section
);
if
(
name_attr
==
NULL
)
{
lpc2xml_log
(
ctx
->
ctx
,
LPC2XML_ERROR
,
"Can't create name attribute for
\"
section
\"
element"
);
ctx
->
ret
=
-
1
;
...
...
@@ -177,22 +180,25 @@ static int processConfig(xmlNode *node, lpc2xml_context *ctx) {
static
int
processDoc
(
xmlDoc
*
doc
,
lpc2xml_context
*
ctx
)
{
int
ret
=
0
;
xmlNs
*
xsi_ns
;
xmlNs
*
lpc_ns
;
xmlAttr
*
schemaLocation
;
xmlNode
*
root_node
=
xmlNewNode
(
NULL
,
(
const
xmlChar
*
)
"config"
);
if
(
root_node
==
NULL
)
{
lpc2xml_log
(
ctx
,
LPC2XML_ERROR
,
"Can't create
\"
config
\"
element"
);
return
-
1
;
}
xmlNs
*
lpc_ns
=
xmlNewNs
(
root_node
,
(
const
xmlChar
*
)
"http://www.linphone.org/xsds/lpconfig.xsd"
,
NULL
);
lpc_ns
=
xmlNewNs
(
root_node
,
(
const
xmlChar
*
)
"http://www.linphone.org/xsds/lpconfig.xsd"
,
NULL
);
if
(
lpc_ns
==
NULL
)
{
lpc2xml_log
(
ctx
,
LPC2XML_WARNING
,
"Can't create lpc namespace"
);
}
else
{
xmlSetNs
(
root_node
,
lpc_ns
);
}
xmlNs
*
xsi_ns
=
xmlNewNs
(
root_node
,
(
const
xmlChar
*
)
"http://www.w3.org/2001/XMLSchema-instance"
,
(
const
xmlChar
*
)
"xsi"
);
xsi_ns
=
xmlNewNs
(
root_node
,
(
const
xmlChar
*
)
"http://www.w3.org/2001/XMLSchema-instance"
,
(
const
xmlChar
*
)
"xsi"
);
if
(
lpc_ns
==
NULL
)
{
lpc2xml_log
(
ctx
,
LPC2XML_WARNING
,
"Can't create xsi namespace"
);
}
xmlAttr
*
schemaLocation
=
xmlNewNsProp
(
root_node
,
xsi_ns
,
(
const
xmlChar
*
)
"schemaLocation"
,
(
const
xmlChar
*
)
"http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd"
);
schemaLocation
=
xmlNewNsProp
(
root_node
,
xsi_ns
,
(
const
xmlChar
*
)
"schemaLocation"
,
(
const
xmlChar
*
)
"http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd"
);
if
(
schemaLocation
==
NULL
)
{
lpc2xml_log
(
ctx
,
LPC2XML_WARNING
,
"Can't create schemaLocation"
);
}
...
...
@@ -203,12 +209,13 @@ static int processDoc(xmlDoc *doc, lpc2xml_context *ctx) {
static
int
internal_convert_lpc2xml
(
lpc2xml_context
*
ctx
)
{
int
ret
=
0
;
xmlDoc
*
doc
;
lpc2xml_log
(
ctx
,
LPC2XML_DEBUG
,
"Generation started"
);
if
(
ctx
->
doc
!=
NULL
)
{
xmlFreeDoc
(
ctx
->
doc
);
ctx
->
doc
=
NULL
;
}
xmlDoc
*
doc
=
xmlNewDoc
((
const
xmlChar
*
)
"1.0"
);
doc
=
xmlNewDoc
((
const
xmlChar
*
)
"1.0"
);
ret
=
processDoc
(
doc
,
ctx
);
if
(
ret
==
0
)
{
ctx
->
doc
=
doc
;
...
...
@@ -226,9 +233,10 @@ int lpc2xml_set_lpc(lpc2xml_context* context, const LpConfig *lpc) {
int
lpc2xml_convert_file
(
lpc2xml_context
*
context
,
const
char
*
filename
)
{
int
ret
=
-
1
;
xmlSaveCtxtPtr
save_ctx
;
lpc2xml_context_clear_logs
(
context
);
xmlSetGenericErrorFunc
(
context
,
lpc2xml_genericxml_error
);
xmlSaveCtxtPtr
save_ctx
=
xmlSaveToFilename
(
filename
,
"UTF-8"
,
XML_SAVE_FORMAT
);
save_ctx
=
xmlSaveToFilename
(
filename
,
"UTF-8"
,
XML_SAVE_FORMAT
);