forked from mirrors/linphone-iphone
inapp settings mostly finished.
This commit is contained in:
parent
2e3d4c0fdf
commit
4a0e4e1ee8
13 changed files with 175 additions and 153 deletions
|
|
@ -33,12 +33,10 @@
|
|||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
//[username setText:[[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]];
|
||||
//[passwd setText:[[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]];
|
||||
}
|
||||
|
||||
-(void) viewDidLoad {
|
||||
NSString* siteUrl = [[NSUserDefaults standardUserDefaults] stringForKey:@"firt_login_view_url"];
|
||||
NSString* siteUrl = [[NSUserDefaults standardUserDefaults] stringForKey:@"first_login_view_url"];
|
||||
if (siteUrl==nil) {
|
||||
siteUrl=@"http://www.linphone.org";
|
||||
}
|
||||
|
|
@ -79,9 +77,8 @@
|
|||
[error show];
|
||||
[error release];
|
||||
} else {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:username.text forKey:@"username_preference"];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:passwd.text forKey:@"password_preference"];
|
||||
[[LinphoneManager instance] reconfigureLinphoneIfNeeded:nil];
|
||||
[[LinphoneManager instance].settingsStore setObject:username.text forKey:@"username_preference"];
|
||||
[[LinphoneManager instance].settingsStore setObject:passwd.text forKey:@"password_preference"];
|
||||
[self.activityIndicator setHidden:false];
|
||||
};
|
||||
|
||||
|
|
@ -106,9 +103,9 @@
|
|||
// otherButtonTitles:nil ,nil];
|
||||
//[error show];
|
||||
//[error release];
|
||||
//erase uername passwd
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"username_preference"];
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"password_preference"];
|
||||
//erase username passwd
|
||||
[[LinphoneManager instance].settingsStore setObject:Nil forKey:@"username_preference"];
|
||||
[[LinphoneManager instance].settingsStore setObject:Nil forKey:@"password_preference"];
|
||||
}
|
||||
-(void) displayNotRegisteredFromUI:(UIViewController*) viewCtrl {
|
||||
[self.activityIndicator setHidden:true];
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ void addAnimationFadeTransition(UIView* view, float duration) {
|
|||
UIDevice* device = [UIDevice currentDevice];
|
||||
if ([device respondsToSelector:@selector(isMultitaskingSupported)]
|
||||
&& [device isMultitaskingSupported]) {
|
||||
bool enableVideo = [[NSUserDefaults standardUserDefaults] boolForKey:@"enable_video_preference"];
|
||||
bool enableVideo = linphone_core_video_enabled([LinphoneManager getLc]);
|
||||
|
||||
[LinphoneManager set:contacts hidden:enableVideo withName:"CONTACT button" andReason:AT];
|
||||
[LinphoneManager set:addVideo hidden:!contacts.hidden withName:"ADD_VIDEO button" andReason:AT];
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ int __aeabi_idiv(int a, int b) {
|
|||
|
||||
}
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
if (settingsController.settingsStore!=Nil)
|
||||
[settingsController.settingsStore synchronize];
|
||||
if (![[LinphoneManager instance] enterBackgroundMode]) {
|
||||
// destroying eventHandler if app cannot go in background.
|
||||
// Otherwise if a GSM call happen and Linphone is resumed,
|
||||
|
|
@ -138,34 +140,8 @@ int __aeabi_idiv(int a, int b) {
|
|||
}
|
||||
|
||||
- (void) loadDefaultSettings:(NSDictionary *) appDefaults {
|
||||
|
||||
NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
|
||||
if(!settingsBundle) {
|
||||
NSLog(@"Could not find Settings.bundle");
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableDictionary *rootSettings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Root.plist"]];
|
||||
NSMutableDictionary *audioSettings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"audio.plist"]];
|
||||
NSMutableDictionary *videoSettings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"video.plist"]];
|
||||
NSMutableDictionary *advancedSettings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Advanced.plist"]];
|
||||
|
||||
NSMutableArray *preferences = [rootSettings objectForKey:@"PreferenceSpecifiers"];
|
||||
[preferences addObjectsFromArray:[audioSettings objectForKey:@"PreferenceSpecifiers"]];
|
||||
[preferences addObjectsFromArray:[videoSettings objectForKey:@"PreferenceSpecifiers"]];
|
||||
[preferences addObjectsFromArray:[advancedSettings objectForKey:@"PreferenceSpecifiers"]];
|
||||
|
||||
NSMutableDictionary *defaultsToRegister = [[NSMutableDictionary alloc] initWithCapacity:[preferences count]];
|
||||
|
||||
for(NSDictionary *prefSpecification in preferences) {
|
||||
NSString *key = [prefSpecification objectForKey:@"Key"];
|
||||
if(key && [prefSpecification objectForKey:@"DefaultValue"]) {
|
||||
[defaultsToRegister setObject:[prefSpecification objectForKey:@"DefaultValue"] forKey:key];
|
||||
}
|
||||
}
|
||||
[defaultsToRegister addEntriesFromDictionary:appDefaults];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister];
|
||||
[defaultsToRegister release];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
||||
[appDefaults release];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
|
|
@ -204,22 +180,14 @@ int __aeabi_idiv(int a, int b) {
|
|||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"NO", @"enable_first_login_view_preference", //
|
||||
#ifdef HAVE_AMR
|
||||
@"YES",@"amr_8k_preference", // enable amr by default if compiled with
|
||||
#endif
|
||||
#ifdef HAVE_G729
|
||||
@"YES",@"g729_preference", // enable amr by default if compiled with
|
||||
#endif
|
||||
//@"+33",@"countrycode_preference",
|
||||
nil];
|
||||
|
||||
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: nil];
|
||||
// Put your default NSUserDefaults settings in the dictionary above.
|
||||
|
||||
[self loadDefaultSettings: appDefaults];
|
||||
|
||||
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
||||
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
|
||||
&& [[NSUserDefaults standardUserDefaults] boolForKey:@"disable_autoboot_preference"]) {
|
||||
&& ![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"]) {
|
||||
// autoboot disabled, doing nothing
|
||||
} else {
|
||||
[self startApplication];
|
||||
|
|
@ -240,11 +208,8 @@ int __aeabi_idiv(int a, int b) {
|
|||
// Settings, setup delegate
|
||||
settingsController.delegate = [LinphoneManager instance];
|
||||
settingsController.settingsReaderDelegate = [LinphoneManager instance];
|
||||
settingsController.settingsStore=[[LinphoneCoreSettingsStore alloc] init];
|
||||
//settingsController.file=@"settings/Inappsettings.bundle";
|
||||
[LinphoneManager instance].settingsStore=settingsController.settingsStore=[[LinphoneCoreSettingsStore alloc] init];
|
||||
settingsController.showCreditsFooter=FALSE;
|
||||
//[settingsController.settingsReader init];
|
||||
|
||||
|
||||
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
@interface LinphoneCoreSettingsStore : IASKAbstractSettingsStore {
|
||||
NSDictionary *dict;
|
||||
NSDictionary *changedDict;
|
||||
}
|
||||
|
||||
-(void) transformLinphoneCoreToKeys;
|
||||
|
|
|
|||
|
|
@ -11,44 +11,33 @@
|
|||
#include "lpconfig.h"
|
||||
|
||||
|
||||
struct codec_name_pref_table{
|
||||
const char *name;
|
||||
int rate;
|
||||
NSString *prefname;
|
||||
};
|
||||
extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
||||
|
||||
struct codec_name_pref_table codec_pref_table[]={
|
||||
{ "speex", 8000, @"speex_8k_preference" },
|
||||
{ "speex", 16000, @"speex_16k_preference" },
|
||||
{ "silk", 24000, @"silk_24k_preference" },
|
||||
{ "silk", 16000, @"silk_16k_preference" },
|
||||
{ "amr", 8000, @"amr_8k_preference" },
|
||||
{ "ilbc", 8000, @"ilbc_preference"},
|
||||
{ "pcmu", 8000, @"pcmu_preference"},
|
||||
{ "pcma", 8000, @"pcma_preference"},
|
||||
{ "g722", 8000, @"g722_preference"},
|
||||
{ "g729", 8000, @"g729_preference"},
|
||||
{ "mp4v-es", 90000, @"mp4v-es_preference"},
|
||||
{ "h264", 90000, @"h264_preference"},
|
||||
{ "vp8", 90000, @"vp8_preference"},
|
||||
{ NULL,0,Nil }
|
||||
};
|
||||
|
||||
static NSString *getPrefForCodec(const char *name, int rate){
|
||||
int i;
|
||||
for(i=0;codec_pref_table[i].name!=NULL;++i){
|
||||
if (strcasecmp(codec_pref_table[i].name,name)==0 && codec_pref_table[i].rate==rate)
|
||||
return codec_pref_table[i].prefname;
|
||||
}
|
||||
return Nil;
|
||||
}
|
||||
|
||||
@implementation LinphoneCoreSettingsStore
|
||||
|
||||
-(void) handleMigration{
|
||||
|
||||
NSUserDefaults *oldconfig=[NSUserDefaults standardUserDefaults];
|
||||
NSArray *allkeys=[[oldconfig dictionaryRepresentation] allKeys];
|
||||
for(NSString* key in allkeys){
|
||||
NSLog(@"Migrating old config item %@ to in app settings.",key);
|
||||
[self setObject:[oldconfig objectForKey:key] forKey:key];
|
||||
}
|
||||
[self synchronize];
|
||||
NSLog(@"Migration done");
|
||||
}
|
||||
|
||||
-(id) init{
|
||||
self = [super init];
|
||||
if (self){
|
||||
dict=[[NSMutableDictionary alloc] init];
|
||||
changedDict=[[NSMutableDictionary alloc] init];
|
||||
LinphoneCore *lc=[LinphoneManager getLc];
|
||||
if (lp_config_get_int(linphone_core_get_config(lc),"app","config_migrated",0)==0){
|
||||
[self handleMigration];
|
||||
lp_config_set_int(linphone_core_get_config(lc),"app","config_migrated",1);
|
||||
}
|
||||
[self transformLinphoneCoreToKeys];
|
||||
}
|
||||
return self;
|
||||
|
|
@ -57,6 +46,7 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
-(void) dealloc{
|
||||
[super dealloc];
|
||||
[dict release];
|
||||
[changedDict release];
|
||||
}
|
||||
|
||||
-(void) transformKeysToLinphoneCore{
|
||||
|
|
@ -79,7 +69,7 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
const MSList *elem=codecs;
|
||||
for(;elem!=NULL;elem=elem->next){
|
||||
PayloadType *pt=(PayloadType*)elem->data;
|
||||
NSString *pref=getPrefForCodec(pt->mime_type,pt->clock_rate);
|
||||
NSString *pref=[LinphoneManager getPrefForCodec:pt->mime_type withRate:pt->clock_rate];
|
||||
if (pref){
|
||||
[self setBool: linphone_core_payload_type_enabled(lc,pt) forKey: pref];
|
||||
}else{
|
||||
|
|
@ -163,7 +153,14 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
[self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","check_config_disable_preference",0) forKey:@"check_config_disable_preference"];
|
||||
[self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","wifi_only_preference",0) forKey:@"wifi_only_preference"];
|
||||
[self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","backgroundmode_preference",TRUE) forKey:@"backgroundmode_preference"];
|
||||
[self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","start_at_boot_preference",TRUE) forKey:@"disable_autoboot_preference"];
|
||||
/*keep this one also in the standardUserDefaults so that it can be read before starting liblinphone*/
|
||||
BOOL start_at_boot;
|
||||
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"start_at_boot_preference"]==Nil)
|
||||
start_at_boot=TRUE;
|
||||
else start_at_boot=[[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"];
|
||||
[self setBool: start_at_boot forKey:@"start_at_boot_preference"];
|
||||
|
||||
|
||||
|
||||
if (linphone_core_tunnel_available()){
|
||||
/*FIXME: enhance linphonecore API to handle tunnel more easily in applications */
|
||||
|
|
@ -178,30 +175,32 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
pol=linphone_core_get_video_policy(lc);
|
||||
[self setBool:(pol->automatically_accept && pol->automatically_initiate) forKey:@"start_video_preference"];
|
||||
}
|
||||
if (lp_config_get_int(linphone_core_get_config(lc),"app","debugenable_preference",0))
|
||||
linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler);
|
||||
|
||||
[changedDict release];
|
||||
changedDict=[[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
-(void) setObject:(id)value forKey:(NSString *)key {
|
||||
[dict setValue:value forKey:key];
|
||||
NSString *changed_value=[[NSString alloc] initWithFormat:@"%@_changed", key];
|
||||
[dict setValue:[NSNumber numberWithBool:TRUE] forKey:changed_value];
|
||||
[changed_value release];
|
||||
[changedDict setValue:[NSNumber numberWithBool:TRUE] forKey:key];
|
||||
}
|
||||
|
||||
- (id)objectForKey:(NSString*)key {
|
||||
return [dict valueForKey:key];
|
||||
}
|
||||
|
||||
- (BOOL)synchronize {
|
||||
- (BOOL)valueChangedForKey:(NSString*)key{
|
||||
return [ [changedDict valueForKey:key] boolValue];
|
||||
}
|
||||
|
||||
- (void) synchronizeAccount{
|
||||
LinphoneCore *lc=[LinphoneManager getLc];
|
||||
LinphoneManager* lLinphoneMgr = [LinphoneManager instance];
|
||||
|
||||
NSLog(@"Called in SettingsStore synchronize");
|
||||
if ([self boolForKey:@"username_preference_changed"])
|
||||
NSLog(@"username_preference_changed !!");
|
||||
return YES;
|
||||
LinphoneProxyConfig* proxyCfg=NULL;
|
||||
/* unregister before modifying any settings */
|
||||
{
|
||||
LinphoneProxyConfig* proxyCfg;
|
||||
linphone_core_get_default_proxy(lc, &proxyCfg);
|
||||
|
||||
if (proxyCfg) {
|
||||
|
|
@ -221,7 +220,7 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
|
||||
NSString* transport = [self stringForKey:@"transport_preference"];
|
||||
|
||||
LCSipTransports transportValue;
|
||||
LCSipTransports transportValue={0};
|
||||
if (transport!=nil) {
|
||||
if (linphone_core_get_sip_transports(lc, &transportValue)) {
|
||||
ms_error("cannot get current transport");
|
||||
|
|
@ -266,7 +265,7 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
const char* identity = [[NSString stringWithFormat:@"sip:%@@%@",username,domain] cStringUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
const char* password = [accountPassword cStringUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
|
||||
NSString* proxyAddress = [[NSUserDefaults standardUserDefaults] stringForKey:@"proxy_preference"];
|
||||
NSString* proxyAddress = [self stringForKey:@"proxy_preference"];
|
||||
if ((!proxyAddress || [proxyAddress length] <1 ) && domain) {
|
||||
proxyAddress = [NSString stringWithFormat:@"sip:%@",domain] ;
|
||||
} else {
|
||||
|
|
@ -275,10 +274,10 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
|
||||
const char* proxy = [proxyAddress cStringUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
|
||||
NSString* prefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"prefix_preference"];
|
||||
bool substitute_plus_by_00 = [[NSUserDefaults standardUserDefaults] boolForKey:@"substitute_+_by_00_preference"];
|
||||
NSString* prefix = [self stringForKey:@"prefix_preference"];
|
||||
bool substitute_plus_by_00 = [self boolForKey:@"substitute_+_by_00_preference"];
|
||||
//possible valid config detected
|
||||
LinphoneProxyConfig* proxyCfg;
|
||||
|
||||
proxyCfg = linphone_proxy_config_new();
|
||||
|
||||
// add username password
|
||||
|
|
@ -314,20 +313,41 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
//set to default proxy
|
||||
linphone_core_set_default_proxy(lc,proxyCfg);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)synchronize {
|
||||
LinphoneCore *lc=[LinphoneManager getLc];
|
||||
|
||||
if (lc==NULL) return YES;
|
||||
BOOL account_changed;
|
||||
|
||||
account_changed=[self valueChangedForKey:@"username_preference"]
|
||||
|| [self valueChangedForKey:@"password_preference"]
|
||||
|| [self valueChangedForKey:@"domain_preference"]
|
||||
|| [self valueChangedForKey:@"proxy_preference"]
|
||||
|| [self valueChangedForKey:@"outbound_proxy_preference"]
|
||||
|| [self valueChangedForKey:@"transport_preference"]
|
||||
|| [self valueChangedForKey:@"prefix_preference"]
|
||||
|| [self valueChangedForKey:@"substitute_+_by_00_preference"];
|
||||
|
||||
if (account_changed)
|
||||
[self synchronizeAccount];
|
||||
|
||||
//Configure Codecs
|
||||
|
||||
PayloadType *pt;
|
||||
const MSList *elem;
|
||||
//disable all codecs
|
||||
|
||||
for (elem=linphone_core_get_audio_codecs(lc);elem!=NULL;elem=elem->next){
|
||||
pt=(PayloadType*)elem->data;
|
||||
linphone_core_enable_payload_type(lc,pt,[self boolForKey: getPrefForCodec(pt->mime_type,pt->clock_rate)]);
|
||||
NSString *pref=[LinphoneManager getPrefForCodec:pt->mime_type withRate:pt->clock_rate];
|
||||
linphone_core_enable_payload_type(lc,pt,[self boolForKey: pref]);
|
||||
}
|
||||
for (elem=linphone_core_get_video_codecs(lc);elem!=NULL;elem=elem->next){
|
||||
pt=(PayloadType*)elem->data;
|
||||
linphone_core_enable_payload_type(lc,pt,[self boolForKey: getPrefForCodec(pt->mime_type,pt->clock_rate)]);
|
||||
NSString *pref=[LinphoneManager getPrefForCodec:pt->mime_type withRate:pt->clock_rate];
|
||||
linphone_core_enable_payload_type(lc,pt,[self boolForKey: pref]);
|
||||
}
|
||||
|
||||
bool enableVideo = [self boolForKey:@"enable_video_preference"];
|
||||
|
|
@ -364,7 +384,19 @@ static NSString *getPrefForCodec(const char *name, int rate){
|
|||
} else {
|
||||
isbackgroundModeEnabled=false;
|
||||
}
|
||||
lp_config_set_int(linphone_core_get_config(lc),"app","backgroundmode_preference",backgroundSupported);
|
||||
lp_config_set_int(linphone_core_get_config(lc),"app","backgroundmode_preference",isbackgroundModeEnabled);
|
||||
|
||||
BOOL debugmode=[self boolForKey:@"debugenable_preference"];
|
||||
lp_config_set_int(linphone_core_get_config(lc),"app","debugenable_preference",debugmode);
|
||||
if (debugmode) linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler);
|
||||
else linphone_core_disable_logs();
|
||||
|
||||
/*keep this one also in the standardUserDefaults so that it can be read before starting liblinphone*/
|
||||
BOOL start_at_boot=[self boolForKey:@"start_at_boot_preference"];
|
||||
[[NSUserDefaults standardUserDefaults] setBool: start_at_boot forKey:@"start_at_boot_preference"];
|
||||
|
||||
[changedDict release];
|
||||
changedDict=[[NSMutableDictionary alloc] init];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#import "LogView.h"
|
||||
#import "LinphoneUIDelegates.h"
|
||||
#import "IASKSettingsReader.h"
|
||||
#import "IASKSettingsStore.h"
|
||||
#import "IASKAppSettingsViewController.h"
|
||||
|
||||
typedef enum _Connectivity {
|
||||
|
|
@ -66,7 +67,7 @@ typedef struct _LinphoneCallAppData {
|
|||
FastAddressBook* mFastAddressBook;
|
||||
const char* frontCamId;
|
||||
const char* backCamId;
|
||||
|
||||
id<IASKSettingsStore> settingsStore;
|
||||
@public
|
||||
CallContext currentCallContextBeforeGoingBackground;
|
||||
}
|
||||
|
|
@ -75,6 +76,7 @@ typedef struct _LinphoneCallAppData {
|
|||
+(BOOL) runningOnIpad;
|
||||
+(void) set:(UIView*)view hidden: (BOOL) hidden withName:(const char*)name andReason:(const char*) reason;
|
||||
+(void) logUIElementPressed:(const char*) name;
|
||||
+ (NSString *) getPrefForCodec: (const char*) name withRate: (int) rate;
|
||||
|
||||
-(void) displayDialer;
|
||||
|
||||
|
|
@ -95,10 +97,11 @@ typedef struct _LinphoneCallAppData {
|
|||
|
||||
@property (nonatomic, retain) id<LinphoneUICallDelegate> callDelegate;
|
||||
@property (nonatomic, retain) id<LinphoneUIRegistrationDelegate> registrationDelegate;
|
||||
@property (nonatomic, retain) id<IASKSettingsStore> settingsStore;
|
||||
@property Connectivity connectivity;
|
||||
@property (nonatomic) int defaultExpires;
|
||||
@property (readonly) const char* frontCamId;
|
||||
@property (readonly) const char* backCamId;
|
||||
@property (nonatomic) bool isbackgroundModeEnabled;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,41 @@ extern void libmsbcg729_init();
|
|||
@synthesize connectivity;
|
||||
@synthesize frontCamId;
|
||||
@synthesize backCamId;
|
||||
@synthesize isbackgroundModeEnabled;
|
||||
@synthesize defaultExpires;
|
||||
@synthesize settingsStore;
|
||||
|
||||
struct codec_name_pref_table{
|
||||
const char *name;
|
||||
int rate;
|
||||
NSString *prefname;
|
||||
};
|
||||
|
||||
struct codec_name_pref_table codec_pref_table[]={
|
||||
{ "speex", 8000, @"speex_8k_preference" },
|
||||
{ "speex", 16000, @"speex_16k_preference" },
|
||||
{ "silk", 24000, @"silk_24k_preference" },
|
||||
{ "silk", 16000, @"silk_16k_preference" },
|
||||
{ "amr", 8000, @"amr_8k_preference" },
|
||||
{ "ilbc", 8000, @"ilbc_preference"},
|
||||
{ "pcmu", 8000, @"pcmu_preference"},
|
||||
{ "pcma", 8000, @"pcma_preference"},
|
||||
{ "g722", 8000, @"g722_preference"},
|
||||
{ "g729", 8000, @"g729_preference"},
|
||||
{ "mp4v-es", 90000, @"mp4v-es_preference"},
|
||||
{ "h264", 90000, @"h264_preference"},
|
||||
{ "vp8", 90000, @"vp8_preference"},
|
||||
{ NULL,0,Nil }
|
||||
};
|
||||
|
||||
+ (NSString *) getPrefForCodec: (const char*) name withRate: (int) rate{
|
||||
int i;
|
||||
for(i=0;codec_pref_table[i].name!=NULL;++i){
|
||||
if (strcasecmp(codec_pref_table[i].name,name)==0 && codec_pref_table[i].rate==rate)
|
||||
return codec_pref_table[i].prefname;
|
||||
}
|
||||
return Nil;
|
||||
}
|
||||
|
||||
|
||||
-(id) init {
|
||||
assert (!theLinphoneManager);
|
||||
|
|
@ -289,9 +322,12 @@ extern void libmsbcg729_init();
|
|||
}
|
||||
|
||||
+(LinphoneCore*) getLc {
|
||||
#if 0
|
||||
if (theLinphoneCore==nil) {
|
||||
@throw([NSException exceptionWithName:@"LinphoneCoreException" reason:@"Linphone core not initialized yet" userInfo:nil]);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
return theLinphoneCore;
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +338,7 @@ extern void libmsbcg729_init();
|
|||
[callDelegate displayStatus:message];
|
||||
}
|
||||
//generic log handler for debug version
|
||||
static void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){
|
||||
void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){
|
||||
NSString* format = [[NSString alloc] initWithCString:fmt encoding:[NSString defaultCStringEncoding]];
|
||||
NSLogv(format,args);
|
||||
NSString* formatedString = [[NSString alloc] initWithFormat:format arguments:args];
|
||||
|
|
@ -564,7 +600,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
linphone_core_get_default_proxy(theLinphoneCore, &proxyCfg);
|
||||
linphone_core_stop_dtmf_stream(theLinphoneCore);
|
||||
|
||||
if (isbackgroundModeEnabled && proxyCfg) {
|
||||
if (proxyCfg && lp_config_get_int(linphone_core_get_config(theLinphoneCore),"app","backgroundmode_preference",0)) {
|
||||
//For registration register
|
||||
linphone_core_refresh_registers(theLinphoneCore);
|
||||
|
||||
|
|
@ -595,10 +631,6 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
} else {
|
||||
ms_warning("keepalive handler cannot be registered");
|
||||
}
|
||||
LCSipTransports transportValue;
|
||||
if (linphone_core_get_sip_transports(theLinphoneCore, &transportValue)) {
|
||||
ms_error("cannot get current transport");
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
else {
|
||||
|
|
@ -820,7 +852,16 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
}
|
||||
|
||||
-(void) settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender {
|
||||
NSLog(@"settingsViewControllerDidEnd");
|
||||
}
|
||||
|
||||
-(BOOL) codecSupported:(NSString *) prefName{
|
||||
int i;
|
||||
for(i=0;codec_pref_table[i].name!=NULL;++i){
|
||||
if ([prefName compare:codec_pref_table[i].prefname]==0){
|
||||
return linphone_core_find_payload_type(theLinphoneCore,codec_pref_table[i].name, codec_pref_table[i].rate)!=NULL;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
-(NSDictionary*) filterPreferenceSpecifier:(NSDictionary *)specifier {
|
||||
|
|
@ -842,16 +883,11 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
return specifier;
|
||||
}
|
||||
// NSLog(@"Specifier received: %@", identifier);
|
||||
if ([identifier hasPrefix:@"silk"]) {
|
||||
if (linphone_core_find_payload_type(theLinphoneCore,"SILK",8000)==NULL){
|
||||
if ([identifier isEqualToString:@"silk_24k_preference"]) {
|
||||
if (![self isNotIphone3G])
|
||||
return nil;
|
||||
}
|
||||
if ([identifier isEqualToString:@"silk_24k_preference"]) {
|
||||
if (![self isNotIphone3G])
|
||||
return nil;
|
||||
}
|
||||
|
||||
} else if ([identifier isEqualToString:@"backgroundmode_preference"]) {
|
||||
}
|
||||
if ([identifier isEqualToString:@"backgroundmode_preference"]) {
|
||||
UIDevice* device = [UIDevice currentDevice];
|
||||
if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {
|
||||
if ([device isMultitaskingSupported]) {
|
||||
|
|
@ -861,6 +897,8 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
// hide setting if bg mode not supported
|
||||
return nil;
|
||||
}
|
||||
if (![self codecSupported:identifier])
|
||||
return Nil;
|
||||
return specifier;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,14 +129,12 @@
|
|||
|
||||
-(void) showPreview:(BOOL) show {
|
||||
LinphoneCore* lc;
|
||||
@try {
|
||||
lc = [LinphoneManager getLc];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool enableVideo = [[NSUserDefaults standardUserDefaults] boolForKey:@"enable_video_preference"];
|
||||
lc = [LinphoneManager getLc];
|
||||
|
||||
if (lc==NULL) return;
|
||||
|
||||
bool enableVideo = linphone_core_video_enabled(lc);
|
||||
|
||||
if (enableVideo) {
|
||||
LinphoneCall* call = linphone_core_get_current_call(lc);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#import "MoreViewController.h"
|
||||
#include "ConsoleViewController.h"
|
||||
#import "LinphoneManager.h"
|
||||
#include "lpconfig.h"
|
||||
|
||||
|
||||
@implementation MoreViewController
|
||||
|
|
@ -36,7 +37,7 @@
|
|||
[creditText setText: [NSString stringWithFormat:creditText.text,[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]];
|
||||
consoleViewController = [[ConsoleViewController alloc] initWithNibName:@"ConsoleViewController" bundle:[NSBundle mainBundle]];
|
||||
[[LinphoneManager instance] registerLogView:consoleViewController];
|
||||
isDebug = [[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"];
|
||||
isDebug = lp_config_get_int(linphone_core_get_config([LinphoneManager getLc]),"app","debugenable_preference",0);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,8 +101,9 @@
|
|||
}
|
||||
|
||||
-(void) updateCallAndBackButtons {
|
||||
@try {
|
||||
bool zeroCall = (linphone_core_get_calls_nb([LinphoneManager getLc]) == 0);
|
||||
LinphoneCore *lc=[LinphoneManager getLc];
|
||||
if (lc){
|
||||
bool zeroCall = (linphone_core_get_calls_nb(lc) == 0);
|
||||
|
||||
[LinphoneManager set:callLarge hidden:!zeroCall withName:"CALL_LARGE button" andReason:__FUNCTION__];
|
||||
[LinphoneManager set:switchCamera hidden:!zeroCall withName:"SWITCH_CAM button" andReason:__FUNCTION__];
|
||||
|
|
@ -112,14 +113,8 @@
|
|||
[callShort setTitle:[UICallButton transforModeEnabled] ? @"transfer":@"call" forState:UIControlStateNormal];
|
||||
|
||||
if (!callShort.hidden)
|
||||
[callShort setEnabled:!linphone_core_sound_resources_locked([LinphoneManager getLc])];
|
||||
} @catch (NSException* exc) {
|
||||
// R.A.S: linphone core si simply not ready...
|
||||
ms_warning("Catched exception %s: %s",
|
||||
[exc.name cStringUsingEncoding:[NSString defaultCStringEncoding]],
|
||||
[exc.reason cStringUsingEncoding:[NSString defaultCStringEncoding]]);
|
||||
}
|
||||
|
||||
[callShort setEnabled:!linphone_core_sound_resources_locked(lc)];
|
||||
}
|
||||
[self updateStatusSubView];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,21 +6,17 @@ mtu=1300
|
|||
|
||||
[sip]
|
||||
sip_random_port=1
|
||||
sip_port=5060
|
||||
sip_tcp_random_port=1
|
||||
sip_tcp_port=0
|
||||
sip_tls_random_port=1
|
||||
sip_tls_port=0
|
||||
guess_hostname=1
|
||||
contact=sip:toto@unknown-host
|
||||
inc_timeout=15
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
default_proxy=-1
|
||||
register_only_when_network_is_up=1
|
||||
auto_net_state_mon=0
|
||||
keepalive_period=30000
|
||||
media_encryption=zrtp
|
||||
|
||||
|
||||
[rtp]
|
||||
audio_rtp_port=7076
|
||||
|
|
|
|||
|
|
@ -6,17 +6,13 @@ mtu=1300
|
|||
|
||||
[sip]
|
||||
sip_random_port=1
|
||||
sip_port=5060
|
||||
sip_tcp_random_port=1
|
||||
sip_tcp_port=0
|
||||
sip_tls_random_port=1
|
||||
sip_tls_port=0
|
||||
guess_hostname=1
|
||||
contact=sip:toto@unknown-host
|
||||
inc_timeout=15
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
default_proxy=-1
|
||||
register_only_when_network_is_up=1
|
||||
auto_net_state_mon=0
|
||||
keepalive_period=30000
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit bad6c152f1521de8648d47c70e9321b7668b40b5
|
||||
Subproject commit 23d589cec01361b7c08528cd7433d5b01c0579bb
|
||||
Loading…
Add table
Reference in a new issue