Commit ecaa3952 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk

create account: link to new lrc

Change-Id: I08b578cc29f0fc8f664763b3aeecb8406a6aa328
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent c2531e60
......@@ -176,7 +176,9 @@ SET(ringclient_CONTROLLERS
src/MessagesVC.mm
src/PasswordChangeWC.h
src/PasswordChangeWC.mm
src/LrcModelsSProtocol.h
src/LrcModelsProtocol.h
src/AddSIPAccountVC.mm
src/AddSIPAccountVC.h
)
SET(ringclient_BACKENDS
......@@ -276,6 +278,7 @@ SET(ringclient_XIBS
AccBannedContacts
PasswordChange
MessageCells
AddSIPAccountVC
)
# Icons
......
......@@ -18,7 +18,8 @@
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsProtocol.h"
@interface AccountsVC : NSViewController <NSOutlineViewDelegate, NSMenuDelegate>
@interface AccountsVC : NSViewController <NSOutlineViewDelegate, NSMenuDelegate, LrcModelsProtocol>
@end
\ No newline at end of file
@end
......@@ -95,6 +95,8 @@ NSInteger const TAG_TYPE = 400;
QMetaObject::Connection accountChangedConnection, selectedAccountChangedConnection, accountTypeChangedConnection;
@synthesize accountModel;
- (void)loadView {
[super loadView];
......@@ -182,6 +184,15 @@ QMetaObject::Connection accountChangedConnection, selectedAccountChangedConnecti
[self.bannedListTabItem setView:self.bannedContactsVC.view];
}
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(lrc::api::NewAccountModel*) accountModel
{
if (self = [self initWithNibName: nibNameOrNil bundle:nibBundleOrNil])
{
self.accountModel= accountModel;
}
return self;
}
- (void) setupSIPPanels
{
// Start by removing all tabs
......@@ -404,17 +415,10 @@ QMetaObject::Connection accountChangedConnection, selectedAccountChangedConnecti
- (IBAction)addAccountClicked:(NSButton *)sender
{
NSMenu* menu = [[NSMenu alloc] init];
[menu insertItemWithTitle:NSLocalizedString(@"Create RING Account", @"Contextual menu entry")
action:@selector(createRingAccount:)
keyEquivalent:@""
atIndex:0];
[menu insertItemWithTitle:NSLocalizedString(@"Create SIP Account", @"Contextual menu entry")
action:@selector(createSIPAccount:)
keyEquivalent:@""
atIndex:0];
[NSMenu popUpContextMenu:menu withEvent:[self forgedEventForButton:sender] forView:(NSButton *)sender];
wizard = [[RingWizardWC alloc] initWithNibName:@"RingWizard" bundle: nil accountmodel: self.accountModel];
[wizard showChooseWithCancelButton: YES andAdvanced: YES];
[self.view.window beginSheet:wizard.window completionHandler:nil];
[wizard showWindow:self];
}
- (void)createSIPAccount:(NSMenuItem*) sender
......@@ -426,23 +430,6 @@ QMetaObject::Connection accountChangedConnection, selectedAccountChangedConnecti
AccountModel::instance().save();
}
- (void)createRingAccount:(NSMenuItem*) sender
{
wizard = [[RingWizardWC alloc] initWithWindowNibName:@"RingWizard"];
[wizard showChooseWithCancelButton: YES];
// [wizard.window makeKeyAndOrderFront:self];
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
[self.view.window beginSheet:wizard.window completionHandler:nil];
#else
[NSApp beginSheet: wizard.window
modalForWindow: self.view.window
modalDelegate: self
didEndSelector: nil
contextInfo: nil];
#endif
[wizard showWindow:self];
}
#pragma mark - BackupAccountDelegate methods
-(void) didCompleteExportWithPath:(NSURL*) fileUrl
......
/*
* Copyright (C) 22018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsProtocol.h"
@protocol AddSIPAccountDelegate <NSObject>
- (void)close;
- (void)showView:(NSView*)view;
@end
@interface AddSIPAccountVC : NSViewController <LrcModelsProtocol>
@property (nonatomic, weak) NSWindowController <AddSIPAccountDelegate>* delegate;
- (void)show;
@end
/*
* Copyright (C) 22018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//cocoa
#import <Quartz/Quartz.h>
//LRC
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <account.h>
//ring
#import "AddSIPAccountVC.h"
@interface AddSIPAccountVC () {
__unsafe_unretained IBOutlet NSButton* photoView;
__unsafe_unretained IBOutlet NSImageView* addProfilePhotoImage;
__unsafe_unretained IBOutlet NSTextField* displayNameField;
__unsafe_unretained IBOutlet NSTextField* userNameField;
__unsafe_unretained IBOutlet NSSecureTextField* passwordField;
__unsafe_unretained IBOutlet NSTextField* serverField;
}
@end
@implementation AddSIPAccountVC
QMetaObject::Connection accountCreated;
std::string accountToCreate;
NSTimer* timeoutTimer;
@synthesize accountModel;
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setAutoresizingMask: NSViewHeightSizable];
}
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(lrc::api::NewAccountModel*) accountModel {
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.accountModel = accountModel;
}
return self;
}
-(void) show {
[photoView setWantsLayer: YES];
photoView.layer.cornerRadius = photoView.frame.size.width / 2;
photoView.layer.masksToBounds = YES;
[photoView setBordered:YES];
[addProfilePhotoImage setWantsLayer: YES];
}
- (IBAction)cancel:(id)sender
{
[self.delegate close];
}
- (IBAction)addAccount:(id)sender
{
NSString* displayName = [displayNameField.stringValue isEqualToString:@""] ? @"SIP" : displayNameField.stringValue;
QObject::disconnect(accountCreated);
accountCreated = QObject::connect(self.accountModel,
&lrc::api::NewAccountModel::accountAdded,
[self] (const std::string& accountID) {
if(accountID.compare(accountToCreate) != 0) {
return;
}
if([photoView image]) {
NSImage *avatarImage = [photoView image];
auto imageToBytes = QByteArray::fromNSData([avatarImage TIFFRepresentation]).toBase64();
std::string imageToString = std::string(imageToBytes.constData(), imageToBytes.length());
self.accountModel->setAvatar(accountID, imageToString);
}
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(accountID);
if(![serverField.stringValue isEqualToString:@""]) {
accountProperties.hostname = [serverField.stringValue UTF8String];
}
if(![passwordField.stringValue isEqualToString:@""]) {
accountProperties.password = [passwordField.stringValue UTF8String];
}
if(![userNameField.stringValue isEqualToString:@""]) {
accountProperties.username = [userNameField.stringValue UTF8String];
}
self.accountModel->setAccountConfig(accountID, accountProperties);
QObject::disconnect(accountCreated);
[self.delegate close];
});
accountToCreate = self.accountModel->createNewAccount(lrc::api::profile::Type::SIP, [displayName UTF8String]);
timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(addingAccountTimeout) userInfo:nil
repeats:NO];
}
-(void) addingAccountTimeout {
QObject::disconnect(accountCreated);
[self.delegate close];
}
- (IBAction)editPhoto:(id)sender
{
auto pictureTaker = [IKPictureTaker pictureTaker];
[pictureTaker beginPictureTakerSheetForWindow:[self.delegate window]
withDelegate:self
didEndSelector:@selector(pictureTakerDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
- (void)pictureTakerDidEnd:(IKPictureTaker *) picker
returnCode:(NSInteger) code
contextInfo:(void*) contextInfo
{
if (auto outputImage = [picker outputImage]) {
[photoView setBordered:NO];
[photoView setImage:outputImage];
[addProfilePhotoImage setHidden:YES];
} else if(!photoView.image) {
[photoView setBordered:YES];
[addProfilePhotoImage setHidden:NO];
}
}
@end
......@@ -30,6 +30,7 @@
#import <QDebug>
#import <account.h>
#import <AvailableAccountModel.h>
#import <api/lrc.h>
#if ENABLE_SPARKLE
......@@ -54,9 +55,11 @@
@end
@implementation AppDelegate
@implementation AppDelegate {
NSTimer* preventSleepTimer;
std::unique_ptr<lrc::api::Lrc> lrc;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
......@@ -76,6 +79,7 @@ NSTimer* preventSleepTimer;
NSAppleEventManager* appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
lrc = std::make_unique<lrc::api::Lrc>();
if([self checkForRingAccount]) {
[self showMainWindow];
......@@ -239,7 +243,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
- (void) showWizard
{
if(self.wizard == nil) {
self.wizard = [[RingWizardWC alloc] initWithWindowNibName:@"RingWizard"];
self.wizard = [[RingWizardWC alloc] initWithNibName:@"RingWizard" bundle: nil accountmodel: &lrc->getAccountModel()];
}
[self.wizard.window makeKeyAndOrderFront:self];
}
......@@ -247,7 +251,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
- (void) showMainWindow
{
if(self.ringWindowController == nil) {
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"];
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow" bundle: nil accountModel:&lrc->getAccountModel() dataTransferModel:&lrc->getDataTransferModel() behaviourController:&lrc->getBehaviorController()];
}
[[NSApplication sharedApplication] removeWindowsItem:self.wizard.window];
[self.ringWindowController.window makeKeyAndOrderFront:self];
......
......@@ -180,7 +180,7 @@ NSMenuItem* selectedMenuItem;
QByteArray ba = QByteArray::fromStdString(account.profileInfo.avatar);
QVariant photo = GlobalInstances::pixmapManipulator().personPhoto(ba);
QVariant photo = GlobalInstances::pixmapManipulator().personPhoto(ba, nil);
[profileImage setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
}
@catch (NSException *ex) {
......@@ -234,6 +234,7 @@ NSMenuItem* selectedMenuItem;
}
[self updateMenu];
[self setPopUpButtonSelection];
[self updatePhoto];
}
-(void) setPopUpButtonSelection {
......@@ -265,6 +266,7 @@ NSMenuItem* selectedMenuItem;
auto& account = accMdl_->getAccountInfo(accList[row]);
[accountSelectionManager_ setSavedAccount:account];
[delegate selectAccount:account];
[self updatePhoto];
}
#pragma mark - NSMenuDelegate
......
......@@ -19,8 +19,8 @@
#import <Cocoa/Cocoa.h>
#import "LrcModelsSProtocol.h"
#import "LrcModelsProtocol.h"
@interface GeneralPrefsVC : NSViewController <LrcModelsSProtocol, NSOpenSavePanelDelegate>
@interface GeneralPrefsVC : NSViewController <LrcModelsProtocol, NSOpenSavePanelDelegate>
@end
......@@ -65,7 +65,7 @@
@synthesize dataTransferModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil model:(lrc::api::DataTransferModel*) dataTransferModel
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(lrc::api::DataTransferModel*) dataTransferModel
{
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
......
/*
* Copyright (C) 2018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* 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 3 of the License, or
......@@ -17,13 +20,19 @@
namespace lrc {
namespace api {
class DataTransferModel;
class NewAccountModel;
class BehaviorController;
}
}
@protocol LrcModelsSProtocol
@protocol LrcModelsProtocol
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil model:(lrc::api::DataTransferModel*) dataTransferModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(const lrc::api::DataTransferModel*) dataTransferModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(const lrc::api::NewAccountModel*) accountModel;
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(const lrc::api::NewAccountModel*)accountModel dataTransferModel:(const lrc::api::DataTransferModel*)dataTransferModel behaviourController:(const lrc::api::BehaviorController*) behaviorController;
@property lrc::api::DataTransferModel* dataTransferModel;
@property lrc::api::NewAccountModel* accountModel;
@property lrc::api::BehaviorController* behaviorController;
@end
......@@ -17,9 +17,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsSProtocol.h"
#import "LrcModelsProtocol.h"
@interface PreferencesWC : NSWindowController <NSWindowDelegate, LrcModelsSProtocol>
@interface PreferencesWC : NSWindowController <NSWindowDelegate, LrcModelsProtocol>
- (void)displayGeneral:(NSToolbarItem *)sender;
- (void)displayAudio:(NSToolbarItem *)sender;
......
......@@ -39,7 +39,7 @@
NSViewController *currentVC;
}
@synthesize dataTransferModel;
@synthesize dataTransferModel, accountModel, behaviorController;
// Identifiers used in PreferencesWindow.xib for tabs
static auto const kProfilePrefsIdentifier = @"AccountsPrefsIdentifier";
......@@ -55,11 +55,13 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
[self displayGeneral:nil];
}
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil model:(lrc::api::DataTransferModel*) dataTransferModel
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*)accountModel dataTransferModel:( lrc::api::DataTransferModel*)dataTransferModel behaviourController:( lrc::api::BehaviorController*) behaviorController
{
if (self = [self initWithWindowNibName:nibNameOrNil])
if (self = [self initWithWindowNibName:nibNameOrNil])
{
self.accountModel = accountModel;
self.dataTransferModel = dataTransferModel;
self.behaviorController = behaviorController;
}
return self;
}
......@@ -74,7 +76,7 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
{
[[prefsContainer subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)];
currentVC = [[GeneralPrefsVC alloc] initWithNibName:@"GeneralPrefs" bundle:nil model: self.dataTransferModel];
currentVC = [[GeneralPrefsVC alloc] initWithNibName:@"GeneralPrefs" bundle:nil dataTransferModel: self.dataTransferModel];
[self resizeWindowWithFrame:currentVC.view.frame];
[prefsContainer addSubview:currentVC.view];
......@@ -102,7 +104,7 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
{
[[prefsContainer subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)];
currentVC = [[AccountsVC alloc] initWithNibName:@"Accounts" bundle:nil];
currentVC = [[AccountsVC alloc] initWithNibName:@"Accounts" bundle:nil accountmodel:self.accountModel];
[self resizeWindowWithFrame:currentVC.view.frame];
[prefsContainer addSubview:currentVC.view];
}
......
......@@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsProtocol.h"
namespace lrc {
namespace api {
......@@ -26,7 +27,7 @@ namespace lrc {
}
}
@interface RingWindowController : NSWindowController <NSSharingServicePickerDelegate> {
@interface RingWindowController : NSWindowController <NSSharingServicePickerDelegate, LrcModelsProtocol> {
IBOutlet NSView *currentView;
}
......
......@@ -73,8 +73,6 @@
__unsafe_unretained IBOutlet NSButton* shareButton;
__unsafe_unretained IBOutlet NSImageView* qrcodeView;
std::unique_ptr<lrc::api::Lrc> lrc_;
PreferencesWC* preferencesWC;
IBOutlet SmartViewVC* smartViewVC;
......@@ -88,6 +86,19 @@
static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItemIdentifier";
@synthesize dataTransferModel, accountModel, behaviorController;
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*)accountModel dataTransferModel:( lrc::api::DataTransferModel*)dataTransferModel behaviourController:( lrc::api::BehaviorController*) behaviorController
{
if (self = [self initWithWindowNibName:nibNameOrNil])
{
self.accountModel = accountModel;
self.dataTransferModel = dataTransferModel;
self.behaviorController = behaviorController;
}
return self;
}
- (void)windowDidLoad {
[super windowDidLoad];
[self.window setMovableByWindowBackground:YES];
......@@ -95,12 +106,10 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarIte
[self.window setBackgroundColor:[NSColor colorWithRed:242.0/255 green:242.0/255 blue:242.0/255 alpha:1.0]];
self.window.titleVisibility = NSWindowTitleHidden;
lrc_ = std::make_unique<lrc::api::Lrc>();
currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
conversationVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil delegate:self];
// toolbar items
chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel()) delegate:self];
chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:self.accountModel delegate:self];
[callView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[[currentCallVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[[conversationVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
......@@ -132,7 +141,7 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarIte
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
}
lrc_->getDataTransferModel().downloadDirectory = std::string([path UTF8String]);
self.dataTransferModel->downloadDirectory = std::string([path UTF8String]);
if(appSandboxed()) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
media::RecordingModel::instance().setRecordPath(QString::fromNSString([paths objectAtIndex:0]));
......@@ -141,11 +150,11 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarIte
- (void) connect
{
QObject::connect(&lrc_->getBehaviorController(),
QObject::connect(self.behaviorController,
&lrc::api::BehaviorController::showCallView,
[self](const std::string accountId,
const lrc::api::conversation::Info convInfo){
auto* accInfo = &lrc_->getAccountModel().getAccountInfo(accountId);
auto* accInfo = &self.accountModel->getAccountInfo(accountId);
if (accInfo->contactModel->getContact(convInfo.participants[0]).profileInfo.type == lrc::api::profile::Type::PENDING)
[smartViewVC selectPendingList];
else
......@@ -159,11 +168,11 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarIte
[conversationVC hideWithAnimation:false];
});
QObject::connect(&lrc_->getBehaviorController(),
QObject::connect(self.behaviorController,
&lrc::api::BehaviorController::showIncomingCallView,
[self](const std::string accountId,
const lrc::api::conversation::Info convInfo){
auto* accInfo = &lrc_->getAccountModel().getAccountInfo(accountId);
auto* accInfo = &self.accountModel->getAccountInfo(accountId);
if (accInfo->contactModel->getContact(convInfo.participants[0]).profileInfo.type == lrc::api::profile::Type::PENDING)
[smartViewVC selectPendingList];
else
......@@ -177,11 +186,11 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarIte
[conversationVC hideWithAnimation:false];
});
QObject::connect(&lrc_->getBehaviorController(),
QObject::connect(self.behaviorController,
&lrc::api::BehaviorController::showChatView,
[self](const std::string& accountId,
const lrc::api::conversation::Info& convInfo){
auto& accInfo = lrc_->getAccountModel().getAccountInfo(accountId);
auto& accInfo = self.accountModel->getAccountInfo(accountId);
[conversationVC setConversationUid:convInfo.uid model:accInfo.conversationModel.get()];
[smartViewVC selectConversation: convInfo model:accInfo.conversationModel.get()];
[conversationVC showWithAnimation:false];
......@@ -328,7 +337,8 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarIte
[preferencesWC.window orderFront:preferencesWC.window];
return;
}
preferencesWC = [[PreferencesWC alloc] initWithNibName:@"PreferencesWindow" bundle: nil model:&(lrc_->getDataTransferModel())];
preferencesWC = [[PreferencesWC alloc] initWithWindowNibName: @"PreferencesWindow" bundle: nil accountModel:self.accountModel dataTransferModel:self.dataTransferModel behaviourController:self.behaviorController];
[preferencesWC.window makeKeyAndOrderFront:preferencesWC.window];
}
......
......@@ -25,6 +25,8 @@ typedef NS_ENUM(NSInteger, WizardAction) {
WIZARD_ACTION_INVALID = -1,
WIZARD_ACTION_NEW = 0,
WIZARD_ACTION_LINK = 1,
WIZARD_ACTION_ADVANCED = 2,
WIZARD_ACTION_SIP_ACCOUNT = 3
};
@protocol RingWizardChooseDelegate <NSObject>
......@@ -38,8 +40,11 @@ typedef NS_ENUM(NSInteger, WizardAction) {
@property (weak, nonatomic) id <RingWizardChooseDelegate> delegate;
@property BOOL isCancelable;
@property BOOL withAdvancedOptions;
- (void)showCancelButton:(BOOL)showCancel;
- (void)showAdvancedButton:(BOOL)showAdvanced;
@end
......@@ -23,12 +23,26 @@
@end
@implementation RingWizardChooseVC
@implementation RingWizardChooseVC {
__unsafe_unretained IBOutlet NSButton* createSIPAccount;
}
@synthesize delegate;
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setAutoresizingMask: NSViewHeightSizable];
}
- (void)showCancelButton:(BOOL)showCancel{
self.isCancelable = showCancel;
[createSIPAccount setHidden: YES];
}
- (void)showAdvancedButton:(BOOL)showAdvanced {
self.withAdvancedOptions = showAdvanced;
}
- (IBAction)createRingAccount:(id)sender
......@@ -52,4 +66,19 @@
}
}
- (IBAction)showCreateSIP:(id)sender
{
if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){
[delegate didCompleteWithAction:WIZARD_ACTION_ADVANCED];
}
[createSIPAccount setHidden: NO];
}
- (IBAction)addSIPAccount:(id)sender
{
if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){
[delegate didCompleteWithAction:WIZARD_ACTION_SIP_ACCOUNT];
}
}
@end
......@@ -18,12 +18,14 @@
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsProtocol.h"
@protocol RingWizardLinkDelegate <NSObject>
- (void)didLinkAccountWithSuccess:(BOOL)success;
- (void)showView:(NSView*)view;
@end
@interface RingWizardLinkAccountVC : NSViewController
@interface RingWizardLinkAccountVC : NSViewController <LrcModelsProtocol>
@property (nonatomic, weak) NSWindowController <RingWizardLinkDelegate>* delegate;
@property (nonatomic, weak) NSString* pinValue;
@property (nonatomic, weak) NSString* passwordValue;
......
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Author: Loïc Siret <loic.siret@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* 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
......@@ -26,15 +27,8 @@
#import <QPixmap>
//LRC
#import <accountmodel.h>
#import <protocolmodel.h>
#import <profilemodel.h>
#import <QItemSelectionModel>
#import <account.h>
#import <certificate.h>
#import <profilemodel.h>
#import <profile.h>
#import <person.h>
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import "Constants.h"
#import "views/NSImage+Extensions.h"
......@@ -46,7 +40,6 @@
@implementation RingWizardLinkAccountVC {
__unsafe_unretained IBOutlet NSView* initialContainer;
__unsafe_unretained IBOutlet NSView* firstStepContainer;
__unsafe_unretained IBOutlet NSView* loadingContainer;
__unsafe_unretained IBOutlet NSProgressIndicator* progressBar;
......@@ -60,76 +53,76 @@
__unsafe_unretained IBOutlet NSButton* linkButton;
NSString *fileButtonTitleBackup;
Account* accountToCreate;
NSURL* backupFile;
NSTimer* errorTimer;
QMetaObject::Connection stateChanged;
QMetaObject::Connection accountCreated;
QMetaObject::Connection accountRemoved;
std::string accountToCreate;
}
- (IBAction)goToStepTwo:(id)sender
{
[self disconnectCallback];
[firstStepContainer setHidden:YES];
[initialContainer setHidden:NO];
[loadingContainer setHidden:YES];
[errorContainer setHidden:YES];
@synthesize accountModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(lrc::api::NewAccountModel*) accountModel {
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.accountModel = accountModel;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setAutoresizingMask: NSViewHeightSizable];
}
- (IBAction)goToStepOne:(id)sender
- (void)show
{
[firstStepContainer setHidden:NO];
[initialContainer setHidden:YES];
[loadingContainer setHidden:YES];
[errorContainer setHidden:YES];
[self.delegate showView:initialContainer];
[fileButton setTitle:fileButtonTitleBackup];
backupFile = nil;
[pinTextField setStringValue:@""];
[pinTextField setEnabled:YES];
[linkButton setEnabled:NO];
[linkButton setEnabled:YES];
[passwordTextField setStringValue:@""];
}
- (void)show
{
[firstStepContainer setHidden:NO];
[initialContainer setHidden:YES];
[loadingContainer setHidden:YES];
[errorContainer setHidden:YES];
fileButtonTitleBackup = [fileButton title];
}
- (void)showError
{
[initialContainer setHidden:YES];
[loadingContainer setHidden:YES];
[errorContainer setHidden:NO];
[self.delegate showView:errorContainer];
QObject::disconnect(accountCreated);
QObject::disconnect(accountRemoved);
}
- (void)showLoading
{
[initialContainer setHidden:YES];
[loadingContainer setHidden:NO];
[progressBar startAnimation:nil];
[errorContainer setHidden:YES];
[self.delegate showView:loadingContainer];