forked from mirrors/linphone-iphone
Rework assistant for asynchronous XML-RPC requests.
This commit is contained in:
parent
caf5d38787
commit
17cad99e4f
22 changed files with 859 additions and 971 deletions
|
|
@ -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)
|
||||
option(ENABLE_DEBUG_LOGS "Turn on or off debug level logs." NO)
|
||||
|
||||
|
||||
|
|
@ -121,9 +120,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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
26
configure.ac
26
configure.ac
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
209
coreapi/account_creator.c
Normal file
209
coreapi/account_creator.c
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
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);
|
||||
}
|
||||
78
coreapi/account_creator.h
Normal file
78
coreapi/account_creator.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
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_ */
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1504,98 +1504,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
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;
|
||||
surname=TRUE;
|
||||
}else {
|
||||
*wptr=*it;
|
||||
}
|
||||
wptr++;
|
||||
}
|
||||
*wptr='\0';
|
||||
linphone_address_set_display_name(from,dn);
|
||||
ms_free(dn);
|
||||
}
|
||||
|
||||
static int sip_wizard_do_login(SipSetupContext * ctx, const char *uri, const char *passwd, const char *userid){
|
||||
LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
|
||||
LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
|
||||
LinphoneAuthInfo *auth;
|
||||
LinphoneAddress *parsed_uri;
|
||||
char *tmp;
|
||||
|
||||
parsed_uri=linphone_address_new(uri);
|
||||
if (parsed_uri==NULL){
|
||||
return -1;
|
||||
}
|
||||
if (linphone_address_get_display_name(parsed_uri)!=NULL){
|
||||
guess_display_name(parsed_uri);
|
||||
}
|
||||
tmp=linphone_address_as_string(parsed_uri);
|
||||
linphone_proxy_config_set_identity(cfg,tmp);
|
||||
if (passwd) {
|
||||
auth=linphone_auth_info_new(linphone_address_get_username(parsed_uri),NULL,passwd,NULL,NULL,NULL);
|
||||
linphone_core_add_auth_info(lc,auth);
|
||||
}
|
||||
linphone_proxy_config_enable_register(cfg,TRUE);
|
||||
linphone_proxy_config_done(cfg);
|
||||
ms_free(tmp);
|
||||
linphone_address_destroy(parsed_uri);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* a simple SipSetup built-in plugin to allow creating accounts at runtime*/
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
SipSetup linphone_sip_wizard={
|
||||
.name="SipWizard",
|
||||
.capabilities=SIP_SETUP_CAP_ACCOUNT_MANAGER,
|
||||
.init_instance=sip_wizard_init_instance,
|
||||
.uninit_instance=sip_wizard_uninit_instance,
|
||||
.account_exists=sip_wizard_account_exists,
|
||||
.create_account=sip_wizard_create_account,
|
||||
.login_account=sip_wizard_do_login,
|
||||
.get_domains=sip_wizard_get_domains,
|
||||
.account_validated=sip_wizard_account_validated
|
||||
};
|
||||
|
||||
#else
|
||||
SipSetup linphone_sip_wizard={
|
||||
"SipWizard",
|
||||
SIP_SETUP_CAP_ACCOUNT_MANAGER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
sip_wizard_init_instance,
|
||||
sip_wizard_uninit_instance,
|
||||
sip_wizard_account_exists,
|
||||
sip_wizard_create_account,
|
||||
sip_wizard_do_login,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
sip_wizard_get_domains,
|
||||
NULL,
|
||||
NULL,
|
||||
sip_wizard_account_validated
|
||||
};
|
||||
|
||||
#endif
|
||||
115
coreapi/xmlrpc.c
115
coreapi/xmlrpc.c
|
|
@ -116,40 +116,46 @@ static void free_arg(LinphoneXmlRpcArg *arg) {
|
|||
}
|
||||
|
||||
static void process_io_error_from_post_xml_rpc_request(void *data, const belle_sip_io_error_event_t *event) {
|
||||
LinphoneXmlRpcSession *session = (LinphoneXmlRpcSession *)data;
|
||||
ms_error("I/O Error during XML-RPC request sending to %s", session->url);
|
||||
session->request->status = LinphoneXmlRpcStatusFailed;
|
||||
ms_cond_signal(&session->cond);
|
||||
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)data;
|
||||
ms_error("I/O Error during XML-RPC request sending");
|
||||
request->status = LinphoneXmlRpcStatusFailed;
|
||||
if (request->cb != NULL) {
|
||||
request->cb(request, request->cb_ud);
|
||||
}
|
||||
linphone_xml_rpc_request_unref(request);
|
||||
}
|
||||
|
||||
static void process_auth_requested_from_post_xml_rpc_request(void *data, belle_sip_auth_event_t *event) {
|
||||
LinphoneXmlRpcSession *session = (LinphoneXmlRpcSession *)data;
|
||||
ms_error("Error during XML-RPC request sending to connect %s", session->url);
|
||||
session->request->status = LinphoneXmlRpcStatusFailed;
|
||||
ms_cond_signal(&session->cond);
|
||||
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)data;
|
||||
ms_error("Authentication error during XML-RPC request sending");
|
||||
request->status = LinphoneXmlRpcStatusFailed;
|
||||
if (request->cb != NULL) {
|
||||
request->cb(request, request->cb_ud);
|
||||
}
|
||||
linphone_xml_rpc_request_unref(request);
|
||||
}
|
||||
|
||||
static void parse_valid_xml_rpc_response(LinphoneXmlRpcSession *session, const char *response_body) {
|
||||
static void parse_valid_xml_rpc_response(LinphoneXmlRpcRequest *request, const char *response_body) {
|
||||
xmlparsing_context_t *xml_ctx = linphone_xmlparsing_context_new();
|
||||
xmlSetGenericErrorFunc(xml_ctx, linphone_xmlparsing_genericxml_error);
|
||||
session->request->status = LinphoneXmlRpcStatusFailed;
|
||||
request->status = LinphoneXmlRpcStatusFailed;
|
||||
xml_ctx->doc = xmlReadDoc((const unsigned char*)response_body, 0, NULL, 0);
|
||||
if (xml_ctx->doc != NULL) {
|
||||
const char *response_str;
|
||||
if (linphone_create_xml_xpath_context(xml_ctx) < 0) goto end;
|
||||
switch (session->request->response.type) {
|
||||
switch (request->response.type) {
|
||||
case LinphoneXmlRpcArgInt:
|
||||
response_str = linphone_get_xml_text_content(xml_ctx, "/methodResponse/params/param/value/int");
|
||||
if (response_str != NULL) {
|
||||
session->request->response.data.i = atoi(response_str);
|
||||
session->request->status = LinphoneXmlRpcStatusOk;
|
||||
request->response.data.i = atoi(response_str);
|
||||
request->status = LinphoneXmlRpcStatusOk;
|
||||
}
|
||||
break;
|
||||
case LinphoneXmlRpcArgString:
|
||||
response_str = linphone_get_xml_text_content(xml_ctx, "/methodResponse/params/param/value/string");
|
||||
if (response_str != NULL) {
|
||||
session->request->response.data.s = belle_sip_strdup(response_str);
|
||||
session->request->status = LinphoneXmlRpcStatusOk;
|
||||
request->response.data.s = belle_sip_strdup(response_str);
|
||||
request->status = LinphoneXmlRpcStatusOk;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -161,43 +167,42 @@ static void parse_valid_xml_rpc_response(LinphoneXmlRpcSession *session, const c
|
|||
}
|
||||
end:
|
||||
linphone_xmlparsing_context_destroy(xml_ctx);
|
||||
ms_cond_signal(&session->cond);
|
||||
if (request->cb != NULL) {
|
||||
request->cb(request, request->cb_ud);
|
||||
}
|
||||
}
|
||||
|
||||
static void notify_xml_rpc_error(LinphoneXmlRpcSession *session) {
|
||||
session->request->status = LinphoneXmlRpcStatusOk;
|
||||
ms_cond_signal(&session->cond);
|
||||
static void notify_xml_rpc_error(LinphoneXmlRpcRequest *request) {
|
||||
request->status = LinphoneXmlRpcStatusOk;
|
||||
if (request->cb != NULL) {
|
||||
request->cb(request, request->cb_ud);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function called when we have a response from server during the upload of the log collection to the server (rcs5.1 recommandation)
|
||||
* Note: The first post is empty and the server shall reply a 204 (No content) message, this will trigger a new post request to the server
|
||||
* to upload the file. The server response to this second post is processed by this same function
|
||||
*
|
||||
* @param[in] data The user-defined pointer associated with the request, it contains the LinphoneCore object
|
||||
* @param[in] event The response from server
|
||||
*/
|
||||
static void process_response_from_post_xml_rpc_request(void *data, const belle_http_response_event_t *event) {
|
||||
LinphoneXmlRpcSession *session = (LinphoneXmlRpcSession *)data;
|
||||
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)data;
|
||||
|
||||
/* Check the answer code */
|
||||
if (event->response) {
|
||||
int code = belle_http_response_get_status_code(event->response);
|
||||
if (code == 200) { /* Valid response from the server. */
|
||||
parse_valid_xml_rpc_response(session, belle_sip_message_get_body((belle_sip_message_t *)event->response));
|
||||
parse_valid_xml_rpc_response(request, belle_sip_message_get_body((belle_sip_message_t *)event->response));
|
||||
} else {
|
||||
notify_xml_rpc_error(session);
|
||||
notify_xml_rpc_error(request);
|
||||
}
|
||||
}
|
||||
linphone_xml_rpc_request_unref(request);
|
||||
}
|
||||
|
||||
|
||||
static LinphoneXmlRpcRequest * _linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type) {
|
||||
static LinphoneXmlRpcRequest * _linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type, LinphoneXmlRpcResponseCb cb, void *user_data) {
|
||||
LinphoneXmlRpcRequest *request = belle_sip_object_new(LinphoneXmlRpcRequest);
|
||||
belle_sip_object_ref(request);
|
||||
request->status = LinphoneXmlRpcStatusPending;
|
||||
request->response.type = return_type;
|
||||
request->method = belle_sip_strdup(method);
|
||||
request->cb = cb;
|
||||
request->cb_ud = user_data;
|
||||
return request;
|
||||
}
|
||||
|
||||
|
|
@ -226,9 +231,6 @@ static void _linphone_xml_rpc_request_destroy(LinphoneXmlRpcRequest *request) {
|
|||
|
||||
static void _linphone_xml_rpc_session_destroy(LinphoneXmlRpcSession *session) {
|
||||
belle_sip_free(session->url);
|
||||
ms_cond_destroy(&session->cond);
|
||||
ms_mutex_destroy(&session->cond_mutex);
|
||||
ms_mutex_destroy(&session->mutex);
|
||||
}
|
||||
|
||||
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneXmlRpcRequest);
|
||||
|
|
@ -249,19 +251,18 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneXmlRpcSession, belle_sip_object_t,
|
|||
);
|
||||
|
||||
|
||||
LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type) {
|
||||
LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type);
|
||||
LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type, LinphoneXmlRpcResponseCb cb, void *user_data) {
|
||||
LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type, cb, user_data);
|
||||
format_request(request);
|
||||
return request;
|
||||
}
|
||||
|
||||
LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, ...) {
|
||||
LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, LinphoneXmlRpcResponseCb cb, void *user_data, ...) {
|
||||
bool_t cont = TRUE;
|
||||
va_list args;
|
||||
LinphoneXmlRpcArgType arg_type;
|
||||
LinphoneXmlRpcArg *arg = NULL;
|
||||
LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type);
|
||||
va_start(args, return_type);
|
||||
LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type, cb, user_data);
|
||||
va_start(args, cb);
|
||||
while (cont) {
|
||||
arg_type = va_arg(args, LinphoneXmlRpcArgType);
|
||||
switch (arg_type) {
|
||||
|
|
@ -330,9 +331,6 @@ LinphoneXmlRpcSession * linphone_xml_rpc_session_new(LinphoneCore *core, const c
|
|||
belle_sip_object_ref(session);
|
||||
session->core = core;
|
||||
session->url = belle_sip_strdup(url);
|
||||
ms_cond_init(&session->cond, NULL);
|
||||
ms_mutex_init(&session->cond_mutex, NULL);
|
||||
ms_mutex_init(&session->mutex, NULL);
|
||||
return session;
|
||||
}
|
||||
|
||||
|
|
@ -353,40 +351,29 @@ void linphone_xml_rpc_session_set_user_data(LinphoneXmlRpcSession *session, void
|
|||
session->user_data = ud;
|
||||
}
|
||||
|
||||
LinphoneXmlRpcStatus linphone_xml_rpc_session_send_request(LinphoneXmlRpcSession *session, LinphoneXmlRpcRequest *request) {
|
||||
void linphone_xml_rpc_session_send_request(LinphoneXmlRpcSession *session, LinphoneXmlRpcRequest *request) {
|
||||
belle_http_request_listener_callbacks_t cbs = { 0 };
|
||||
belle_http_request_listener_t *l;
|
||||
belle_generic_uri_t *uri;
|
||||
belle_http_request_t *req;
|
||||
belle_sip_memory_body_handler_t *bh;
|
||||
const char *data;
|
||||
LinphoneXmlRpcStatus status;
|
||||
LinphoneContent *content;
|
||||
|
||||
ms_mutex_lock(&session->mutex);
|
||||
session->request = linphone_xml_rpc_request_ref(request);
|
||||
session->content = linphone_content_new();
|
||||
linphone_content_set_type(session->content, "text");
|
||||
linphone_content_set_subtype(session->content,"xml");
|
||||
linphone_content_set_string_buffer(session->content, linphone_xml_rpc_request_get_content(request));
|
||||
linphone_xml_rpc_request_ref(request);
|
||||
content = linphone_content_new();
|
||||
linphone_content_set_type(content, "text");
|
||||
linphone_content_set_subtype(content, "xml");
|
||||
linphone_content_set_string_buffer(content, linphone_xml_rpc_request_get_content(request));
|
||||
uri = belle_generic_uri_parse(session->url);
|
||||
req = belle_http_request_create("POST", uri, belle_sip_header_content_type_create("text", "xml"), NULL);
|
||||
data = linphone_xml_rpc_request_get_content(request);
|
||||
bh = belle_sip_memory_body_handler_new_copy_from_buffer(data, strlen(data), NULL, session);
|
||||
bh = belle_sip_memory_body_handler_new_copy_from_buffer(data, strlen(data), NULL, NULL);
|
||||
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), BELLE_SIP_BODY_HANDLER(bh));
|
||||
cbs.process_response = process_response_from_post_xml_rpc_request;
|
||||
cbs.process_io_error = process_io_error_from_post_xml_rpc_request;
|
||||
cbs.process_auth_requested = process_auth_requested_from_post_xml_rpc_request;
|
||||
l = belle_http_request_listener_create_from_callbacks(&cbs, session);
|
||||
l = belle_http_request_listener_create_from_callbacks(&cbs, request);
|
||||
belle_http_provider_send_request(session->core->http_provider, req, l);
|
||||
|
||||
ms_mutex_lock(&session->cond_mutex);
|
||||
ms_cond_wait(&session->cond, &session->cond_mutex);
|
||||
ms_mutex_unlock(&session->cond_mutex);
|
||||
status = session->request->status;
|
||||
linphone_xml_rpc_request_unref(session->request);
|
||||
session->request = NULL;
|
||||
linphone_content_unref(session->content);
|
||||
session->content = NULL;
|
||||
ms_mutex_unlock(&session->mutex);
|
||||
return status;
|
||||
linphone_content_unref(content);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
buffer.h
|
||||
xmlrpc.h
|
||||
Copyright (C) 2010-2015 Belledonne Communications SARL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
@ -59,22 +59,30 @@ typedef struct _LinphoneXmlRpcRequest LinphoneXmlRpcRequest;
|
|||
**/
|
||||
typedef struct _LinphoneXmlRpcSession LinphoneXmlRpcSession;
|
||||
|
||||
typedef void (*LinphoneXmlRpcResponseCb)(LinphoneXmlRpcRequest *request, void *user_data);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new LinphoneXmlRpcRequest object.
|
||||
* @param[in] method The XML-RPC method to call.
|
||||
* @param[in] return_type The expected XML-RPC response type.
|
||||
* @return A new LinphoneXmlRpcRequest object.
|
||||
* Create a new LinphoneXmlRpcRequest object.
|
||||
* @param[in] method The XML-RPC method to call.
|
||||
* @param[in] return_type The expected XML-RPC response type.
|
||||
* @param[in] cb The callback that will be called when the XML-RPC response is received or if an error occurs.
|
||||
* @param[in] user_data A user data that will be passed as a parameter to the callback.
|
||||
* @return A new LinphoneXmlRpcRequest object.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type);
|
||||
LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type,
|
||||
LinphoneXmlRpcResponseCb cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Create a new LinphoneXmlRpcRequest object giving the arguments to the method call.
|
||||
* @param[in] method The XML-RPC method to call.
|
||||
* @param[in] return_type The expected XML-RPC response type.
|
||||
* @param[in] cb The callback that will be called when the XML-RPC response is received or if an error occurs.
|
||||
* @param[in] user_data A user data that will be passed as a parameter to the callback.
|
||||
* @return A new LinphoneXmlRpcRequest object.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, ...);
|
||||
LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type,
|
||||
LinphoneXmlRpcResponseCb cb, void *user_data, ...);
|
||||
|
||||
/**
|
||||
* Acquire a reference to the XML-RPC request.
|
||||
|
|
@ -184,9 +192,8 @@ LINPHONE_PUBLIC void linphone_xml_rpc_session_set_user_data(LinphoneXmlRpcSessio
|
|||
* Send an XML-RPC request.
|
||||
* @param[in] session LinphoneXmlRpcSession object.
|
||||
* @param[in] request The LinphoneXmlRpcRequest to be sent.
|
||||
* @return The status of the XML-RPC request sending. If it is LinphoneXmlRpcStatusOk, use linphone_xml_rpc_session_get_response() to get the XML-RPC response.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneXmlRpcStatus linphone_xml_rpc_session_send_request(LinphoneXmlRpcSession *session, LinphoneXmlRpcRequest *request);
|
||||
LINPHONE_PUBLIC void linphone_xml_rpc_session_send_request(LinphoneXmlRpcSession *session, LinphoneXmlRpcRequest *request);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ set(SOURCE_FILES
|
|||
loginframe.c
|
||||
main.c
|
||||
propertybox.c
|
||||
setupwizard.c
|
||||
singleinstance.c
|
||||
status_icon.c
|
||||
status_notifier.c
|
||||
|
|
@ -75,10 +76,6 @@ if(WIN32)
|
|||
list(APPEND SOURCE_FILES linphone.rc)
|
||||
endif()
|
||||
|
||||
if(ENABLE_ASSISTANT)
|
||||
list(APPEND SOURCE_FILES setupwizard.c)
|
||||
endif()
|
||||
|
||||
if(GETTEXT_FOUND)
|
||||
add_definitions("-DENABLE_NLS")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ linphone_SOURCES= \
|
|||
singleinstance.c \
|
||||
conference.c \
|
||||
config-fetching.c \
|
||||
setupwizard.c \
|
||||
audio_assistant.c \
|
||||
videowindow.c \
|
||||
status_icon.c status_icon.h \
|
||||
|
|
@ -64,11 +65,6 @@ linphone_SOURCES+= \
|
|||
status_notifier.h
|
||||
endif
|
||||
|
||||
if BUILD_WIZARD
|
||||
linphone_SOURCES+= \
|
||||
setupwizard.c
|
||||
endif
|
||||
|
||||
linphone_LDADD= $(top_builddir)/coreapi/liblinphone.la \
|
||||
$(LIBGTK_LIBS) $(NOTIFY1_LIBS) $(NOTIFY4_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS) $(SQLITE3_LIBS) $(BELLESIP_LIBS)
|
||||
|
||||
|
|
|
|||
|
|
@ -1979,9 +1979,7 @@ static void linphone_gtk_check_soundcards(){
|
|||
static void linphone_gtk_quit_core(void){
|
||||
linphone_gtk_unmonitor_usb();
|
||||
g_source_remove_by_user_data(linphone_gtk_get_core());
|
||||
#ifdef BUILD_WIZARD
|
||||
linphone_gtk_close_assistant();
|
||||
#endif
|
||||
linphone_gtk_set_ldap(NULL);
|
||||
linphone_gtk_destroy_log_window();
|
||||
linphone_core_destroy(the_core);
|
||||
|
|
@ -2021,12 +2019,10 @@ static gboolean on_block_termination(void){
|
|||
static void linphone_gtk_init_ui(void){
|
||||
linphone_gtk_init_main_window();
|
||||
|
||||
#ifdef BUILD_WIZARD
|
||||
// Veryfing if at least one sip account is configured. If not, show wizard
|
||||
if (linphone_core_get_proxy_config_list(linphone_gtk_get_core()) == NULL) {
|
||||
linphone_gtk_show_assistant(the_ui);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(run_audio_assistant){
|
||||
linphone_gtk_show_audio_assistant();
|
||||
|
|
|
|||
|
|
@ -923,6 +923,7 @@
|
|||
<child>
|
||||
<object class="GtkImageMenuItem" id="assistant_item">
|
||||
<property name="label" translatable="yes">Account assistant</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">connect_image</property>
|
||||
<property name="use_stock">False</property>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<property name="modal">True</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox9">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
|||
|
|
@ -1584,11 +1584,6 @@ void linphone_gtk_show_parameters(void){
|
|||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(pb,"username")),linphone_address_get_username(contact));
|
||||
linphone_address_destroy(contact);
|
||||
}
|
||||
#ifdef BUILD_WIZARD
|
||||
gtk_widget_show(linphone_gtk_get_widget(pb,"wizard"));
|
||||
#else
|
||||
gtk_widget_hide(linphone_gtk_get_widget(pb,"wizard"));
|
||||
#endif
|
||||
linphone_gtk_show_sip_accounts(pb);
|
||||
/* CODECS CONFIG */
|
||||
linphone_gtk_init_codec_list(GTK_TREE_VIEW(codec_list));
|
||||
|
|
|
|||
1005
gtk/setupwizard.c
1005
gtk/setupwizard.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue