Commit be7e2e4a authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

cleanup: remove unused code

Change-Id: Ic614edbc59b90552365ca090da4b17a8daa17277
parent bce35482
...@@ -135,8 +135,6 @@ SET(ringclient_CONTROLLERS ...@@ -135,8 +135,6 @@ SET(ringclient_CONTROLLERS
src/AccAdvancedRingVC.h src/AccAdvancedRingVC.h
src/CertificateWC.mm src/CertificateWC.mm
src/CertificateWC.h src/CertificateWC.h
src/RestoreAccountWC.mm
src/RestoreAccountWC.h
src/AudioPrefsVC.mm src/AudioPrefsVC.mm
src/AudioPrefsVC.h src/AudioPrefsVC.h
src/VideoPrefsVC.mm src/VideoPrefsVC.mm
...@@ -180,10 +178,6 @@ SET(ringclient_CONTROLLERS ...@@ -180,10 +178,6 @@ SET(ringclient_CONTROLLERS
src/LeaveMessageVC.h src/LeaveMessageVC.h
) )
SET(ringclient_BACKENDS
src/backends/AddressBookBackend.mm
src/backends/AddressBookBackend.h)
SET(ringclient_VIEWS SET(ringclient_VIEWS
src/views/CallView.mm src/views/CallView.mm
src/views/CallView.h src/views/CallView.h
...@@ -262,7 +256,6 @@ SET(ringclient_XIBS ...@@ -262,7 +256,6 @@ SET(ringclient_XIBS
PreferencesWindow PreferencesWindow
RingWizard RingWizard
CertificateWindow CertificateWindow
RestoreAccountWindow
ExportPasswordWindow ExportPasswordWindow
MigrateRingAccountsWindow MigrateRingAccountsWindow
Conversation Conversation
...@@ -416,7 +409,6 @@ ENDFOREACH() ...@@ -416,7 +409,6 @@ ENDFOREACH()
SET(TO_ADD SET(TO_ADD
${ringclient_CONTROLLERS} ${ringclient_CONTROLLERS}
${ringclient_BACKENDS}
${ringclient_VIEWS} ${ringclient_VIEWS}
${ringclient_OTHERS} ${ringclient_OTHERS}
${ringclient_XIBS_FOR_EXECUTABLE} ${ringclient_XIBS_FOR_EXECUTABLE}
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#import <api/newaccountmodel.h> #import <api/newaccountmodel.h>
#import <api/newdevicemodel.h> #import <api/newdevicemodel.h>
#import <api/newcodecmodel.h> #import <api/newcodecmodel.h>
#import <account.h> #import <api/account.h>
@interface AccAdvancedVC () @interface AccAdvancedVC ()
......
...@@ -19,10 +19,7 @@ ...@@ -19,10 +19,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <certificate.h>
@interface CertificateWC : NSWindowController @interface CertificateWC : NSWindowController
- (void) setCertificate:(Certificate*) cert;
@end @end
...@@ -25,11 +25,6 @@ ...@@ -25,11 +25,6 @@
[super windowDidLoad]; [super windowDidLoad];
} }
- (void) setCertificate:(Certificate*) cert
{
NSLog(@"CertificateWC loaded");
}
- (IBAction)closePanel:(id)sender - (IBAction)closePanel:(id)sender
{ {
[NSApp endSheet:self.window]; [NSApp endSheet:self.window];
......
...@@ -437,7 +437,7 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -437,7 +437,7 @@ CVPixelBufferRef pixelBufferPreview;
} }
} }
-(void) setupConference:(Call*) c -(void) setupConference
{ {
[videoView setShouldAcceptInteractions:YES]; [videoView setShouldAcceptInteractions:YES];
[self.chatButton setHidden:NO]; [self.chatButton setHidden:NO];
......
...@@ -19,14 +19,19 @@ ...@@ -19,14 +19,19 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
//LRC //Jami
#import <account.h>
//RING
#import "LoadingWCProtocol.h" #import "LoadingWCProtocol.h"
#import "LoadingWCDelegate.h" #import "LoadingWCDelegate.h"
#import "AbstractLoadingWC.h" #import "AbstractLoadingWC.h"
#import "string"
namespace lrc {
namespace api {
class NewAccountModel;
}
}
@protocol MigrateRingAccountsDelegate <LoadingWCDelegate> @protocol MigrateRingAccountsDelegate <LoadingWCDelegate>
-(void) migrationDidCompleteWithError; -(void) migrationDidCompleteWithError;
...@@ -57,6 +62,7 @@ ...@@ -57,6 +62,7 @@
*/ */
@property (readonly) BOOL validatePasswords; @property (readonly) BOOL validatePasswords;
@property Account* account; @property lrc::api::NewAccountModel* accountModel;
@property std::string accountToMigrate;
@end @end
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#import "MigrateRingAccountsWC.h" #import "MigrateRingAccountsWC.h"
//LRC //LRC
#import <accountmodel.h> #import <api/newaccountmodel.h>
//RING //RING
#import "views/ITProgressIndicator.h" #import "views/ITProgressIndicator.h"
...@@ -31,12 +31,14 @@ ...@@ -31,12 +31,14 @@
__unsafe_unretained IBOutlet NSTextField* infoField; __unsafe_unretained IBOutlet NSTextField* infoField;
__unsafe_unretained IBOutlet NSTextField* errorField; __unsafe_unretained IBOutlet NSTextField* errorField;
__unsafe_unretained IBOutlet ITProgressIndicator* progressIndicator; __unsafe_unretained IBOutlet ITProgressIndicator* progressIndicator;
__unsafe_unretained IBOutlet NSImageView* profileImage;
__unsafe_unretained IBOutlet NSTextField* alias;
} }
- (IBAction)onClickComplete:(id)sender; - (IBAction)onClickComplete:(id)sender;
@end @end
@implementation MigrateRingAccountsWC{ @implementation MigrateRingAccountsWC {
struct { struct {
unsigned int didComplete:1; unsigned int didComplete:1;
unsigned int didCompleteWithError:1; unsigned int didCompleteWithError:1;
...@@ -46,6 +48,8 @@ ...@@ -46,6 +48,8 @@
NSTimer* errorTimer; NSTimer* errorTimer;
QMetaObject::Connection stateChanged; QMetaObject::Connection stateChanged;
@synthesize accountModel, accountToMigrate;
#pragma mark - Initialise / Setters #pragma mark - Initialise / Setters
- (id)initWithDelegate:(id <MigrateRingAccountsDelegate>) del actionCode:(NSInteger) code - (id)initWithDelegate:(id <MigrateRingAccountsDelegate>) del actionCode:(NSInteger) code
{ {
...@@ -54,6 +58,9 @@ QMetaObject::Connection stateChanged; ...@@ -54,6 +58,9 @@ QMetaObject::Connection stateChanged;
- (void) awakeFromNib{ - (void) awakeFromNib{
[self setInfoMessageForAccount]; [self setInfoMessageForAccount];
[profileImage setWantsLayer: YES];
profileImage.layer.cornerRadius = 40;
profileImage.layer.masksToBounds = YES;
} }
- (void)setDelegate:(id <MigrateRingAccountsDelegate>)aDelegate - (void)setDelegate:(id <MigrateRingAccountsDelegate>)aDelegate
...@@ -65,30 +72,43 @@ QMetaObject::Connection stateChanged; ...@@ -65,30 +72,43 @@ QMetaObject::Connection stateChanged;
} }
} }
- (void) setAccount:(Account *)aAccount
{
_account = aAccount;
}
- (void) setInfoMessageForAccount - (void) setInfoMessageForAccount
{ {
NSMutableAttributedString* infoMessage = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"The following account needs to be migrated to the new Ring account format:",@"Text shown to the user")]; const lrc::api::account::Info& accountInfo = self.accountModel->getAccountInfo(accountToMigrate);
NSData *imageData = [[NSData alloc]
initWithBase64EncodedString: @(accountInfo.profileInfo.avatar.c_str())
options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSImage *image = [[NSImage alloc] initWithData:imageData];
if (image) {
profileImage.image = image;
} else {
profileImage.image = [NSImage imageNamed:@"default_avatar_overlay.png"];
profileImage.layer.backgroundColor = [[NSColor grayColor] CGColor];
}
alias.stringValue = @(accountInfo.profileInfo.alias.c_str());
NSMutableAttributedString* infoMessage = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"This account needs to be migrated",@"Text shown to the user")];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Alias : ",@"Text shown to the user")]];
const CGFloat fontSize = 13; const CGFloat fontSize = 13;
NSDictionary *attrs = @{ NSDictionary *attrs = @{
NSFontAttributeName:[NSFont boldSystemFontOfSize:fontSize] NSFontAttributeName:[NSFont boldSystemFontOfSize:fontSize]
}; };
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:self.account->alias().toNSString() attributes:attrs]]; auto registredName = accountInfo.registeredName;
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; if(!registredName.empty()) {
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"RingID : ",@"Text shown to the user")]]; [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Registered name: ",@"Text shown to the user")
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:self.account->username().toNSString() attributes:attrs]]; attributes:attrs]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@(registredName.c_str()) attributes:attrs]];
} else {
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"ID: ",@"Text shown to the user")
attributes:attrs]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@(accountInfo.profileInfo.uri.c_str()) attributes:attrs]];
}
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"To proceed with the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If you are not ready to choose a password, you may close Ring and resume the migration later.",@"Text shown to the user")]]; [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"To proceed with the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If you are not ready to choose a password, you may close Ring and resume the migration later.",@"Text shown to the user")]];
[infoField setAttributedStringValue:infoMessage]; [infoField setAttributedStringValue:infoMessage];
} }
- (void) showError:(NSString*) errorMessage - (void) showError:(NSString*) errorMessage
{ {
[errorField setStringValue:errorMessage]; [errorField setStringValue:errorMessage];
...@@ -107,9 +127,10 @@ QMetaObject::Connection stateChanged; ...@@ -107,9 +127,10 @@ QMetaObject::Connection stateChanged;
#pragma mark - Events Handlers #pragma mark - Events Handlers
- (IBAction)removeAccount:(id)sender - (IBAction)removeAccount:(id)sender
{ {
AccountModel::instance().remove(self.account); self.accountModel->removeAccount(accountToMigrate);
AccountModel::instance().save();
[self cancelPressed:sender]; [self cancelPressed:sender];
if (delegateRespondsTo.didComplete)
[((id<MigrateRingAccountsDelegate>)self.delegate) migrationDidComplete];
} }
- (IBAction)startMigration:(NSButton *)sender - (IBAction)startMigration:(NSButton *)sender
...@@ -122,28 +143,21 @@ QMetaObject::Connection stateChanged; ...@@ -122,28 +143,21 @@ QMetaObject::Connection stateChanged;
target:self target:self
selector:@selector(didCompleteWithError) userInfo:nil selector:@selector(didCompleteWithError) userInfo:nil
repeats:NO]; repeats:NO];
stateChanged = QObject::connect( stateChanged = QObject::connect(self.accountModel,
self.account, &Account::stateChanged, &lrc::api::NewAccountModel::migrationEnded,
[=](Account::RegistrationState state){ [self](const std::string& accountId, bool ok) {
switch(state){ if (accountToMigrate != accountId) {
case Account::RegistrationState::READY: return;
case Account::RegistrationState::TRYING:
case Account::RegistrationState::UNREGISTERED:{
self.account<< Account::EditAction::RELOAD;
QObject::disconnect(stateChanged);
[self didComplete];
break;
}
case Account::RegistrationState::ERROR:
case Account::RegistrationState::INITIALIZING:
case Account::RegistrationState::COUNT__:{
//DO Nothing
break;
} }
if (ok) {
[self didComplete];
} else {
[self didCompleteWithError];
} }
}); });
self.account->setArchivePassword(QString::fromNSString(self.password)); lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(accountToMigrate);
self.account->performAction(Account::EditAction::SAVE); accountProperties.archivePassword = [self.password UTF8String];
self.accountModel->setAccountConfig(accountToMigrate, accountProperties);
} }
} }
...@@ -159,7 +173,6 @@ QMetaObject::Connection stateChanged; ...@@ -159,7 +173,6 @@ QMetaObject::Connection stateChanged;
return [NSSet setWithObjects:@"password", @"passwordConfirmation", nil]; return [NSSet setWithObjects:@"password", @"passwordConfirmation", nil];
} }
#pragma mark - Delegates #pragma mark - Delegates
- (void)didComplete - (void)didComplete
{ {
...@@ -175,11 +188,9 @@ QMetaObject::Connection stateChanged; ...@@ -175,11 +188,9 @@ QMetaObject::Connection stateChanged;
[((id<MigrateRingAccountsDelegate>)self.delegate) migrationDidComplete]; [((id<MigrateRingAccountsDelegate>)self.delegate) migrationDidComplete];
} }
- (void)didCompleteWithError - (void)didCompleteWithError
{ {
[self showError:NSLocalizedString(@"Failed to migrate your account. You can retry by pressing Ok or delete your account.",@"Error message shown to user when it is impossible to migrate account")]; [self showError:NSLocalizedString(@"Failed to migrate your account. You can retry by pressing Ok or delete your account.",@"Error message shown to user when it is impossible to migrate account")];
} }
@end @end
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
//LRC //LRC
#import <api/lrc.h> #import <api/lrc.h>
#import <api/newaccountmodel.h> #import <api/newaccountmodel.h>
#import <account.h> #import <api/account.h>
#import <namedirectory.h>
@implementation RegisterNameWC @implementation RegisterNameWC
{ {
...@@ -116,7 +117,8 @@ NSInteger const PASSWORD_TAG = 3; ...@@ -116,7 +117,8 @@ NSInteger const PASSWORD_TAG = 3;
registeredNameFound = QObject::connect( registeredNameFound = QObject::connect(
&NameDirectory::instance(), &NameDirectory::instance(),
&NameDirectory::registeredNameFound, &NameDirectory::registeredNameFound,
[=] ( const Account* account, NameDirectory::LookupStatus status, const QString& address, const QString& name) { [=] (NameDirectory::LookupStatus status,
const QString& address, const QString& name) {
NSLog(@"Name lookup ended"); NSLog(@"Name lookup ended");
lookupQueued = NO; lookupQueued = NO;
//If this is the username we are waiting for, we can disconnect. //If this is the username we are waiting for, we can disconnect.
...@@ -170,7 +172,7 @@ NSInteger const PASSWORD_TAG = 3; ...@@ -170,7 +172,7 @@ NSInteger const PASSWORD_TAG = 3;
); );
//Start the lookup in a second so that the UI dosen't seem to freeze //Start the lookup in a second so that the UI dosen't seem to freeze
BOOL result = NameDirectory::instance().lookupName(nullptr, QString(), QString::fromNSString(usernameWaitingForLookupResult)); BOOL result = NameDirectory::instance().lookupName(QString(), QString::fromNSString(usernameWaitingForLookupResult));
} }
- (void)controlTextDidChange:(NSNotification *)notif - (void)controlTextDidChange:(NSNotification *)notif
......
/*
* Copyright (C) 2016-2019 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@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 <QtCore/qdir.h>
#import "LoadingWCDelegate.h"
#import "AbstractLoadingWC.h"
typedef NS_ENUM(NSUInteger, Action) {
ACTION_EXPORT = 0,
ACTION_IMPORT = 1,
};
@protocol RestoreAccountDelegate <LoadingWCDelegate>
@optional
-(void) didCompleteImport;
@end
@interface RestoreAccountWC : AbstractLoadingWC
- (id)initWithDelegate:(id <LoadingWCDelegate>) del;
/**
* Allow the NSPathControl of this window to select files or not
*/
@property (nonatomic) BOOL allowFileSelection;
/**
* password string contained in passwordField.
* This is a KVO method to bind the text with the OK Button
* if password.length is > 0, button is enabled, otherwise disabled
*/
@property (retain) NSString* password;
/**
* Object uses to store account to exports
*/
@property (assign) QStringList accounts;
@end
/*
* Copyright (C) 2016-2019 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@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 "RestoreAccountWC.h"
//LRC
#import <accountmodel.h>
//Ring
#import "views/ITProgressIndicator.h"
@interface RestoreAccountWC() <NSTextFieldDelegate> {
__unsafe_unretained IBOutlet NSPathControl* path;
__unsafe_unretained IBOutlet NSSecureTextField* passwordField;
__unsafe_unretained IBOutlet ITProgressIndicator* progressIndicator;
}
@end
@implementation RestoreAccountWC {
struct {
unsigned int didCompleteImport:1;
} delegateRespondsTo;
}
@synthesize accounts;
- (id)initWithDelegate:(id <LoadingWCDelegate>) del
{
return [self initWithDelegate:del actionCode:0];
}
- (id)initWithDelegate:(id <RestoreAccountDelegate>) del actionCode:(NSInteger) code
{
return [super initWithWindowNibName:@"RestoreAccountWindow" delegate:del actionCode:code];
}
- (void)windowDidLoad
{
[super windowDidLoad];
[path setURL: [NSURL fileURLWithPath:NSHomeDirectory()]];
}
- (void)setDelegate:(id <RestoreAccountDelegate>)aDelegate
{
if (self.delegate != aDelegate) {
[super setDelegate: aDelegate];
delegateRespondsTo.didCompleteImport = [self.delegate respondsToSelector:@selector(didCompleteWithImport)];
}
}
- (void) setAllowFileSelection:(BOOL) b
{
_allowFileSelection = b;
[path setAllowedTypes:_allowFileSelection ? nil : [NSArray arrayWithObject:@"public.folder"]];
}
- (IBAction)completeAction:(id)sender
{
auto passwordString = passwordField.stringValue;
auto pathURL = path.URL;
[self showLoading];
SEL sel = @selector(importAccountsWithPath:andPassword:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:sel]];
[inv setSelector:sel];
[inv setTarget:self];
//arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
[inv setArgument:&pathURL atIndex:2];
[inv setArgument:&passwordString atIndex:3];
// Schedule import for next iteration of event loop in order to let us start the loading anim
[inv performSelector:@selector(invoke) withObject:nil afterDelay:0];
}
- (void)showLoading
{
[progressIndicator setNumberOfLines:30];
[progressIndicator setWidthOfLine:2];
[progressIndicator setLengthOfLine:5];
[progressIndicator setInnerMargin:20];
[super showLoading];
}
- (void) importAccountsWithPath:(NSURL*) urlPath andPassword:(NSString*) password
{
int result = AccountModel::instance().importAccounts(urlPath.path.UTF8String, password.UTF8String);
switch (result) {
case 0:
if (delegateRespondsTo.didCompleteImport)
[((id<RestoreAccountDelegate>)self.delegate) didCompleteImport];
[self close];
break;
default:
{
[self showError];
}
break;
}
}
@end
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#import "RingWindowController.h" #import "RingWindowController.h"
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#include <qrencode.h> #include <qrencode.h>
#include <memory>
//LRC //LRC
#import <api/lrc.h> #import <api/lrc.h>
...@@ -31,7 +30,6 @@ ...@@ -31,7 +30,6 @@
#import <api/contactmodel.h> #import <api/contactmodel.h>
#import <api/contact.h> #import <api/contact.h>
#import <api/datatransfermodel.h> #import <api/datatransfermodel.h>
#import <media/recordingmodel.h>
#import <api/avmodel.h> #import <api/avmodel.h>
// Ring // Ring
...@@ -48,7 +46,6 @@ ...@@ -48,7 +46,6 @@
#import "utils.h" #import "utils.h"
#import "RingWizardWC.h" #import "RingWizardWC.h"
#import "AccountSettingsVC.h" #import "AccountSettingsVC.h"
#import "views/CallLayer.h"
typedef NS_ENUM(NSInteger, ViewState) { typedef NS_ENUM(NSInteger, ViewState) {
SHOW_WELCOME_SCREEN = 0, SHOW_WELCOME_SCREEN = 0,
...@@ -99,7 +96,6 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -99,7 +96,6 @@ typedef NS_ENUM(NSInteger, ViewState) {
self.behaviorController = behaviorController; self.behaviorController = behaviorController;
self.avModel = avModel; self.avModel = avModel;
self.avModel->useAVFrame(YES); self.avModel->useAVFrame(YES);
avModel->deactivateOldVideoModels();
} }
return self; return self;
} }
...@@ -191,18 +187,9 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -191,18 +187,9 @@ typedef NS_ENUM(NSInteger, ViewState) {
[conversationVC initFrame]; [conversationVC initFrame];
[settingsVC initFrame]; [settingsVC initFrame];
@try {
[smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
}
@catch (NSException *ex) {
NSLog(@"Caught exception %@: %@", [ex name], [ex reason]);
}
// Fresh run, we need to make sure RingID appears [self checkAccountsToMigrate];
[shareButton sendActionOn:NSLeftMouseDownMask];
[self connect];
[self updateRingID];
// set download folder (default - 'Documents') // set download folder (default - 'Documents')
NSString* path = [[NSUserDefaults standardUserDefaults] stringForKey:Preferences::DownloadFolder]; NSString* path = [[NSUserDefaults standardUserDefaults] stringForKey:Preferences::DownloadFolder];
if (!path || path.length == 0) { if (!path || path.length == 0) {
...@@ -212,7 +199,7 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -212,7 +199,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
self.dataTransferModel->downloadDirectory = std::string([path UTF8String]); self.dataTransferModel->downloadDirectory = std::string([path UTF8String]);
if(appSandboxed()) { if(appSandboxed()) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
media::RecordingModel::instance().setRecordPath(QString::fromNSString([paths objectAtIndex:0])); avModel->setRecordPath([[paths objectAtIndex:0] UTF8String]);
} }
NSToolbar *tb = [[self window] toolbar]; NSToolbar *tb = [[self window] toolbar];
[tb setAllowsUserCustomization:NO]; [tb setAllowsUserCustomization:NO];
...@@ -281,6 +268,47 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -281,6 +268,47 @@ typedef NS_ENUM(NSInteger, ViewState) {
}); });
} }
#pragma mark - Ring account migration
- (void) migrateRingAccount:(std::string) acc
{
self.migrateWC = [[MigrateRingAccountsWC alloc] initWithDelegate:self actionCode:1];
self.migrateWC.accountModel = self.accountModel;
self.migrateWC.accountToMigrate = acc;
[self.window beginSheet:self.migrateWC.window completionHandler:nil];
}
- (void)checkAccountsToMigrate
{
auto accounts = self.accountModel->getAccountList();
for (auto accountId: accounts) {
const lrc::api::account::Info& accountInfo = self.accountModel->getAccountInfo(accountId);
if (accountInfo.status == lrc::api::account::Status::ERROR_NEED_MIGRATION) {
[self migrateRingAccount:accountInfo.id];
return;
}
}
@try {
[smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
}
@catch (NSException *ex) {
NSLog(@"Caught exception %@: %@", [ex name], [ex reason]);
}
[shareButton sendActionOn:NSLeftMouseDownMask];
[self connect];
[self updateRingID];
}
- (void)migrationDidComplete
{
[self checkAccountsToMigrate];
}
- (void)migrationDidCompleteWithError
{
[self checkAccountsToMigrate];
}
/** /**
* Implement the necessary logic to choose which Ring ID to display. * Implement the necessary logic to choose which Ring ID to display.
* This tries to choose the "best" ID to show * This tries to choose the "best" ID to show
......
...@@ -34,8 +34,9 @@ ...@@ -34,8 +34,9 @@
//LRC //LRC
#import <api/lrc.h> #import <api/lrc.h>
#import <api/newaccountmodel.h> #import <api/newaccountmodel.h>
#import <account.h> #import <api/account.h>
#import <interfaces/pixmapmanipulatori.h> #import <interfaces/pixmapmanipulatori.h>
#import <namedirectory.h>
#import "Constants.h" #import "Constants.h"
#import "views/NSImage+Extensions.h" #import "views/NSImage+Extensions.h"
...@@ -402,7 +403,8 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2; ...@@ -402,7 +403,8 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
registeredNameFound = QObject::connect( registeredNameFound = QObject::connect(
&NameDirectory::instance(), &NameDirectory::instance(),
&NameDirectory::registeredNameFound, &NameDirectory::registeredNameFound,
[=] ( const Account* account, NameDirectory::LookupStatus status, const QString& address, const QString& name) { [=] (NameDirectory::LookupStatus status,
const QString& address, const QString& name) {
NSLog(@"Name lookup ended"); NSLog(@"Name lookup ended");
lookupQueued = NO; lookupQueued = NO;
//If this is the username we are waiting for, we can disconnect. //If this is the username we are waiting for, we can disconnect.
...@@ -456,7 +458,7 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;