mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
Splitted linphone_core_init in half into linphone_core_start, added new global state GlobalConfiguring and a new callback for the configuring state
This commit is contained in:
parent
a89206aec1
commit
227742469f
6 changed files with 155 additions and 16 deletions
2
README
2
README
|
|
@ -33,7 +33,7 @@ This is Linphone, a free (GPL) video softphone based on the SIP protocol.
|
|||
|
||||
Here is the command line to get these dependencies installed for Ubuntu && Debian
|
||||
|
||||
$ sudo apt-get install libtool intltool libgtk2.0-dev libosip2-dev libexosip2-dev libspeexdsp-dev libavcodec-dev libswscale-dev libx11-dev libxv-dev libgl1-mesa-dev libglew1.6-dev libv4l-dev libxml2-dev
|
||||
$ sudo apt-get install libtool intltool libgtk2.0-dev libspeexdsp-dev libavcodec-dev libswscale-dev libx11-dev libxv-dev libgl1-mesa-dev libglew1.6-dev libv4l-dev libxml2-dev
|
||||
|
||||
+ for optional library
|
||||
$ sudo apt-get install libreadline-dev libgsm1-dev libtheora-dev libsoup2.4-dev libsqlite3-dev libupnp4-dev
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ static void linphone_core_run_hooks(LinphoneCore *lc);
|
|||
static void linphone_core_free_hooks(LinphoneCore *lc);
|
||||
|
||||
#include "enum.h"
|
||||
#include "contact_providers_priv.h"
|
||||
|
||||
|
||||
const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
|
||||
|
|
@ -610,6 +611,17 @@ static void sound_config_read(LinphoneCore *lc)
|
|||
linphone_core_get_audio_features(lc);
|
||||
}
|
||||
|
||||
static void certificates_config_read(LinphoneCore *lc)
|
||||
{
|
||||
#ifdef __linux
|
||||
sal_set_root_ca(lc->sal, lp_config_get_string(lc->config,"sip","root_ca", "/etc/ssl/certs"));
|
||||
#else
|
||||
sal_set_root_ca(lc->sal, lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE));
|
||||
#endif
|
||||
linphone_core_verify_server_certificates(lc,lp_config_get_int(lc->config,"sip","verify_server_certs",TRUE));
|
||||
linphone_core_verify_server_cn(lc,lp_config_get_int(lc->config,"sip","verify_server_cn",TRUE));
|
||||
}
|
||||
|
||||
static void sip_config_read(LinphoneCore *lc)
|
||||
{
|
||||
char *contact;
|
||||
|
|
@ -635,14 +647,7 @@ static void sip_config_read(LinphoneCore *lc)
|
|||
tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0);
|
||||
tr.tls_port=lp_config_get_int(lc->config,"sip","sip_tls_port",0);
|
||||
|
||||
|
||||
#ifdef __linux
|
||||
sal_set_root_ca(lc->sal, lp_config_get_string(lc->config,"sip","root_ca", "/etc/ssl/certs"));
|
||||
#else
|
||||
sal_set_root_ca(lc->sal, lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE));
|
||||
#endif
|
||||
linphone_core_verify_server_certificates(lc,lp_config_get_int(lc->config,"sip","verify_server_certs",TRUE));
|
||||
linphone_core_verify_server_cn(lc,lp_config_get_int(lc->config,"sip","verify_server_cn",TRUE));
|
||||
certificates_config_read(lc);
|
||||
/*setting the dscp must be done before starting the transports, otherwise it is not taken into effect*/
|
||||
sal_set_dscp(lc->sal,linphone_core_get_sip_dscp(lc));
|
||||
/*start listening on ports*/
|
||||
|
|
@ -1221,7 +1226,7 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const
|
|||
}
|
||||
}
|
||||
|
||||
static void misc_config_read (LinphoneCore *lc) {
|
||||
static void misc_config_read(LinphoneCore *lc) {
|
||||
LpConfig *config=lc->config;
|
||||
const char *uuid;
|
||||
|
||||
|
|
@ -1237,10 +1242,30 @@ static void misc_config_read (LinphoneCore *lc) {
|
|||
sal_set_uuid(lc->sal, uuid);
|
||||
}
|
||||
|
||||
static void linphone_core_start(LinphoneCore * lc) {
|
||||
sip_setup_register_all();
|
||||
sound_config_read(lc);
|
||||
net_config_read(lc);
|
||||
rtp_config_read(lc);
|
||||
codecs_config_read(lc);
|
||||
sip_config_read(lc);
|
||||
video_config_read(lc);
|
||||
//autoreplier_config_init(&lc->autoreplier_conf);
|
||||
lc->presence_model=linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline, NULL);
|
||||
misc_config_read(lc);
|
||||
ui_config_read(lc);
|
||||
#ifdef TUNNEL_ENABLED
|
||||
lc->tunnel=linphone_core_tunnel_new(lc);
|
||||
if (lc->tunnel) linphone_tunnel_configure(lc->tunnel);
|
||||
#endif
|
||||
|
||||
if (lc->vtable.display_status)
|
||||
lc->vtable.display_status(lc,_("Ready"));
|
||||
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
|
||||
linphone_core_set_state(lc,LinphoneGlobalOn,"Ready");
|
||||
}
|
||||
|
||||
|
||||
static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata)
|
||||
static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata)
|
||||
{
|
||||
ms_message("Initializing LinphoneCore %s", linphone_core_get_version());
|
||||
memset (lc, 0, sizeof (LinphoneCore));
|
||||
|
|
@ -1344,9 +1369,19 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
|
|||
#endif
|
||||
|
||||
if (lc->vtable.display_status)
|
||||
lc->vtable.display_status(lc,_("Ready"));
|
||||
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
|
||||
linphone_core_set_state(lc,LinphoneGlobalOn,"Ready");
|
||||
lc->vtable.display_status(lc, _("Configuring"));
|
||||
linphone_core_set_state(lc, LinphoneGlobalConfiguring, "Configuring");
|
||||
|
||||
const char *remote_provisioning_uri = lp_config_get_string(lc->config, "app", "remote_provisioning", NULL);
|
||||
LinphoneConfiguringState configuring_result = LinphoneConfiguringSkipped;
|
||||
if (remote_provisioning_uri) {
|
||||
certificates_config_read(lc);
|
||||
}
|
||||
|
||||
if (lc->vtable.configuring_status)
|
||||
lc->vtable.configuring_status(lc, configuring_result, configuring_result == LinphoneConfiguringFailed ? _("Configuring failed") : NULL);
|
||||
|
||||
linphone_core_start(lc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -5923,6 +5958,8 @@ const char *linphone_global_state_to_string(LinphoneGlobalState gs){
|
|||
break;
|
||||
case LinphoneGlobalShutdown:
|
||||
return "LinphoneGlobalShutdown";
|
||||
case LinphoneGlobalConfiguring:
|
||||
return "LinphoneGlobalConfiguring";
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -1062,7 +1062,8 @@ typedef enum _LinphoneGlobalState{
|
|||
LinphoneGlobalOff,
|
||||
LinphoneGlobalStartup,
|
||||
LinphoneGlobalOn,
|
||||
LinphoneGlobalShutdown
|
||||
LinphoneGlobalShutdown,
|
||||
LinphoneGlobalConfiguring
|
||||
}LinphoneGlobalState;
|
||||
|
||||
const char *linphone_global_state_to_string(LinphoneGlobalState gs);
|
||||
|
|
@ -1212,6 +1213,23 @@ typedef void (*LinphoneCoreCallStatsUpdatedCb)(LinphoneCore *lc, LinphoneCall *c
|
|||
*/
|
||||
typedef void (*LinphoneCoreInfoReceivedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
|
||||
|
||||
/**
|
||||
* LinphoneGlobalState describes the global state of the LinphoneCore object.
|
||||
* It is notified via the LinphoneCoreVTable::global_state_changed
|
||||
**/
|
||||
typedef enum _LinphoneConfiguringState {
|
||||
LinphoneConfiguringSuccessful,
|
||||
LinphoneConfiguringFailed,
|
||||
LinphoneConfiguringSkipped
|
||||
} LinphoneConfiguringState;
|
||||
|
||||
/**
|
||||
* Callback prototype for configuring status changes notification
|
||||
* @param lc the LinphoneCore
|
||||
* @param message informational message.
|
||||
*/
|
||||
typedef void (*LinphoneCoreConfiguringStatusCb)(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
|
||||
|
||||
/**
|
||||
* This structure holds all callbacks that the application should implement.
|
||||
* None is mandatory.
|
||||
|
|
@ -1236,6 +1254,7 @@ typedef struct _LinphoneCoreVTable{
|
|||
LinphoneCoreSubscriptionStateChangedCb subscription_state_changed; /**<Notifies subscription state change */
|
||||
LinphoneCoreNotifyReceivedCb notify_received; /**< Notifies a an event notification, see linphone_core_subscribe() */
|
||||
LinphoneCorePublishStateChangedCb publish_state_changed;/**Notifies publish state change (only from #LinphoneEvent api)*/
|
||||
LinphoneCoreConfiguringStatusCb configuring_status; /** Notifies configuring status changes */
|
||||
DisplayStatusCb display_status; /**< @deprecated Callback that notifies various events with human readable text.*/
|
||||
DisplayMessageCb display_message;/**< @deprecated Callback to display a message to the user */
|
||||
DisplayMessageCb display_warning;/**< @deprecated Callback to display a warning to the user */
|
||||
|
|
@ -2259,6 +2278,16 @@ typedef struct _LinphoneContactProvider LinphoneContactProvider;
|
|||
|
||||
typedef void (*ContactSearchCallback)( LinphoneContactSearch* id, MSList* friends, void* data );
|
||||
|
||||
/** Remote provisioning
|
||||
*/
|
||||
|
||||
/**
|
||||
* Download a remote provisioning file from the given uri and applies it to current lp config.
|
||||
* A restart is requiered for the changes to be applied.
|
||||
* @param lc the LinphoneCore
|
||||
* @param remote_provisioning_uri the URI at which the remote provisioning file is available
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneConfiguringState linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ public:
|
|||
vTable.subscription_state_changed=subscriptionStateChanged;
|
||||
vTable.notify_received=notifyReceived;
|
||||
vTable.publish_state_changed=publishStateChanged;
|
||||
vTable.configuring_status=configuringStatus;
|
||||
|
||||
listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
|
||||
|
||||
|
|
@ -276,6 +277,10 @@ public:
|
|||
|
||||
subscriptionDirClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/SubscriptionDir"));
|
||||
subscriptionDirFromIntId = env->GetStaticMethodID(subscriptionDirClass,"fromInt","(I)Lorg/linphone/core/SubscriptionDir;");
|
||||
|
||||
configuringStateId = env->GetMethodID(listenerClass,"configuringStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$RemoteProvisioningState;Ljava/lang/String;)V");
|
||||
configuringStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RemoteProvisioningState"));
|
||||
configuringStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RemoteProvisioningState;");
|
||||
}
|
||||
|
||||
~LinphoneCoreData() {
|
||||
|
|
@ -286,6 +291,7 @@ public:
|
|||
if (userdata) env->DeleteGlobalRef(userdata);
|
||||
env->DeleteGlobalRef(listenerClass);
|
||||
env->DeleteGlobalRef(globalStateClass);
|
||||
env->DeleteGlobalRef(configuringStateClass);
|
||||
env->DeleteGlobalRef(registrationStateClass);
|
||||
env->DeleteGlobalRef(callStateClass);
|
||||
env->DeleteGlobalRef(chatMessageStateClass);
|
||||
|
|
@ -317,6 +323,10 @@ public:
|
|||
jmethodID subscriptionStateId;
|
||||
jmethodID publishStateId;
|
||||
jmethodID notifyRecvId;
|
||||
|
||||
jclass configuringStateClass;
|
||||
jmethodID configuringStateId;
|
||||
jmethodID configuringStateFromIntId;
|
||||
|
||||
jclass globalStateClass;
|
||||
jmethodID globalStateId;
|
||||
|
|
@ -708,6 +718,17 @@ public:
|
|||
,content ? create_java_linphone_content(env,content) : NULL
|
||||
);
|
||||
}
|
||||
|
||||
static void configuringStatus(LinphoneCore *lc, LinphoneConfiguringState status, const char *message) {
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
if (result != 0) {
|
||||
ms_error("cannot attach VM");
|
||||
return;
|
||||
}
|
||||
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
|
||||
env->CallVoidMethod(lcData->listener, lcData->configuringStateId, lcData->core, env->CallStaticObjectMethod(lcData->configuringStateClass,lcData->configuringStateFromIntId,(jint)status), message ? env->NewStringUTF(message) : NULL);
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid);
|
|||
static void linphone_gtk_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
|
||||
static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
|
||||
static void linphone_gtk_display_status(LinphoneCore *lc, const char *status);
|
||||
static void linphone_gtk_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
|
||||
static void linphone_gtk_display_message(LinphoneCore *lc, const char *msg);
|
||||
static void linphone_gtk_display_warning(LinphoneCore *lc, const char *warning);
|
||||
static void linphone_gtk_display_url(LinphoneCore *lc, const char *msg, const char *url);
|
||||
|
|
@ -272,6 +273,7 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
|
|||
vtable.call_encryption_changed=linphone_gtk_call_encryption_changed;
|
||||
vtable.transfer_state_changed=linphone_gtk_transfer_state_changed;
|
||||
vtable.dtmf_received=linphone_gtk_dtmf_received;
|
||||
vtable.configuring_status=linphone_gtk_configuring_status;
|
||||
|
||||
the_core=linphone_core_new(&vtable,config_file,factory_config_file,NULL);
|
||||
//lp_config_set_int(linphone_core_get_config(the_core), "sip", "store_auth_info", 0);
|
||||
|
|
@ -1237,6 +1239,12 @@ static void linphone_gtk_display_status(LinphoneCore *lc, const char *status){
|
|||
status);
|
||||
}
|
||||
|
||||
static void linphone_gtk_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message) {
|
||||
if (status == LinphoneConfiguringFailed) {
|
||||
linphone_gtk_display_something(GTK_MESSAGE_ERROR, message);
|
||||
}
|
||||
}
|
||||
|
||||
static void linphone_gtk_display_message(LinphoneCore *lc, const char *msg){
|
||||
linphone_gtk_display_something(GTK_MESSAGE_INFO,msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ public interface LinphoneCore {
|
|||
* Shutdown
|
||||
*/
|
||||
static public GlobalState GlobalShutdown = new GlobalState(3,"GlobalShutdown");
|
||||
/**
|
||||
* Configuring
|
||||
*/
|
||||
static public GlobalState GlobalConfiguring = new GlobalState(4,"GlobalConfiguring");
|
||||
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
|
|
@ -75,6 +79,46 @@ public interface LinphoneCore {
|
|||
return mStringValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* linphone remote provisioning states
|
||||
*/
|
||||
static public class RemoteProvisioningState {
|
||||
|
||||
static private Vector<RemoteProvisioningState> values = new Vector<RemoteProvisioningState>();
|
||||
/**
|
||||
* Off
|
||||
*/
|
||||
static public RemoteProvisioningState ConfiguringSuccessful = new RemoteProvisioningState(0,"ConfiguringSuccessful");
|
||||
/**
|
||||
* Startup
|
||||
*/
|
||||
static public RemoteProvisioningState ConfiguringFailed = new RemoteProvisioningState(1,"ConfiguringFailed");
|
||||
/**
|
||||
* On
|
||||
*/
|
||||
static public RemoteProvisioningState ConfiguringSkipped = new RemoteProvisioningState(2,"ConfiguringSkipped");
|
||||
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
|
||||
|
||||
private RemoteProvisioningState(int value,String stringValue) {
|
||||
mValue = value;
|
||||
values.addElement(this);
|
||||
mStringValue=stringValue;
|
||||
}
|
||||
public static RemoteProvisioningState fromInt(int value) {
|
||||
|
||||
for (int i=0; i<values.size();i++) {
|
||||
RemoteProvisioningState state = (RemoteProvisioningState) values.elementAt(i);
|
||||
if (state.mValue == value) return state;
|
||||
}
|
||||
throw new RuntimeException("state not found ["+value+"]");
|
||||
}
|
||||
public String toString() {
|
||||
return mStringValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Describes proxy registration states.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue