Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linphone
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
7
Issues
7
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
linphone
Commits
26fac3e0
Commit
26fac3e0
authored
Jun 05, 2015
by
Ghislain MARY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework assistant for asynchronous XML-RPC requests.
parent
01be7132
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
844 additions
and
953 deletions
+844
-953
CMakeLists.txt
CMakeLists.txt
+0
-4
config.h
build/android/config.h
+0
-3
config.h.cmake
config.h.cmake
+0
-1
configure.ac
configure.ac
+0
-26
CMakeLists.txt
coreapi/CMakeLists.txt
+2
-3
Makefile.am
coreapi/Makefile.am
+5
-9
account_creator.c
coreapi/account_creator.c
+209
-0
account_creator.h
coreapi/account_creator.h
+78
-0
linphonecore.h
coreapi/linphonecore.h
+2
-26
private.h
coreapi/private.h
+2
-6
proxy.c
coreapi/proxy.c
+0
-92
sipsetup.c
coreapi/sipsetup.c
+0
-6
sipwizard.c
coreapi/sipwizard.c
+0
-189
xmlrpc.c
coreapi/xmlrpc.c
+52
-65
xmlrpc.h
coreapi/xmlrpc.h
+16
-9
CMakeLists.txt
gtk/CMakeLists.txt
+1
-4
Makefile.am
gtk/Makefile.am
+1
-5
main.c
gtk/main.c
+0
-4
main.ui
gtk/main.ui
+1
-0
password.ui
gtk/password.ui
+0
-1
propertybox.c
gtk/propertybox.c
+0
-5
setupwizard.c
gtk/setupwizard.c
+475
-495
No files found.
CMakeLists.txt
View file @
26fac3e0
...
...
@@ -51,7 +51,6 @@ option(ENABLE_TUTORIALS "Enable compilation of tutorials." YES)
option
(
ENABLE_UNIT_TESTS
"Enable compilation of unit tests."
YES
)
option
(
ENABLE_UPNP
"Build with uPnP support."
YES
)
option
(
ENABLE_VIDEO
"Build with video support."
YES
)
cmake_dependent_option
(
ENABLE_ASSISTANT
"Turn on assistant compiling."
YES
"ENABLE_GTK_UI"
NO
)
list
(
APPEND CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
...
...
@@ -120,9 +119,6 @@ if(ENABLE_NOTIFY)
set
(
ENABLE_NOTIFY OFF CACHE BOOL
"Enable libnotify support."
FORCE
)
endif
()
endif
()
if
(
ENABLE_ASSISTANT
)
set
(
BUILD_WIZARD 1
)
endif
()
find_package
(
Gettext
)
...
...
build/android/config.h
View file @
26fac3e0
...
...
@@ -7,9 +7,6 @@
/* Define if tools enabled */
/* #undef BUILD_TOOLS */
/* Define if wizard enabled */
/* #undef BUILD_WIZARD */
/* Tells whether localisation is possible */
/* #undef ENABLE_NLS */
...
...
config.h.cmake
View file @
26fac3e0
...
...
@@ -37,7 +37,6 @@
#define PACKAGE_DATA_DIR "${PACKAGE_DATA_DIR}"
#define PACKAGE_SOUND_DIR "${PACKAGE_SOUND_DIR}"
#cmakedefine BUILD_WIZARD
#cmakedefine HAVE_NOTIFY4
#cmakedefine HAVE_ZLIB 1
#cmakedefine HAVE_CU_GET_SUITE 1
...
...
configure.ac
View file @
26fac3e0
...
...
@@ -729,31 +729,6 @@ if test "$has_sighandler_t" = "yes" ; then
AC_DEFINE( HAVE_SIGHANDLER_T, 1, [Define if sighandler_t available] )
fi
AC_ARG_ENABLE(assistant,
[AS_HELP_STRING([--enable-assistant], [Turn on assistant compiling])],
[case "${enableval}" in
yes) build_wizard=true ;;
no) build_wizard=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-assistant) ;;
esac],
[build_wizard=check]
)
if test "$build_wizard" != "false" ; then
PKG_CHECK_MODULES(LIBGTKWIZARD, [gtk+-2.0 >= 2.22.0],[],
[if test "$build_wizard" = "true" ; then
AC_MSG_ERROR([gtk+-2.0 < 2.22.0, assistant cannot be compiled.])
else
build_wizard=false
fi]
)
fi
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] )
fi
AC_CHECK_HEADERS(libudev.h)
AC_CHECK_LIB(udev,udev_new)
...
...
@@ -1062,7 +1037,6 @@ echo "Linphone build configuration ended."
echo "Summary of build options:"
printf "* %-30s %s\n" "Video support" $video
printf "* %-30s %s\n" "GTK interface" $gtk_ui
printf "* %-30s %s\n" "Account assistant" $build_wizard
printf "* %-30s %s\n" "Console interface" $console_ui
printf "* %-30s %s\n" "Tools" $build_tools
printf "* %-30s %s\n" "Message storage" $enable_msg_storage
...
...
coreapi/CMakeLists.txt
View file @
26fac3e0
...
...
@@ -31,6 +31,8 @@ endif()
set
(
SOURCE_FILES
account_creator.c
account_creator.h
address.c
authentication.c
bellesip_sal/sal_address_impl.c
...
...
@@ -105,9 +107,6 @@ if(ENABLE_TUNNEL)
else
()
list
(
APPEND SOURCE_FILES linphone_tunnel_stubs.c
)
endif
()
if
(
ENABLE_ASSISTANT
)
list
(
APPEND SOURCE_FILES sipwizard.c
)
endif
()
set
(
GENERATED_SOURCE_FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/liblinphone_gitversion.h
...
...
coreapi/Makefile.am
View file @
26fac3e0
...
...
@@ -25,6 +25,7 @@ CLEANFILES=$(GITVERSION_FILE)
linphone_includedir
=
$(includedir)
/linphone
linphone_include_HEADERS
=
\
account_creator.h
\
buffer.h
\
call_log.h
\
call_params.h
\
...
...
@@ -38,11 +39,13 @@ linphone_include_HEADERS=\
lpc2xml.h
\
lpconfig.h
\
sipsetup.h
\
xml2lpc.h
xml2lpc.h
\
xmlrpc.h
lib_LTLIBRARIES
=
liblinphone.la
liblinphone_la_SOURCES
=
\
account_creator.c
\
address.c
\
authentication.c
\
buffer.c
\
...
...
@@ -82,6 +85,7 @@ liblinphone_la_SOURCES=\
sipsetup.c sipsetup.h
\
xml2lpc.c
\
xml.c
\
xmlrpc.c
\
vtables.c
\
$(GITVERSION_FILE)
...
...
@@ -102,10 +106,6 @@ liblinphone_la_SOURCES+= bellesip_sal/sal_address_impl.c \
bellesip_sal/sal_op_info.c
\
bellesip_sal/sal_op_events.c
if
BUILD_WIZARD
liblinphone_la_SOURCES
+=
sipwizard.c
endif
liblinphone_la_SOURCES
+=
linphone_tunnel_config.c
if
BUILD_TUNNEL
liblinphone_la_SOURCES
+=
linphone_tunnel.cc TunnelManager.cc TunnelManager.hh linphone_tunnel.h
...
...
@@ -181,10 +181,6 @@ COMMON_CFLAGS=\
$(SASL_CFLAGS)
\
$(ZLIB_CFLAGS)
if
BUILD_WIZARD
COMMON_CFLAGS
+=
-DBUILD_WIZARD
endif
COMMON_CFLAGS
+=
-DUSE_BELLESIP
AM_CFLAGS
=
$(COMMON_CFLAGS)
$(STRICT_OPTIONS_CC)
...
...
coreapi/account_creator.c
0 → 100644
View file @
26fac3e0
/*
linphone
Copyright (C) 2010-2015 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
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "linphonecore.h"
#include "private.h"
struct
_LinphoneAccountCreator
{
LinphoneXmlRpcSession
*
xmlrpc_session
;
LinphoneAccountCreatorCb
existence_test_cb
;
LinphoneAccountCreatorCb
validation_test_cb
;
LinphoneAccountCreatorCb
validate_cb
;
void
*
existence_test_cb_ud
;
void
*
validation_test_cb_ud
;
void
*
validate_cb_ud
;
char
*
xmlrpc_url
;
char
*
username
;
char
*
password
;
char
*
domain
;
char
*
route
;
char
*
email
;
int
subscribe
;
};
LinphoneAccountCreator
*
linphone_account_creator_new
(
LinphoneCore
*
core
,
const
char
*
xmlrpc_url
)
{
LinphoneAccountCreator
*
creator
;
creator
=
ms_new0
(
LinphoneAccountCreator
,
1
);
creator
->
xmlrpc_session
=
linphone_xml_rpc_session_new
(
core
,
xmlrpc_url
);
return
creator
;
}
void
linphone_account_creator_set_username
(
LinphoneAccountCreator
*
creator
,
const
char
*
username
)
{
set_string
(
&
creator
->
username
,
username
);
}
const
char
*
linphone_account_creator_get_username
(
const
LinphoneAccountCreator
*
creator
)
{
return
creator
->
username
;
}
void
linphone_account_creator_set_password
(
LinphoneAccountCreator
*
creator
,
const
char
*
password
){
set_string
(
&
creator
->
password
,
password
);
}
const
char
*
linphone_account_creator_get_password
(
const
LinphoneAccountCreator
*
creator
)
{
return
creator
->
password
;
}
void
linphone_account_creator_set_domain
(
LinphoneAccountCreator
*
creator
,
const
char
*
domain
){
set_string
(
&
creator
->
domain
,
domain
);
}
const
char
*
linphone_account_creator_get_domain
(
const
LinphoneAccountCreator
*
creator
)
{
return
creator
->
domain
;
}
void
linphone_account_creator_set_route
(
LinphoneAccountCreator
*
creator
,
const
char
*
route
)
{
set_string
(
&
creator
->
route
,
route
);
}
const
char
*
linphone_account_creator_get_route
(
const
LinphoneAccountCreator
*
creator
)
{
return
creator
->
route
;
}
void
linphone_account_creator_set_email
(
LinphoneAccountCreator
*
creator
,
const
char
*
email
)
{
set_string
(
&
creator
->
email
,
email
);
}
const
char
*
linphone_account_creator_get_email
(
const
LinphoneAccountCreator
*
creator
)
{
return
creator
->
email
;
}
void
linphone_account_creator_set_subscribe
(
LinphoneAccountCreator
*
creator
,
int
subscribe
)
{
creator
->
subscribe
=
subscribe
;
}
int
linphone_account_creator_get_subscribe
(
const
LinphoneAccountCreator
*
creator
)
{
return
creator
->
subscribe
;
}
void
linphone_account_creator_set_test_existence_cb
(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorCb
cb
,
void
*
user_data
)
{
creator
->
existence_test_cb
=
cb
;
creator
->
existence_test_cb_ud
=
user_data
;
}
void
linphone_account_creator_set_test_validation_cb
(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorCb
cb
,
void
*
user_data
)
{
creator
->
validation_test_cb
=
cb
;
creator
->
validation_test_cb_ud
=
user_data
;
}
void
linphone_account_creator_set_validate_cb
(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorCb
cb
,
void
*
user_data
)
{
creator
->
validate_cb
=
cb
;
creator
->
validate_cb_ud
=
user_data
;
}
static
void
_test_existence_cb
(
LinphoneXmlRpcRequest
*
request
,
void
*
user_data
)
{
LinphoneAccountCreator
*
creator
=
(
LinphoneAccountCreator
*
)
user_data
;
if
(
creator
->
existence_test_cb
!=
NULL
)
{
LinphoneAccountCreatorStatus
status
=
LinphoneAccountCreatorFailed
;
if
((
linphone_xml_rpc_request_get_status
(
request
)
==
LinphoneXmlRpcStatusOk
)
&&
(
linphone_xml_rpc_request_get_int_response
(
request
)
==
0
))
{
status
=
LinphoneAccountCreatorOk
;
}
creator
->
existence_test_cb
(
creator
,
status
,
creator
->
existence_test_cb_ud
);
}
}
LinphoneAccountCreatorStatus
linphone_account_creator_test_existence
(
LinphoneAccountCreator
*
creator
)
{
LinphoneXmlRpcRequest
*
request
;
char
*
identity
;
if
(
!
creator
->
username
||
!
creator
->
domain
)
return
LinphoneAccountCreatorFailed
;
identity
=
ms_strdup_printf
(
"%s@%s"
,
creator
->
username
,
creator
->
domain
);
request
=
linphone_xml_rpc_request_new_with_args
(
"check_account"
,
LinphoneXmlRpcArgInt
,
_test_existence_cb
,
creator
,
LinphoneXmlRpcArgString
,
identity
,
LinphoneXmlRpcArgNone
);
linphone_xml_rpc_session_send_request
(
creator
->
xmlrpc_session
,
request
);
linphone_xml_rpc_request_unref
(
request
);
ms_free
(
identity
);
return
LinphoneAccountCreatorOk
;
}
static
void
_test_validation_cb
(
LinphoneXmlRpcRequest
*
request
,
void
*
user_data
)
{
LinphoneAccountCreator
*
creator
=
(
LinphoneAccountCreator
*
)
user_data
;
if
(
creator
->
validation_test_cb
!=
NULL
)
{
LinphoneAccountCreatorStatus
status
=
LinphoneAccountCreatorFailed
;
if
((
linphone_xml_rpc_request_get_status
(
request
)
==
LinphoneXmlRpcStatusOk
)
&&
(
linphone_xml_rpc_request_get_int_response
(
request
)
==
1
))
{
status
=
LinphoneAccountCreatorOk
;
}
creator
->
validation_test_cb
(
creator
,
status
,
creator
->
validation_test_cb_ud
);
}
}
LinphoneAccountCreatorStatus
linphone_account_creator_test_validation
(
LinphoneAccountCreator
*
creator
)
{
LinphoneXmlRpcRequest
*
request
;
char
*
identity
;
if
(
!
creator
->
username
||
!
creator
->
domain
)
return
LinphoneAccountCreatorFailed
;
identity
=
ms_strdup_printf
(
"%s@%s"
,
creator
->
username
,
creator
->
domain
);
request
=
linphone_xml_rpc_request_new_with_args
(
"check_account_validated"
,
LinphoneXmlRpcArgInt
,
_test_validation_cb
,
creator
,
LinphoneXmlRpcArgString
,
identity
,
LinphoneXmlRpcArgNone
);
linphone_xml_rpc_session_send_request
(
creator
->
xmlrpc_session
,
request
);
linphone_xml_rpc_request_unref
(
request
);
ms_free
(
identity
);
return
LinphoneAccountCreatorOk
;
}
static
void
_validate_cb
(
LinphoneXmlRpcRequest
*
request
,
void
*
user_data
)
{
LinphoneAccountCreator
*
creator
=
(
LinphoneAccountCreator
*
)
user_data
;
if
(
creator
->
validate_cb
!=
NULL
)
{
LinphoneAccountCreatorStatus
status
=
LinphoneAccountCreatorFailed
;
if
((
linphone_xml_rpc_request_get_status
(
request
)
==
LinphoneXmlRpcStatusOk
)
&&
(
linphone_xml_rpc_request_get_int_response
(
request
)
==
0
))
{
status
=
LinphoneAccountCreatorOk
;
}
creator
->
validate_cb
(
creator
,
status
,
creator
->
validate_cb_ud
);
}
}
LinphoneAccountCreatorStatus
linphone_account_creator_validate
(
LinphoneAccountCreator
*
creator
)
{
LinphoneXmlRpcRequest
*
request
;
char
*
identity
;
if
(
!
creator
->
username
||
!
creator
->
domain
)
return
LinphoneAccountCreatorFailed
;
identity
=
ms_strdup_printf
(
"%s@%s"
,
creator
->
username
,
creator
->
domain
);
request
=
linphone_xml_rpc_request_new_with_args
(
"create_account"
,
LinphoneXmlRpcArgInt
,
_validate_cb
,
creator
,
LinphoneXmlRpcArgString
,
identity
,
LinphoneXmlRpcArgString
,
creator
->
password
,
LinphoneXmlRpcArgString
,
creator
->
email
,
LinphoneXmlRpcArgInt
,
creator
->
subscribe
,
LinphoneXmlRpcArgNone
);
linphone_xml_rpc_session_send_request
(
creator
->
xmlrpc_session
,
request
);
linphone_xml_rpc_request_unref
(
request
);
ms_free
(
identity
);
return
LinphoneAccountCreatorOk
;
}
void
linphone_account_creator_destroy
(
LinphoneAccountCreator
*
creator
){
linphone_xml_rpc_session_unref
(
creator
->
xmlrpc_session
);
if
(
creator
->
username
)
ms_free
(
creator
->
username
);
if
(
creator
->
password
)
ms_free
(
creator
->
password
);
if
(
creator
->
domain
)
ms_free
(
creator
->
domain
);
if
(
creator
->
route
)
ms_free
(
creator
->
route
);
if
(
creator
->
email
)
ms_free
(
creator
->
email
);
ms_free
(
creator
);
}
coreapi/account_creator.h
0 → 100644
View file @
26fac3e0
/*
account_creator.h
Copyright (C) 2010-2015 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
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef LINPHONE_ACCOUNT_CREATOR_H_
#define LINPHONE_ACCOUNT_CREATOR_H_
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* @addtogroup misc
* @{
*/
enum
_LinphoneAccountCreatorStatus
{
LinphoneAccountCreatorOk
,
LinphoneAccountCreatorFailed
};
typedef
enum
_LinphoneAccountCreatorStatus
LinphoneAccountCreatorStatus
;
typedef
struct
_LinphoneAccountCreator
LinphoneAccountCreator
;
typedef
void
(
*
LinphoneAccountCreatorCb
)(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorStatus
status
,
void
*
user_data
);
LINPHONE_PUBLIC
LinphoneAccountCreator
*
linphone_account_creator_new
(
LinphoneCore
*
core
,
const
char
*
xmlrpc_url
);
LINPHONE_PUBLIC
void
linphone_account_creator_destroy
(
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_username
(
LinphoneAccountCreator
*
creator
,
const
char
*
username
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_username
(
const
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_password
(
LinphoneAccountCreator
*
creator
,
const
char
*
password
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_password
(
const
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_domain
(
LinphoneAccountCreator
*
creator
,
const
char
*
domain
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_domain
(
const
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_route
(
LinphoneAccountCreator
*
creator
,
const
char
*
route
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_route
(
const
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_email
(
LinphoneAccountCreator
*
creator
,
const
char
*
email
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_email
(
const
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_subscribe
(
LinphoneAccountCreator
*
creator
,
int
suscribre
);
LINPHONE_PUBLIC
int
linphone_account_creator_get_subscribe
(
const
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_test_existence_cb
(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorCb
cb
,
void
*
user_data
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_test_validation_cb
(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorCb
cb
,
void
*
user_data
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_validate_cb
(
LinphoneAccountCreator
*
creator
,
LinphoneAccountCreatorCb
cb
,
void
*
user_data
);
LINPHONE_PUBLIC
LinphoneAccountCreatorStatus
linphone_account_creator_test_existence
(
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
LinphoneAccountCreatorStatus
linphone_account_creator_test_validation
(
LinphoneAccountCreator
*
creator
);
LINPHONE_PUBLIC
LinphoneAccountCreatorStatus
linphone_account_creator_validate
(
LinphoneAccountCreator
*
creator
);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
/* LINPHONE_ACCOUNT_CREATOR_H_ */
coreapi/linphonecore.h
View file @
26fac3e0
...
...
@@ -367,6 +367,7 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy);
#ifdef IN_LINPHONE
#include "account_creator.h"
#include "buffer.h"
#include "call_log.h"
#include "call_params.h"
...
...
@@ -375,6 +376,7 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy);
#include "linphonefriend.h"
#include "xmlrpc.h"
#else
#include "linphone/account_creator.h"
#include "linphone/buffer.h"
#include "linphone/call_log.h"
#include "linphone/call_params.h"
...
...
@@ -1179,32 +1181,6 @@ LINPHONE_PUBLIC void linphone_proxy_config_set_custom_header(LinphoneProxyConfig
* @}
**/
typedef
struct
_LinphoneAccountCreator
{
LinphoneCore
*
lc
;
struct
_SipSetupContext
*
ssctx
;
char
*
username
;
char
*
password
;
char
*
domain
;
char
*
route
;
char
*
email
;
int
suscribe
;
bool_t
succeeded
;
}
LinphoneAccountCreator
;
LINPHONE_PUBLIC
LinphoneAccountCreator
*
linphone_account_creator_new
(
LinphoneCore
*
core
,
const
char
*
type
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_username
(
LinphoneAccountCreator
*
obj
,
const
char
*
username
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_password
(
LinphoneAccountCreator
*
obj
,
const
char
*
password
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_domain
(
LinphoneAccountCreator
*
obj
,
const
char
*
domain
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_route
(
LinphoneAccountCreator
*
obj
,
const
char
*
route
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_email
(
LinphoneAccountCreator
*
obj
,
const
char
*
email
);
LINPHONE_PUBLIC
void
linphone_account_creator_set_suscribe
(
LinphoneAccountCreator
*
obj
,
int
suscribre
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_username
(
LinphoneAccountCreator
*
obj
);
LINPHONE_PUBLIC
const
char
*
linphone_account_creator_get_domain
(
LinphoneAccountCreator
*
obj
);
LINPHONE_PUBLIC
int
linphone_account_creator_test_existence
(
LinphoneAccountCreator
*
obj
);
LINPHONE_PUBLIC
int
linphone_account_creator_test_validation
(
LinphoneAccountCreator
*
obj
);
LINPHONE_PUBLIC
LinphoneProxyConfig
*
linphone_account_creator_validate
(
LinphoneAccountCreator
*
obj
);
LINPHONE_PUBLIC
void
linphone_account_creator_destroy
(
LinphoneAccountCreator
*
obj
);
struct
_LinphoneAuthInfo
;
/**
...
...
coreapi/private.h
View file @
26fac3e0
...
...
@@ -997,6 +997,8 @@ struct _LinphoneXmlRpcRequest {
belle_sip_list_t
*
arg_list
;
char
*
content
;
/**< The string representation of the XML-RPC request */
char
*
method
;
LinphoneXmlRpcResponseCb
cb
;
void
*
cb_ud
;
LinphoneXmlRpcStatus
status
;
LinphoneXmlRpcArg
response
;
};
...
...
@@ -1006,14 +1008,8 @@ BELLE_SIP_DECLARE_VPTR(LinphoneXmlRpcRequest);
struct
_LinphoneXmlRpcSession
{
belle_sip_object_t
base
;
void
*
user_data
;
belle_sip_list_t
*
arg_list
;
LinphoneCore
*
core
;
LinphoneXmlRpcRequest
*
request
;
LinphoneContent
*
content
;
char
*
url
;
ms_cond_t
cond
;
ms_mutex_t
cond_mutex
;
ms_mutex_t
mutex
;
};
BELLE_SIP_DECLARE_VPTR
(
LinphoneXmlRpcSession
);
...
...
coreapi/proxy.c
View file @
26fac3e0
...
...
@@ -1494,98 +1494,6 @@ SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig
* @}
**/
LinphoneAccountCreator
*
linphone_account_creator_new
(
struct
_LinphoneCore
*
core
,
const
char
*
type
){
LinphoneAccountCreator
*
obj
;
LinphoneProxyConfig
*
cfg
;
SipSetup
*
ss
=
sip_setup_lookup
(
type
);
SipSetupContext
*
ssctx
;
if
(
!
ss
){
return
NULL
;
}
if
(
!
(
sip_setup_get_capabilities
(
ss
)
&
SIP_SETUP_CAP_ACCOUNT_MANAGER
)){
ms_error
(
"%s cannot manage accounts."
,
type
);
return
NULL
;
}
obj
=
ms_new0
(
LinphoneAccountCreator
,
1
);
cfg
=
linphone_core_create_proxy_config
(
core
);
ssctx
=
sip_setup_context_new
(
ss
,
cfg
);
obj
->
lc
=
core
;
obj
->
ssctx
=
ssctx
;
set_string
(
&
obj
->
domain
,
sip_setup_context_get_domains
(
ssctx
)[
0
]);
cfg
->
lc
=
core
;
return
obj
;
}
void
linphone_account_creator_set_username
(
LinphoneAccountCreator
*
obj
,
const
char
*
username
){
set_string
(
&
obj
->
username
,
username
);
}
void
linphone_account_creator_set_password
(
LinphoneAccountCreator
*
obj
,
const
char
*
password
){
set_string
(
&
obj
->
password
,
password
);
}
void
linphone_account_creator_set_domain
(
LinphoneAccountCreator
*
obj
,
const
char
*
domain
){
set_string
(
&
obj
->
domain
,
domain
);
}
void
linphone_account_creator_set_route
(
LinphoneAccountCreator
*
obj
,
const
char
*
route
)
{
set_string
(
&
obj
->
route
,
route
);
}
void
linphone_account_creator_set_email
(
LinphoneAccountCreator
*
obj
,
const
char
*
email
)
{
set_string
(
&
obj
->
email
,
email
);
}
void
linphone_account_creator_set_suscribe
(
LinphoneAccountCreator
*
obj
,
int
suscribe
)
{
obj
->
suscribe
=
suscribe
;
}
const
char
*
linphone_account_creator_get_username
(
LinphoneAccountCreator
*
obj
){
return
obj
->
username
;
}
const
char
*
linphone_account_creator_get_domain
(
LinphoneAccountCreator
*
obj
){
return
obj
->
domain
;
}
int
linphone_account_creator_test_existence
(
LinphoneAccountCreator
*
obj
){
SipSetupContext
*
ssctx
=
obj
->
ssctx
;
char
*
uri
=
ms_strdup_printf
(
"%s@%s"
,
obj
->
username
,
obj
->
domain
);
int
err
=
sip_setup_context_account_exists
(
ssctx
,
uri
);
ms_free
(
uri
);
return
err
;
}
int
linphone_account_creator_test_validation
(
LinphoneAccountCreator
*
obj
)
{
SipSetupContext
*
ssctx
=
obj
->
ssctx
;
int
err
=
sip_setup_context_account_validated
(
ssctx
,
obj
->
username
);
return
err
;
}
LinphoneProxyConfig
*
linphone_account_creator_validate
(
LinphoneAccountCreator
*
obj
){
SipSetupContext
*
ssctx
=
obj
->
ssctx
;
char
*
uri
=
ms_strdup_printf
(
"%s@%s"
,
obj
->
username
,
obj
->
domain
);
int
err
=
sip_setup_context_create_account
(
ssctx
,
uri
,
obj
->
password
,
obj
->
email
,
obj
->
suscribe
);
ms_free
(
uri
);
if
(
err
==
0
)
{
obj
->
succeeded
=
TRUE
;
return
sip_setup_context_get_proxy_config
(
ssctx
);
}
return
NULL
;
}
void
linphone_account_creator_destroy
(
LinphoneAccountCreator
*
obj
){
if
(
obj
->
username
)
ms_free
(
obj
->
username
);
if
(
obj
->
password
)
ms_free
(
obj
->
password
);
if
(
obj
->
domain
)
ms_free
(
obj
->
domain
);
if
(
!
obj
->
succeeded
){
linphone_proxy_config_destroy
(
sip_setup_context_get_proxy_config
(
obj
->
ssctx
));
}
}
void
linphone_proxy_config_set_user_data
(
LinphoneProxyConfig
*
cfg
,
void
*
ud
)
{
cfg
->
user_data
=
ud
;
}
...
...
coreapi/sipsetup.c
View file @
26fac3e0
...
...
@@ -24,14 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore.h"
extern
SipSetup
linphone_sip_login
;
#ifdef BUILD_WIZARD
extern
SipSetup
linphone_sip_wizard
;
#endif
static
SipSetup
*
all_sip_setups
[]
=
{
&
linphone_sip_login
,
#ifdef BUILD_WIZARD
&
linphone_sip_wizard
,
#endif
NULL
};
...
...
coreapi/sipwizard.c
deleted
100644 → 0
View file @
01be7132
/*
sipwizard.c
Copyright (C) 2011 Belledonne Communication, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "linphonecore.h"
#include "private.h"
#include <ctype.h>
static
const
char
*
XMLRPC_URL
=
"https://www.linphone.org/wizard.php"
;
static
void
sip_wizard_init_instance
(
SipSetupContext
*
ctx
){
LinphoneProxyConfig
*
cfg
=
sip_setup_context_get_proxy_config
(
ctx
);
/*disable registration until the user logs in*/
linphone_proxy_config_enable_register
(
cfg
,
FALSE
);
}
static
void
sip_wizard_uninit_instance
(
SipSetupContext
*
ctx
)
{
if
(
ctx
->
xmlrpc_session
!=
NULL
)
{
linphone_xml_rpc_session_unref
(
ctx
->
xmlrpc_session
);
ctx
->
xmlrpc_session
=
NULL
;
}
}
static
const
char
**
sip_wizard_get_domains
(
SipSetupContext
*
ctx
)
{
LinphoneProxyConfig
*
cfg
=
sip_setup_context_get_proxy_config
(
ctx
);
const
char
**
domains
=
(
const
char
**
)
&
cfg
->
reg_proxy
;
return
domains
;
}
static
int
do_simple_xmlrpc_request
(
SipSetupContext
*
ctx
,
LinphoneXmlRpcRequest
*
request
)
{
int
ret
=
-
1
;
if
(
!
request
)
{
ms_error
(
"Fail to create XML-RPC request!"
);
return
-
1
;
}
if
(
ctx
->
xmlrpc_session
==
NULL
)
{
ctx
->
xmlrpc_session
=
linphone_xml_rpc_session_new
(
ctx
->
cfg
->
lc
,
XMLRPC_URL
);
}
if
(
linphone_xml_rpc_session_send_request
(
ctx
->
xmlrpc_session
,
request
)
==
LinphoneXmlRpcStatusOk
)
{
ret
=
linphone_xml_rpc_request_get_int_response
(
request
);
}
linphone_xml_rpc_request_unref
(
request
);
return
ret
;
}
/*
* Return 1 if account already exists
* 0 if account doesn't exists
* -1 if information isn't available
*/
static
int
sip_wizard_account_exists
(
SipSetupContext
*
ctx
,
const
char
*
identity
)
{
LinphoneXmlRpcRequest
*
request
=
linphone_xml_rpc_request_new_with_args
(
"check_account"
,
LinphoneXmlRpcArgInt
,
LinphoneXmlRpcArgString
,
identity
,
LinphoneXmlRpcArgNone
);
return
do_simple_xmlrpc_request
(
ctx
,
request
);
}
static
int
sip_wizard_account_validated
(
SipSetupContext
*
ctx
,
const
char
*
identity
)
{
LinphoneXmlRpcRequest
*
request
=
linphone_xml_rpc_request_new_with_args
(
"check_account_validated"
,
LinphoneXmlRpcArgInt
,
LinphoneXmlRpcArgString
,
identity
,
LinphoneXmlRpcArgNone
);
return
do_simple_xmlrpc_request
(
ctx
,
request
);
}
static
int
sip_wizard_create_account
(
SipSetupContext
*
ctx
,
const
char
*
identity
,
const
char
*
passwd
,
const
char
*
email
,
int
subscribe
)
{
LinphoneXmlRpcRequest
*
request
=
linphone_xml_rpc_request_new_with_args
(
"create_account"
,
LinphoneXmlRpcArgInt
,
LinphoneXmlRpcArgString
,
identity
,
LinphoneXmlRpcArgString
,
passwd
,
LinphoneXmlRpcArgString
,
email
,
LinphoneXmlRpcArgInt
,
subscribe
,
LinphoneXmlRpcArgNone
);
return
do_simple_xmlrpc_request
(
ctx
,
request
);
}
static
void
guess_display_name
(
LinphoneAddress
*
from
){
const
char
*
username
=
linphone_address_get_username
(
from
);
char
*
dn
=
(
char
*
)
ms_malloc
(
strlen
(
username
)
+
1
);
const
char
*
it
;
char
*
wptr
=
dn
;
bool_t
begin
=
TRUE
;
bool_t
surname
=
FALSE
;
for
(
it
=
username
;
*
it
!=
'\0'
;
++
it
){
if
(
begin
){
*
wptr
=
toupper
(
*
it
);
begin
=
FALSE
;
}
else
if
(
*
it
==
'.'
){
if
(
surname
)
break
;
*
wptr
=
' '
;
begin
=
TRUE
;