forked from mirrors/linphone-iphone
Conflicts: Classes/ChatRoomViewController.m Classes/ContactsViewController.m Classes/HistoryDetailsViewController.h Classes/HistoryDetailsViewController.m Classes/LinphoneCoreSettingsStore.m Classes/LinphoneManager.m Classes/LinphoneUI/UIChatCell.m Classes/LinphoneUI/UIChatCell.xib Classes/LinphoneUI/UICompositeViewController.h Classes/LinphoneUI/UICompositeViewController.m Classes/PhoneMainView.m Classes/SettingsViewController.m Classes/WizardViewController.m Classes/en.lproj/ChatViewController.xib Classes/en.lproj/ContactDetailsViewController.xib Classes/en.lproj/DialerViewController.xib Classes/en.lproj/FirstLoginViewController.xib Classes/en.lproj/HistoryDetailsViewController.xib Classes/fr.lproj/ChatRoomViewController.xib Classes/fr.lproj/ChatViewController.xib Classes/fr.lproj/ContactDetailsViewController.xib Classes/fr.lproj/DialerViewController.xib Classes/fr.lproj/FirstLoginViewController.xib Classes/fr.lproj/HistoryDetailsViewController.xib Resources/en.lproj/Localizable.strings Resources/fr.lproj/Localizable.strings Resources/linphonerc-factory Resources/linphonerc-factory~ipad Settings.bundle/Advanced.plist Settings/InAppSettings.bundle/Advanced.plist Settings/InAppSettings.bundle/Call.plist Settings/InAppSettings.bundle/en.lproj/Audio.strings Settings/InAppSettings.bundle/en.lproj/Call.strings Settings/InAppSettings.bundle/en.lproj/Root.strings Settings/InAppSettings.bundle/fr.lproj/Audio.strings Settings/InAppSettings.bundle/fr.lproj/Call.strings Settings/InAppSettings.bundle/fr.lproj/Video.strings linphone-Info.plist linphone.ldb/Contents.plist linphone.ldb/Resources/Classes/ChatViewController/17/ChatViewController.xib linphone.ldb/Resources/Classes/ContactDetailsViewController/5/ContactDetailsViewController.xib linphone.ldb/Resources/Classes/DialerViewController/6/DialerViewController.xib linphone.ldb/Resources/Classes/FirstLoginViewController/6/FirstLoginViewController.xib linphone.ldb/Resources/Classes/HistoryDetailsViewController/8/HistoryDetailsViewController.xib linphone.ldb/Resources/InAppSettings.bundle/Audio/1/Audio.strings linphone.ldb/Resources/InAppSettings.bundle/Call/1/Call.strings linphone.ldb/Resources/InAppSettings.bundle/Network/1/Network.strings linphone.ldb/Resources/InAppSettings.bundle/Root/1/Root.strings linphone.ldb/Resources/Resources/Localizable/1/Localizable.strings linphone.xcodeproj/project.pbxproj submodules/linphone
247 lines
8 KiB
Objective-C
247 lines
8 KiB
Objective-C
/* BuschJaegerMainView.m
|
|
*
|
|
* Copyright (C) 2011 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 "BuschJaegerMainView.h"
|
|
|
|
@implementation UINavigationControllerEx
|
|
|
|
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
[viewController view];
|
|
UIViewController *oldTopViewController = self.topViewController;
|
|
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
|
[oldTopViewController viewWillDisappear:animated];
|
|
}
|
|
[viewController viewWillAppear:animated];
|
|
[super pushViewController:viewController animated:animated];
|
|
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
|
[self.topViewController viewDidAppear:animated];
|
|
[oldTopViewController viewDidDisappear:animated];
|
|
}
|
|
}
|
|
|
|
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
|
|
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
|
[self.topViewController viewWillDisappear:animated];
|
|
UIViewController *nextView = nil;
|
|
int count = [self.viewControllers count];
|
|
if(count > 1) {
|
|
nextView = [self.viewControllers objectAtIndex:count - 2];
|
|
}
|
|
[nextView viewWillAppear:animated];
|
|
}
|
|
UIViewController * ret = [super popViewControllerAnimated:animated];
|
|
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
|
[ret viewDidDisappear:animated];
|
|
[self.topViewController viewDidAppear:animated];
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation BuschJaegerMainView
|
|
|
|
@synthesize navigationController;
|
|
@synthesize callView;
|
|
@synthesize settingsView;
|
|
@synthesize manualSettingsView;
|
|
@synthesize welcomeView;
|
|
@synthesize historyView;
|
|
@synthesize historyDetailsView;
|
|
|
|
static BuschJaegerMainView* mainViewInstance=nil;
|
|
|
|
|
|
|
|
#pragma mark - Lifecycle Functions
|
|
|
|
- (void)initBuschJaegerMainView {
|
|
assert (!mainViewInstance);
|
|
mainViewInstance = self;
|
|
}
|
|
|
|
- (id)init {
|
|
self = [super init];
|
|
if (self) {
|
|
[self initBuschJaegerMainView];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
if (self) {
|
|
[self initBuschJaegerMainView];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (id)initWithCoder:(NSCoder *)decoder {
|
|
self = [super initWithCoder:decoder];
|
|
if (self) {
|
|
[self initBuschJaegerMainView];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)dealloc {
|
|
[navigationController release];
|
|
[callView release];
|
|
[settingsView release];
|
|
[manualSettingsView release];
|
|
[welcomeView release];
|
|
[historyView release];
|
|
[historyDetailsView release];
|
|
|
|
// Remove all observer
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
#pragma mark - ViewController Functions
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self setWantsFullScreenLayout:TRUE];
|
|
|
|
UIView *view = navigationController.view;
|
|
[view setFrame:[self.view bounds]];
|
|
[self.view addSubview:view];
|
|
[navigationController pushViewController:welcomeView animated:FALSE];
|
|
}
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
[super viewWillAppear:animated];
|
|
|
|
// Set observer
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
selector:@selector(callUpdateEvent:)
|
|
name:kLinphoneCallUpdate
|
|
object:nil];
|
|
|
|
// Set observer
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
selector:@selector(textReceivedEvent:)
|
|
name:kLinphoneTextReceived
|
|
object:nil];
|
|
}
|
|
|
|
- (void)vieWillDisappear:(BOOL)animated{
|
|
[super viewWillDisappear:animated];
|
|
|
|
// Remove observer
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
|
name:kLinphoneCallUpdate
|
|
object:nil];
|
|
|
|
// Remove observer
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
|
name:kLinphoneTextReceived
|
|
object:nil];
|
|
}
|
|
|
|
- (NSUInteger)supportedInterfaceOrientations {
|
|
return UIInterfaceOrientationMaskPortraitUpsideDown | UIInterfaceOrientationMaskPortrait;
|
|
}
|
|
|
|
|
|
#pragma mark - Event Functions
|
|
|
|
- (void)callUpdateEvent: (NSNotification*) notif {
|
|
LinphoneCall *call = [[notif.userInfo objectForKey: @"call"] pointerValue];
|
|
LinphoneCallState state = [[notif.userInfo objectForKey: @"state"] intValue];
|
|
[self callUpdate:call state:state animated:TRUE];
|
|
}
|
|
|
|
|
|
- (void)textReceivedEvent: (NSNotification*) notif {
|
|
[self displayMessage:notif];
|
|
}
|
|
|
|
|
|
#pragma mark -
|
|
|
|
- (void)callUpdate:(LinphoneCall *)call state:(LinphoneCallState)state animated:(BOOL)animated {
|
|
// Fake call update
|
|
if(call == NULL) {
|
|
return;
|
|
}
|
|
|
|
switch (state) {
|
|
case LinphoneCallIncomingReceived:
|
|
{
|
|
[self displayIncomingCall:call];
|
|
}
|
|
case LinphoneCallOutgoingInit:
|
|
{
|
|
linphone_call_enable_camera(call, FALSE);
|
|
}
|
|
case LinphoneCallPausedByRemote:
|
|
case LinphoneCallConnected:
|
|
case LinphoneCallUpdating:
|
|
{
|
|
[navigationController popToViewController:welcomeView animated:FALSE];
|
|
[navigationController pushViewController:callView animated:FALSE]; // No animation... Come back when Apple have learned how to create a good framework
|
|
break;
|
|
}
|
|
case LinphoneCallError:
|
|
case LinphoneCallEnd:
|
|
{
|
|
if ((linphone_core_get_calls([LinphoneManager getLc]) == NULL)) {
|
|
[navigationController popToViewController:welcomeView animated:FALSE]; // No animation... Come back when Apple have learned how to create a good framework
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
- (void)displayIncomingCall:(LinphoneCall *)call {
|
|
if (![[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
|
|| [UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
|
|
[[LinphoneManager instance] setSpeakerEnabled:TRUE];
|
|
AudioServicesPlaySystemSound([LinphoneManager instance].sounds.call);
|
|
}
|
|
}
|
|
|
|
- (void)displayMessage:(id)message {
|
|
if (![[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
|
|| [UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
|
|
UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Dring !",nil)
|
|
message: [NSString stringWithFormat:NSLocalizedString(@"%@ ring!",nil), [LinphoneManager instance].configuration.levelPushButton.name]
|
|
delegate:nil
|
|
cancelButtonTitle:NSLocalizedString(@"Continue",nil)
|
|
otherButtonTitles:nil,nil];
|
|
[error show];
|
|
[error release];
|
|
[[LinphoneManager instance] setSpeakerEnabled:TRUE];
|
|
AudioServicesPlayAlertSound([LinphoneManager instance].sounds.level);
|
|
}
|
|
}
|
|
|
|
+ (BuschJaegerMainView *) instance {
|
|
return mainViewInstance;
|
|
}
|
|
|
|
|
|
@end
|