mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 00:29:21 +00:00
Conflicts: Classes/AboutViewController.h Classes/ChatRoomTableViewController.h Classes/ChatRoomTableViewController.m Classes/ChatRoomViewController.h Classes/ChatRoomViewController.m Classes/ChatViewController.m Classes/ConsoleViewController.m Classes/ConsoleViewController.xib Classes/ContactDetailsLabelViewController.m Classes/ContactDetailsTableViewController.m Classes/ContactDetailsViewController.m Classes/ContactsViewController.m Classes/DialerViewController.m Classes/HistoryViewController.m Classes/ImagePickerViewController.h Classes/ImageViewController.h Classes/ImageViewController.m Classes/InCallTableViewController.m Classes/InCallViewController.m Classes/LinphoneCoreSettingsStore.m Classes/LinphoneUI/UICallBar.m Classes/LinphoneUI/UICallCell.h Classes/LinphoneUI/UICallCell.m Classes/LinphoneUI/UIChatCell.h Classes/LinphoneUI/UIChatCell.m Classes/LinphoneUI/UIChatCell.xib Classes/LinphoneUI/UIChatRoomCell.h Classes/LinphoneUI/UIChatRoomCell.m Classes/LinphoneUI/UIChatRoomCell.xib Classes/LinphoneUI/UICompositeViewController.h Classes/LinphoneUI/UIContactDetailsHeader.m Classes/LinphoneUI/UIHistoryCell.xib Classes/LinphoneUI/UIMainBar.m Classes/LinphoneUI/UIStateBar.xib Classes/LinphoneUI/en.lproj/UICallBar.xib Classes/LinphoneUI/en.lproj/UICallBar~ipad.xib Classes/LinphoneUI/en.lproj/UICallCell.xib Classes/LinphoneUI/en.lproj/UIConferenceHeader.xib Classes/LinphoneUI/en.lproj/UIContactDetailsFooter.xib Classes/LinphoneUI/en.lproj/UIContactDetailsHeader.xib Classes/LinphoneUI/en.lproj/UIMainBar.xib Classes/LinphoneUI/en.lproj/UIMainBar~ipad.xib Classes/LinphoneUI/fr.lproj/UICallBar.xib Classes/LinphoneUI/fr.lproj/UICallBar~ipad.xib Classes/LinphoneUI/fr.lproj/UICallCell.xib Classes/LinphoneUI/fr.lproj/UIConferenceHeader.xib Classes/LinphoneUI/fr.lproj/UIContactDetailsFooter.xib Classes/LinphoneUI/fr.lproj/UIContactDetailsHeader.xib Classes/LinphoneUI/fr.lproj/UIMainBar.xib Classes/LinphoneUI/fr.lproj/UIMainBar~ipad.xib Classes/Model/ChatModel.h Classes/Model/ChatModel.m Classes/PhoneMainView.h Classes/PhoneMainView.m Classes/PhoneMainView.xib Classes/SettingsViewController.m Classes/SettingsViewController.xib Classes/Utils/NinePatch/NinePatch.xcodeproj/project.pbxproj Classes/Utils/XMLRPC/XMLRPC.xcodeproj/project.pbxproj Classes/WizardViewController.h Classes/WizardViewController.m Classes/en.lproj/ChatRoomViewController.xib Classes/en.lproj/ChatViewController.xib Classes/en.lproj/ContactDetailsLabelViewController.xib Classes/en.lproj/ContactDetailsViewController.xib Classes/en.lproj/ContactsViewController.xib Classes/en.lproj/DialerViewController.xib Classes/en.lproj/DialerViewController~ipad.xib Classes/en.lproj/FirstLoginViewController.xib Classes/en.lproj/HistoryDetailsViewController.xib Classes/en.lproj/HistoryViewController.xib Classes/en.lproj/InCallViewController.xib Classes/en.lproj/IncomingCallViewController.xib Classes/en.lproj/WizardViewController.xib Classes/fr.lproj/ChatRoomViewController.xib Classes/fr.lproj/ChatViewController.xib Classes/fr.lproj/ContactDetailsLabelViewController.xib Classes/fr.lproj/ContactDetailsViewController.xib Classes/fr.lproj/ContactsViewController.xib Classes/fr.lproj/DialerViewController.xib Classes/fr.lproj/DialerViewController~ipad.xib Classes/fr.lproj/FirstLoginViewController.xib Classes/fr.lproj/HistoryDetailsViewController.xib Classes/fr.lproj/HistoryViewController.xib Classes/fr.lproj/InCallViewController.xib Classes/fr.lproj/IncomingCallViewController.xib Classes/fr.lproj/WizardViewController.xib README Resources/accept_default.png Resources/accept_over.png Resources/cancel_default.png Resources/cancel_over.png Resources/chat_add_default.png Resources/chat_add_over.png Resources/chat_back_default.png Resources/chat_back_over.png Resources/chat_default.png Resources/chat_default_landscape~ipad.png Resources/chat_default~ipad.png Resources/chat_edit_default.png Resources/chat_edit_over.png Resources/chat_message_delivered.png Resources/chat_message_inprogress.png Resources/chat_message_not_delivered.png Resources/chat_ok_default.png Resources/chat_ok_over.png Resources/chat_over.png Resources/chat_over_landscape~ipad.png Resources/chat_over~ipad.png Resources/chat_selected.png Resources/chat_selected_landscape~ipad.png Resources/chat_selected~ipad.png Resources/chat_send_default.png Resources/chat_send_disabled.png Resources/chat_send_over.png Resources/contact_back_default.png Resources/contact_back_over.png Resources/contact_cancel_default.png Resources/contact_cancel_over.png Resources/contact_edit_default.png Resources/contact_edit_over.png Resources/contact_ok_default.png Resources/contact_ok_disabled.png Resources/contact_ok_over.png Resources/contacts_add_default.png Resources/contacts_add_over.png Resources/contacts_all_default.png Resources/contacts_all_selected.png Resources/contacts_back_default.png Resources/contacts_back_over.png Resources/contacts_default.png Resources/contacts_default_landscape~ipad.png Resources/contacts_default~ipad.png Resources/contacts_linphone_default.png Resources/contacts_linphone_selected.png Resources/contacts_over.png Resources/contacts_over_landscape~ipad.png Resources/contacts_over~ipad.png Resources/contacts_selected.png Resources/contacts_selected_landscape~ipad.png Resources/contacts_selected~ipad.png Resources/decline_default.png Resources/decline_over.png Resources/dialer_address_background_landscape~ipad.png Resources/dialer_address_background~ipad.png Resources/dialer_default.png Resources/dialer_over.png Resources/dialer_selected.png Resources/en.lproj/Localizable.strings Resources/fr.lproj/Localizable.strings Resources/header_conference.png Resources/header_incoming.png Resources/history_all_default.png Resources/history_all_selected.png Resources/history_default.png Resources/history_default_landscape~ipad.png Resources/history_default~ipad.png Resources/history_details_add_default.png Resources/history_details_add_over.png Resources/history_details_back_default.png Resources/history_details_back_over.png Resources/history_edit_default.png Resources/history_edit_over.png Resources/history_missed_default.png Resources/history_missed_selected.png Resources/history_ok_default.png Resources/history_ok_over.png Resources/history_over.png Resources/history_over_landscape~ipad.png Resources/history_over~ipad.png Resources/history_selected.png Resources/history_selected_landscape~ipad.png Resources/history_selected~ipad.png Resources/linphonerc-factory Resources/linphonerc-factory~ipad Resources/micro_off_default.png Resources/micro_off_default_landscape.png Resources/micro_off_default_landscape~ipad.png Resources/micro_off_default~ipad.png Resources/micro_off_disabled.png Resources/micro_off_disabled_landscape.png Resources/micro_off_disabled_landscape~ipad.png Resources/micro_off_disabled~ipad.png Resources/micro_off_over.png Resources/micro_off_over_landscape.png Resources/micro_off_over_landscape~ipad.png Resources/micro_off_over~ipad.png Resources/micro_on_default.png Resources/micro_on_default_landscape.png Resources/micro_on_default_landscape~ipad.png Resources/micro_on_default~ipad.png Resources/micro_on_disabled.png Resources/micro_on_disabled_landscape.png Resources/micro_on_disabled_landscape~ipad.png Resources/micro_on_disabled~ipad.png Resources/micro_on_over.png Resources/micro_on_over_landscape.png Resources/micro_on_over_landscape~ipad.png Resources/micro_on_over~ipad.png Resources/options_add_default.png Resources/options_add_default_landscape.png Resources/options_add_default_landscape~ipad.png Resources/options_add_default~ipad.png Resources/options_add_disabled.png Resources/options_add_disabled_landscape.png Resources/options_add_disabled_landscape~ipad.png Resources/options_add_disabled~ipad.png Resources/options_add_over.png Resources/options_add_over_landscape.png Resources/options_add_over_landscape~ipad.png Resources/options_add_over~ipad.png Resources/options_default.png Resources/options_default_landscape.png Resources/options_default_landscape~ipad.png Resources/options_default~ipad.png Resources/options_disabled.png Resources/options_disabled_landscape.png Resources/options_disabled_landscape~ipad.png Resources/options_disabled~ipad.png Resources/options_over.png Resources/options_over_landscape.png Resources/options_over_landscape~ipad.png Resources/options_over~ipad.png Resources/options_selected.png Resources/options_selected_landscape.png Resources/options_selected_landscape~ipad.png Resources/options_selected~ipad.png Resources/options_transfer_default.png Resources/options_transfer_default_landscape.png Resources/options_transfer_default_landscape~ipad.png Resources/options_transfer_default~ipad.png Resources/options_transfer_disabled.png Resources/options_transfer_disabled_landscape.png Resources/options_transfer_disabled_landscape~ipad.png Resources/options_transfer_disabled~ipad.png Resources/options_transfer_over.png Resources/options_transfer_over_landscape.png Resources/options_transfer_over_landscape~ipad.png Resources/options_transfer_over~ipad.png Resources/settings_default.png Resources/settings_default_landscape~ipad.png Resources/settings_default~ipad.png Resources/settings_over.png Resources/settings_over_landscape~ipad.png Resources/settings_over~ipad.png Resources/settings_selected.png Resources/settings_selected_landscape~ipad.png Resources/settings_selected~ipad.png Resources/setup_back_default.png Resources/setup_back_disabled.png Resources/setup_back_over.png Resources/setup_cancel_default.png Resources/setup_cancel_disabled.png Resources/setup_cancel_over.png Resources/setup_start_default.png Resources/setup_start_disabled.png Resources/setup_start_over.png Resources/setup_welcome_logo.png Resources/speaker_off_default.png Resources/speaker_off_default_landscape.png Resources/speaker_off_default_landscape~ipad.png Resources/speaker_off_default~ipad.png Resources/speaker_off_disabled.png Resources/speaker_off_disabled_landscape.png Resources/speaker_off_disabled_landscape~ipad.png Resources/speaker_off_disabled~ipad.png Resources/speaker_off_over.png Resources/speaker_off_over_landscape.png Resources/speaker_off_over_landscape~ipad.png Resources/speaker_off_over~ipad.png Resources/speaker_on_default.png Resources/speaker_on_default_landscape.png Resources/speaker_on_default_landscape~ipad.png Resources/speaker_on_default~ipad.png Resources/speaker_on_disabled.png Resources/speaker_on_disabled_landscape.png Resources/speaker_on_disabled_landscape~ipad.png Resources/speaker_on_disabled~ipad.png Resources/speaker_on_over.png Resources/speaker_on_over_landscape.png Resources/speaker_on_over_landscape~ipad.png Resources/speaker_on_over~ipad.png Resources/switch_camera_default.png Resources/switch_camera_over.png Resources/toolsbar_background.png Resources/video_off_default.png Resources/video_off_default_landscape.png Resources/video_off_default_landscape~ipad.png Resources/video_off_default~ipad.png Resources/video_off_disabled.png Resources/video_off_disabled_landscape.png Resources/video_off_disabled_landscape~ipad.png Resources/video_off_disabled~ipad.png Resources/video_off_over.png Resources/video_off_over_landscape.png Resources/video_off_over_landscape~ipad.png Resources/video_off_over~ipad.png Resources/video_on_default.png Resources/video_on_default_landscape.png Resources/video_on_default_landscape~ipad.png Resources/video_on_default~ipad.png Resources/video_on_disabled.png Resources/video_on_disabled_landscape.png Resources/video_on_disabled_landscape~ipad.png Resources/video_on_disabled~ipad.png Resources/video_on_over.png Resources/video_on_over_landscape.png Resources/video_on_over_landscape~ipad.png Resources/video_on_over~ipad.png linphone-Info.plist linphone.ldb/Contents.plist linphone.ldb/Resources/Classes/ChatRoomViewController/37/ChatRoomViewController.xib linphone.ldb/Resources/Classes/ChatViewController/16/ChatViewController.xib linphone.ldb/Resources/Classes/ContactDetailsLabelViewController/4/ContactDetailsLabelViewController.xib linphone.ldb/Resources/Classes/ContactDetailsViewController/4/ContactDetailsViewController.xib linphone.ldb/Resources/Classes/ContactsViewController/13/ContactsViewController.xib linphone.ldb/Resources/Classes/DialerViewController/4/DialerViewController.xib linphone.ldb/Resources/Classes/DialerViewController~ipad/12/DialerViewController~ipad.xib linphone.ldb/Resources/Classes/FirstLoginViewController/5/FirstLoginViewController.xib linphone.ldb/Resources/Classes/HistoryDetailsViewController/5/HistoryDetailsViewController.xib linphone.ldb/Resources/Classes/HistoryViewController/12/HistoryViewController.xib linphone.ldb/Resources/Classes/InCallViewController/5/InCallViewController.xib linphone.ldb/Resources/Classes/IncomingCallViewController/6/IncomingCallViewController.xib linphone.ldb/Resources/Classes/WizardViews/17/WizardViews.xib linphone.ldb/Resources/LinphoneUI/UICallBar/9/UICallBar.xib linphone.ldb/Resources/LinphoneUI/UICallBar~ipad/7/UICallBar~ipad.xib linphone.ldb/Resources/LinphoneUI/UICallCell/9/UICallCell.xib linphone.ldb/Resources/LinphoneUI/UIContactDetailsFooter/3/UIContactDetailsFooter.xib linphone.ldb/Resources/LinphoneUI/UIContactDetailsHeader/4/UIContactDetailsHeader.xib linphone.ldb/Resources/LinphoneUI/UIMainBar/9/UIMainBar.xib linphone.ldb/Resources/LinphoneUI/UIMainBar~ipad/8/UIMainBar~ipad.xib linphone.ldb/Resources/Resources/Localizable/1/Localizable.strings linphone.xcodeproj/project.pbxproj
311 lines
13 KiB
Objective-C
311 lines
13 KiB
Objective-C
/* LinphoneAppDelegate.m
|
||
*
|
||
* Copyright (C) 2009 Belledonne Comunications, 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.
|
||
*/
|
||
|
||
#import "linphoneAppDelegate.h"
|
||
#import "AddressBook/ABPerson.h"
|
||
|
||
#import "BuschJaegerMainView.h"
|
||
#import "CoreTelephony/CTCallCenter.h"
|
||
#import "CoreTelephony/CTCall.h"
|
||
|
||
#include "LinphoneManager.h"
|
||
#include "linphonecore.h"
|
||
|
||
@implementation UILinphoneWindow
|
||
|
||
@end
|
||
|
||
@implementation LinphoneAppDelegate
|
||
|
||
@synthesize started;
|
||
|
||
|
||
#pragma mark - Lifecycle Functions
|
||
|
||
- (id)init {
|
||
self = [super init];
|
||
if(self != nil) {
|
||
self->started = FALSE;
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)dealloc {
|
||
[super dealloc];
|
||
}
|
||
|
||
|
||
#pragma mark -
|
||
|
||
- (void)handleGSMCallInteration: (id) cCenter {
|
||
CTCallCenter* ct = (CTCallCenter*) cCenter;
|
||
|
||
int callCount = [ct.currentCalls count];
|
||
/* pause current call, if any */
|
||
LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]);
|
||
if (callCount>0 && call) {
|
||
[LinphoneLogger logc:LinphoneLoggerLog format:"Pausing SIP call"];
|
||
linphone_core_pause_call([LinphoneManager getLc], call);
|
||
}
|
||
}
|
||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application{
|
||
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidEnterBackground"];
|
||
if(![LinphoneManager isLcReady]) return;
|
||
[[LinphoneManager instance] enterBackgroundMode];
|
||
}
|
||
|
||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationWillResignActive"];
|
||
if(![LinphoneManager isLcReady]) return;
|
||
LinphoneCore* lc = [LinphoneManager getLc];
|
||
LinphoneCall* call = linphone_core_get_current_call(lc);
|
||
|
||
|
||
if (call){
|
||
/* save call context */
|
||
LinphoneManager* instance = [LinphoneManager instance];
|
||
instance->currentCallContextBeforeGoingBackground.call = call;
|
||
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call);
|
||
|
||
const LinphoneCallParams* params = linphone_call_get_current_params(call);
|
||
if (linphone_call_params_video_enabled(params)) {
|
||
linphone_call_enable_camera(call, false);
|
||
}
|
||
}
|
||
|
||
if (![[LinphoneManager instance] resignActive]) {
|
||
// destroying eventHandler if app cannot go in background.
|
||
// Otherwise if a GSM call happen and Linphone is resumed,
|
||
// the handler will be called before LinphoneCore is built.
|
||
// Then handler will be restored in appDidBecomeActive cb
|
||
callCenter.callEventHandler = nil;
|
||
[callCenter release];
|
||
callCenter = nil;
|
||
}
|
||
|
||
}
|
||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidBecomeActive"];
|
||
[self startApplication];
|
||
|
||
[[LinphoneManager instance] becomeActive];
|
||
|
||
// check call state at startup
|
||
[self handleGSMCallInteration:callCenter];
|
||
|
||
LinphoneCore* lc = [LinphoneManager getLc];
|
||
LinphoneCall* call = linphone_core_get_current_call(lc);
|
||
|
||
if (call){
|
||
LinphoneManager* instance = [LinphoneManager instance];
|
||
if (call == instance->currentCallContextBeforeGoingBackground.call) {
|
||
const LinphoneCallParams* params = linphone_call_get_current_params(call);
|
||
if (linphone_call_params_video_enabled(params)) {
|
||
linphone_call_enable_camera(
|
||
call,
|
||
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled);
|
||
}
|
||
instance->currentCallContextBeforeGoingBackground.call = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
- (void)setupGSMInteraction {
|
||
if (callCenter == nil) {
|
||
callCenter = [[CTCallCenter alloc] init];
|
||
callCenter.callEventHandler = ^(CTCall* call) {
|
||
// post on main thread
|
||
[self performSelectorOnMainThread:@selector(handleGSMCallInteration:)
|
||
withObject:callCenter
|
||
waitUntilDone:YES];
|
||
};
|
||
}
|
||
}
|
||
|
||
/* MODIFICATION: Add default settings */
|
||
- (void) loadDefaultSettings {
|
||
NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
|
||
if(!settingsBundle) {
|
||
[LinphoneLogger log:LinphoneLoggerError format:@"Could not find Settings.bundle"];
|
||
return;
|
||
}
|
||
|
||
NSMutableDictionary *rootSettings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Root.plist"]];
|
||
NSMutableArray *preferences = [rootSettings objectForKey:@"PreferenceSpecifiers"];
|
||
NSMutableDictionary *defaultsToRegister = [[NSMutableDictionary alloc] initWithCapacity:[preferences count]];
|
||
|
||
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
||
// NSString *appDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
|
||
NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
|
||
// NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
|
||
|
||
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
|
||
@"YES", @"debugenable_preference",
|
||
@"YES", @"enable_video_preference",
|
||
@"YES", @"start_video_preference",
|
||
@"YES", @"h264_preference",
|
||
@"YES", @"vp8_preference",
|
||
@"NO", @"mpeg4_preference",
|
||
@"YES", @"pcmu_preference",
|
||
@"YES", @"pcma_preference",
|
||
@"tcp", @"transport_preference",
|
||
@"NO", @"enable_srtp_preference",
|
||
@"YES", @"backgroundmode_preference",
|
||
@"YES", @"outbound_proxy_preference",
|
||
@"ringtone_01_1600", @"ringtone_preference",
|
||
@"ringtone_01_1600", @"level_ringtone_preference",
|
||
@"NO", @"lockdoors_preference",
|
||
majorVersion, @"version_preference",
|
||
nil];
|
||
|
||
[defaultsToRegister addEntriesFromDictionary:appDefaults];
|
||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister];
|
||
[defaultsToRegister release];
|
||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||
|
||
[[NSUserDefaults standardUserDefaults] setValue:majorVersion forKey:@"version_preference"];
|
||
}
|
||
|
||
/**/
|
||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||
/* MODIFICATION: Add default settings */
|
||
[self loadDefaultSettings];
|
||
/**/
|
||
|
||
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge];
|
||
|
||
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
||
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
|
||
&& (![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"] ||
|
||
![[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"])) {
|
||
// autoboot disabled, doing nothing
|
||
return YES;
|
||
}
|
||
|
||
[self startApplication];
|
||
|
||
return YES;
|
||
}
|
||
|
||
- (void)startApplication {
|
||
// Restart Linphone Core if needed
|
||
if(![LinphoneManager isLcReady]) {
|
||
[[LinphoneManager instance] startLibLinphone];
|
||
}
|
||
if([LinphoneManager isLcReady]) {
|
||
[self setupGSMInteraction];
|
||
|
||
// Only execute one time at application start
|
||
if(!started) {
|
||
started = TRUE;
|
||
/* MODIFICATION: Change Main View
|
||
[[PhoneMainView instance] startUp];
|
||
*/
|
||
[window setRootViewController:[[[BuschJaegerMainView alloc] initWithNibName:@"BuschJaegerMainView" bundle:[NSBundle mainBundle]] autorelease]];
|
||
/**/
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||
}
|
||
|
||
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
|
||
[self startApplication];
|
||
if([LinphoneManager isLcReady]) {
|
||
if([[url scheme] isEqualToString:@"sip"]) {
|
||
/* MODIFICATION: Remove URL handling
|
||
// Go to ChatRoom view
|
||
DialerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[DialerViewController compositeViewDescription]], DialerViewController);
|
||
if(controller != nil) {
|
||
[controller setAddress:[url absoluteString]];
|
||
}
|
||
*/
|
||
}
|
||
}
|
||
return YES;
|
||
}
|
||
|
||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
||
[LinphoneLogger log:LinphoneLoggerDebug format:@"PushNotification: Receive %@", userInfo];
|
||
/* MODIFICATION: Remove remote notification
|
||
NSDictionary *aps = [userInfo objectForKey:@"aps"];
|
||
if(aps != nil) {
|
||
NSDictionary *alert = [aps objectForKey:@"alert"];
|
||
if(alert != nil) {
|
||
NSString *loc_key = [alert objectForKey:@"loc-key"];
|
||
//if we receive a remote notification, it is because our TCP background socket was no more working.
|
||
//As a result, break it and refresh registers in order to make sure to receive incoming INVITE or MESSAGE
|
||
LinphoneCore *lc = [LinphoneManager getLc];
|
||
linphone_core_set_network_reachable(lc, FALSE);
|
||
linphone_core_set_network_reachable(lc, TRUE);
|
||
if(loc_key != nil) {
|
||
if([loc_key isEqualToString:@"IM_MSG"]) {
|
||
[[PhoneMainView instance] addInhibitedEvent:kLinphoneTextReceived];
|
||
[[PhoneMainView instance] changeCurrentView:[ChatViewController compositeViewDescription]];
|
||
} else if([loc_key isEqualToString:@"IC_MSG"]) {
|
||
//it's a call
|
||
[[LinphoneManager instance] didReceiveRemoteNotification];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
}
|
||
|
||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||
if([notification.userInfo objectForKey:@"call"] != nil) {
|
||
LinphoneCall* call;
|
||
[(NSData*)[notification.userInfo objectForKey:@"call"] getBytes:&call];
|
||
if (!call) {
|
||
[LinphoneLogger logc:LinphoneLoggerWarning format:"Local notification received with nil call"];
|
||
return;
|
||
}
|
||
linphone_core_accept_call([LinphoneManager getLc], call);
|
||
} else if([notification.userInfo objectForKey:@"chat"] != nil) {
|
||
/* MODIFICATION: Remove chat local notificaiton
|
||
NSString *remoteContact = (NSString*)[notification.userInfo objectForKey:@"chat"];
|
||
// Go to ChatRoom view
|
||
[[PhoneMainView instance] changeCurrentView:[ChatViewController compositeViewDescription]];
|
||
ChatRoomViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ChatRoomViewController compositeViewDescription] push:TRUE], ChatRoomViewController);
|
||
if(controller != nil) {
|
||
[controller setRemoteAddress:remoteContact];
|
||
}
|
||
*/
|
||
}
|
||
}
|
||
|
||
|
||
#pragma mark - PushNotification Functions
|
||
|
||
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
|
||
[LinphoneLogger log:LinphoneLoggerLog format:@"PushNotification: Token %@", deviceToken];
|
||
[[LinphoneManager instance] setPushNotificationToken:deviceToken];
|
||
}
|
||
|
||
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
|
||
[LinphoneLogger log:LinphoneLoggerError format:@"PushNotification: Error %@", [error localizedDescription]];
|
||
[[LinphoneManager instance] setPushNotificationToken:nil];
|
||
}
|
||
|
||
@end
|