forked from mirrors/linphone-iphone
Merge branch 'new_ui' of git://git.linphone.org/linphone-iphone into castel
Conflicts: Classes/LinphoneManager.h Classes/LinphoneManager.m
This commit is contained in:
commit
7575296518
10 changed files with 103 additions and 33 deletions
|
|
@ -62,7 +62,11 @@
|
|||
- (void)initContactDetailsTableViewController {
|
||||
dataCache = [[NSMutableArray alloc] init];
|
||||
labelArray = [[NSMutableArray alloc] initWithObjects:
|
||||
/* MODIFICATION use sip label
|
||||
@"Linphone",
|
||||
*/
|
||||
@"SIP",
|
||||
/**/
|
||||
[NSString stringWithString:(NSString*)kABPersonPhoneMobileLabel],
|
||||
[NSString stringWithString:(NSString*)kABPersonPhoneIPhoneLabel],
|
||||
[NSString stringWithString:(NSString*)kABPersonPhoneMainLabel], nil];
|
||||
|
|
@ -664,7 +668,11 @@
|
|||
CFRelease(lcMap);
|
||||
int index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]);
|
||||
CFStringRef keys[] = { kABPersonInstantMessageUsernameKey, kABPersonInstantMessageServiceKey};
|
||||
CFTypeRef values[] = { [value copy], CONTACT_SIP_FIELD };
|
||||
/* MODIFICATION prefix with sip:
|
||||
CFTypeRef values[] = { [value copy], CONTACT_SIP_FIELD };
|
||||
*/
|
||||
CFTypeRef values[] = { [FastAddressBook normalizeSipURI:value], CONTACT_SIP_FIELD };
|
||||
/**/
|
||||
CFDictionaryRef lDict = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, NULL, NULL);
|
||||
ABMultiValueReplaceValueAtIndex(lMap, lDict, index);
|
||||
CFRelease(lDict);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#import "CoreTelephony/CTCall.h"
|
||||
|
||||
#import "ConsoleViewController.h"
|
||||
#import "MoreViewController.h"
|
||||
#import "LinphoneCoreSettingsStore.h"
|
||||
|
||||
#include "LinphoneManager.h"
|
||||
|
|
@ -118,7 +117,8 @@ int __aeabi_idiv(int a, int b) {
|
|||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
||||
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
|
||||
&& ![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"]) {
|
||||
&& (![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"] ||
|
||||
![[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"])) {
|
||||
// autoboot disabled, doing nothing
|
||||
return;
|
||||
}
|
||||
|
|
@ -200,7 +200,8 @@ int __aeabi_idiv(int a, int b) {
|
|||
|
||||
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
||||
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
|
||||
&& ![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"]) {
|
||||
&& (![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"] ||
|
||||
![[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"])) {
|
||||
// autoboot disabled, doing nothing
|
||||
} else {
|
||||
[self startApplication];
|
||||
|
|
@ -229,6 +230,10 @@ int __aeabi_idiv(int a, int b) {
|
|||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
||||
//NSLog(@"%@", userInfo);
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||
if([notification.userInfo objectForKey:@"call"] != nil) {
|
||||
LinphoneCall* call;
|
||||
|
|
@ -248,4 +253,18 @@ int __aeabi_idiv(int a, int b) {
|
|||
} */
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - PushNotification Functions
|
||||
|
||||
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
|
||||
[LinphoneLogger log:LinphoneLoggerDebug format:@"PushNotification: Token %@", deviceToken];
|
||||
//NSLog(@"%@", deviceToken);
|
||||
[[LinphoneManager instance] setPushNotificationToken:deviceToken];
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
|
||||
[LinphoneLogger log:LinphoneLoggerDebug format:@"PushNotification: Error %@", error];
|
||||
[[LinphoneManager instance] setPushNotificationToken:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
NSDictionary *changedDict;
|
||||
}
|
||||
|
||||
-(void) transformLinphoneCoreToKeys;
|
||||
- (void)synchronizeAccount;
|
||||
- (void)transformLinphoneCoreToKeys;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -182,12 +182,16 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
[self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","debugenable_preference", 0) forKey:@"debugenable_preference"];
|
||||
[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"];
|
||||
|
||||
/*keep this one also in the standardUserDefaults so that it can be read before starting liblinphone*/
|
||||
BOOL start_at_boot = TRUE;
|
||||
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"start_at_boot_preference"]!=Nil)
|
||||
start_at_boot=[[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"];
|
||||
start_at_boot = [[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"];
|
||||
[self setBool: start_at_boot forKey:@"start_at_boot_preference"];
|
||||
BOOL background_mode = TRUE;
|
||||
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"backgroundmode_preference"]!=Nil)
|
||||
background_mode =[[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"];
|
||||
[self setBool: background_mode forKey:@"backgroundmode_preference"];
|
||||
|
||||
if (linphone_core_tunnel_available()){
|
||||
/*FIXME: enhance linphonecore API to handle tunnel more easily in applications */
|
||||
|
|
@ -349,7 +353,19 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix cStringUsingEncoding:[NSString defaultCStringEncoding]]);
|
||||
}
|
||||
linphone_proxy_config_set_dial_escape_plus(proxyCfg,substitute_plus_by_00);
|
||||
|
||||
|
||||
//Add custom parameter
|
||||
NSData *tokenData = [[LinphoneManager instance] pushNotificationToken];
|
||||
if(tokenData != nil) {
|
||||
const unsigned char *tokenBuffer = [tokenData bytes];
|
||||
NSMutableString *tokenString = [NSMutableString stringWithCapacity:[tokenData length]*2];
|
||||
for(int i = 0; i < [tokenData length]; ++i) {
|
||||
[tokenString appendFormat:@"%02X", (unsigned int)tokenBuffer[i]];
|
||||
}
|
||||
linphone_proxy_config_set_contact_parameters(proxyCfg, [[NSString stringWithFormat:@"APN=%@", tokenString] UTF8String]);
|
||||
}
|
||||
|
||||
|
||||
linphone_core_add_proxy_config(lc,proxyCfg);
|
||||
//set to default proxy
|
||||
linphone_core_set_default_proxy(lc,proxyCfg);
|
||||
|
|
@ -463,7 +479,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
/*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"];
|
||||
|
||||
BOOL background_mode = [self boolForKey:@"backgroundmode_preference"];
|
||||
[[NSUserDefaults standardUserDefaults] setBool: background_mode forKey:@"backgroundmode_preference"];
|
||||
|
||||
// Force synchronize
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ typedef struct _LinphoneCallAppData {
|
|||
@property (readonly) const char* frontCamId;
|
||||
@property (readonly) const char* backCamId;
|
||||
@property (readonly) sqlite3* database;
|
||||
@property (nonatomic, retain) NSData *pushNotificationToken;
|
||||
@property (readonly) NSDictionary* castelCommands;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ extern void libmsbcg729_init();
|
|||
@synthesize settingsStore;
|
||||
@synthesize database;
|
||||
@synthesize fastAddressBook;
|
||||
@synthesize pushNotificationToken;
|
||||
@synthesize castelCommands;
|
||||
|
||||
struct codec_name_pref_table{
|
||||
|
|
@ -743,15 +744,10 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
}
|
||||
|
||||
- (void)becomeActive {
|
||||
if (theLinphoneCore == nil) {
|
||||
//back from standby and background mode is disabled
|
||||
[self startLibLinphone];
|
||||
} else {
|
||||
[self refreshRegisters];
|
||||
}
|
||||
[self refreshRegisters];
|
||||
|
||||
/*IOS specific*/
|
||||
linphone_core_start_dtmf_stream(theLinphoneCore);
|
||||
|
||||
}
|
||||
|
||||
- (void)beginInterruption {
|
||||
|
|
@ -804,16 +800,17 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
}
|
||||
|
||||
- (BOOL)isSpeakerEnabled {
|
||||
bool enabled = false;
|
||||
CFStringRef lNewRoute = CFSTR("Unknown");
|
||||
UInt32 lNewRouteSize = sizeof(lNewRoute);
|
||||
OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &lNewRouteSize, &lNewRoute);
|
||||
if (!lStatus && lNewRouteSize > 0) {
|
||||
NSString *route = (NSString *) lNewRoute;
|
||||
[LinphoneLogger logc:LinphoneLoggerLog format:"Current audio route is [%s]", [route cStringUsingEncoding:[NSString defaultCStringEncoding]]];
|
||||
return [route isEqualToString: @"Speaker"] || [route isEqualToString: @"SpeakerAndMicrophone"];
|
||||
} else {
|
||||
return false;
|
||||
enabled = [route isEqualToString: @"Speaker"] || [route isEqualToString: @"SpeakerAndMicrophone"];
|
||||
CFRelease(lNewRoute);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -889,4 +886,24 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
linphone_call_params_destroy(lcallParams);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Property Functions
|
||||
|
||||
- (void)setPushNotificationToken:(NSData *)apushNotificationToken {
|
||||
if(apushNotificationToken == pushNotificationToken) {
|
||||
return;
|
||||
}
|
||||
if(pushNotificationToken != nil) {
|
||||
[pushNotificationToken release];
|
||||
pushNotificationToken = nil;
|
||||
}
|
||||
|
||||
if(apushNotificationToken != nil) {
|
||||
pushNotificationToken = [apushNotificationToken retain];
|
||||
}
|
||||
if([LinphoneManager isLcReady]) {
|
||||
[(LinphoneCoreSettingsStore*)settingsStore synchronizeAccount];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[hiddenKeys removeObject:@"video_menu"];
|
||||
}
|
||||
[settingsController setHiddenKeys:hiddenKeys animated:TRUE];
|
||||
}else if([@"random_port_preference" compare: notif.object] == NSOrderedSame) {
|
||||
} else if ([@"random_port_preference" compare: notif.object] == NSOrderedSame) {
|
||||
BOOL enable = [[notif.userInfo objectForKey:@"random_port_preference"] boolValue];
|
||||
NSMutableSet *hiddenKeys = [NSMutableSet setWithSet:[settingsController hiddenKeys]];
|
||||
if(enable) {
|
||||
|
|
@ -430,6 +430,15 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[hiddenKeys removeObject:@"port_preference"];
|
||||
}
|
||||
[settingsController setHiddenKeys:hiddenKeys animated:TRUE];
|
||||
} else if ([@"backgroundmode_preference" compare: notif.object] == NSOrderedSame) {
|
||||
BOOL enable = [[notif.userInfo objectForKey:@"backgroundmode_preference"] boolValue];
|
||||
NSMutableSet *hiddenKeys = [NSMutableSet setWithSet:[settingsController hiddenKeys]];
|
||||
if(!enable) {
|
||||
[hiddenKeys addObject:@"start_at_boot_preference"];
|
||||
} else {
|
||||
[hiddenKeys removeObject:@"start_at_boot_preference"];
|
||||
}
|
||||
[settingsController setHiddenKeys:hiddenKeys animated:TRUE];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -454,6 +463,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
UIDevice* device = [UIDevice currentDevice];
|
||||
if (![device respondsToSelector:@selector(isMultitaskingSupported)] || ![device isMultitaskingSupported]) {
|
||||
[hiddenKeys addObject:@"backgroundmode_preference"];
|
||||
[hiddenKeys addObject:@"start_at_boot_preference"];
|
||||
} else {
|
||||
if(![[[[LinphoneManager instance] settingsStore] objectForKey:@"backgroundmode_preference"] boolValue]) {
|
||||
[hiddenKeys addObject:@"start_at_boot_preference"];
|
||||
}
|
||||
}
|
||||
|
||||
[hiddenKeys addObject:@"enable_first_login_view_preference"];
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
+ (NSString*)normalizeSipURI:(NSString*)address {
|
||||
NSString* ret = address;
|
||||
if(![address hasPrefix:@"sip:"]) {
|
||||
if([address rangeOfString:@"@"].location != NSNotFound && ![address hasPrefix:@"sip:"]) {
|
||||
ret = [@"sip:" stringByAppendingString:ret];
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@
|
|||
<key>DefaultValue</key>
|
||||
<true/>
|
||||
<key>Key</key>
|
||||
<string>start_at_boot_preference</string>
|
||||
<string>backgroundmode_preference</string>
|
||||
<key>Title</key>
|
||||
<string>Start at boot</string>
|
||||
<string>Background mode</string>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
</dict>
|
||||
|
|
@ -50,9 +50,9 @@
|
|||
<key>DefaultValue</key>
|
||||
<true/>
|
||||
<key>Key</key>
|
||||
<string>backgroundmode_preference</string>
|
||||
<string>start_at_boot_preference</string>
|
||||
<key>Title</key>
|
||||
<string>Background mode</string>
|
||||
<string>Start at boot</string>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
</dict>
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>get-task-allow</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
Loading…
Add table
Reference in a new issue