Commit 3037dabb authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

swarm: adapt to API changes

- rename to JAMI
- use data transfer for account

Change-Id: Id241eb7150a6353456f080a2901e40bc0d05343b
parent 43536147
......@@ -71,7 +71,7 @@ CGFloat const VIEW_INSET = 40;
- (void) setSelectedAccount:(const QString&) account {
selectedAccountID = account;
const auto& accountInfo = accountModel->getAccountInfo(selectedAccountID);
if (accountInfo.profileInfo.type == lrc::api::profile::Type::RING) {
if (accountInfo.profileInfo.type == lrc::api::profile::Type::JAMI) {
accountGeneralVC = ringGeneralVC;
accountGeneralVC.delegate = self;
accountAdvancedVC = ringAdvancedVC;
......
......@@ -359,7 +359,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
- (void) showMainWindow
{
if(self.ringWindowController == nil) {
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow" bundle: nil accountModel:&lrc->getAccountModel() dataTransferModel:&lrc->getDataTransferModel() behaviourController:&lrc->getBehaviorController() avModel: &lrc->getAVModel() pluginModel: &lrc->getPluginModel()];
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow" bundle: nil accountModel:&lrc->getAccountModel() behaviourController:&lrc->getBehaviorController() avModel: &lrc->getAVModel() pluginModel: &lrc->getPluginModel()];
}
[[NSApplication sharedApplication] removeWindowsItem:self.wizard.window];
self.wizard = nil;
......
......@@ -232,7 +232,7 @@ NSMutableDictionary* menuItemsTags;
case lrc::api::profile::Type::SIP:
[itemView.accountTypeLabel setStringValue:@"SIP"];
break;
case lrc::api::profile::Type::RING:
case lrc::api::profile::Type::JAMI:
[itemView.accountTypeLabel setStringValue:@"Jami"];
break;
default:
......
......@@ -317,8 +317,6 @@ CVPixelBufferRef pixelBufferPreview;
}
lrc::api::conversation::Info& conv = *convOpt;
auto& contact = accountInfo_->contactModel->getContact(conv.participants[0]);
if (contact.profileInfo.type == lrc::api::profile::Type::RING && contact.profileInfo.uri == contactUri)
accountInfo_->conversationModel->makePermanent(convUid_);
[contactPhoto setImage: [self getContactImageOfSize:120.0 withDefaultAvatar:YES]];
[self.delegate conversationInfoUpdatedFor:convUid_];
[self setBackground];
......
......@@ -21,6 +21,7 @@
//lrc
#import <api/datatransfermodel.h>
#import <api/avmodel.h>
#import <api/newaccountmodel.h>
#if ENABLE_SPARKLE
#import <Sparkle/Sparkle.h>
......@@ -50,14 +51,13 @@
@implementation GeneralPrefsVC
@synthesize dataTransferModel;
@synthesize avModel;
@synthesize accountModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(lrc::api::DataTransferModel*) dataTransferModel avModel:(lrc::api::AVModel*) avModel {
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*) accountModel avModel: (lrc::api::AVModel*)avModel {
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.dataTransferModel = dataTransferModel;
self.accountModel = accountModel;
self.avModel = avModel;
}
return self;
......@@ -88,8 +88,8 @@
[conversationStackView setHidden:YES];
heightToReduice += (downloadFolder.frame.size.height + recordingFolder.frame.size.height + 25);
} else {
if (dataTransferModel) {
downloadFolder.title = [dataTransferModel->downloadDirectory.toNSString() lastPathComponent];
if (accountModel) {
downloadFolder.title = [self.accountModel->downloadDirectory.toNSString() lastPathComponent];
}
if (avModel) {
auto name1 = avModel->getRecordPath();
......@@ -112,8 +112,8 @@
if ([panel runModal] != NSFileHandlingPanelOKButton) return;
if ([[panel URLs] lastObject] == nil) return;
NSString * path = [[[[panel URLs] lastObject] path] stringByAppendingString:@"/"];
dataTransferModel->downloadDirectory = QString::fromNSString(path);
downloadFolder.title = [dataTransferModel->downloadDirectory.toNSString() lastPathComponent];
self.accountModel->downloadDirectory = QString::fromNSString(path);
downloadFolder.title = [self.accountModel->downloadDirectory.toNSString() lastPathComponent];
[[NSUserDefaults standardUserDefaults] setObject:path forKey:Preferences::DownloadFolder];
}
......
......@@ -29,14 +29,12 @@ namespace lrc {
@protocol LrcModelsProtocol
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(const lrc::api::DataTransferModel*) dataTransferModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(const lrc::api::DataTransferModel*) dataTransferModel avModel:(const lrc::api::AVModel*) avModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(const lrc::api::NewAccountModel*)accountModel avModel:(const lrc::api::AVModel*) avModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil pluginModel:(const lrc::api::PluginModel*) pluginModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil avModel:(const lrc::api::AVModel*) avModel;
-(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;
-(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 avModel: (const lrc::api::AVModel*)avModel;
-(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 avModel: (const lrc::api::AVModel*)avModel pluginModel: (const lrc::api::PluginModel*)pluginModel;
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(lrc::api::NewAccountModel*)accountModel avModel: ( lrc::api::AVModel*)avModel;
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(const lrc::api::NewAccountModel*)accountModel behaviourController:(const lrc::api::BehaviorController*) behaviorController avModel: (const lrc::api::AVModel*)avModel pluginModel: (const lrc::api::PluginModel*)pluginModel;
@property lrc::api::DataTransferModel* dataTransferModel;
@property lrc::api::NewAccountModel* accountModel;
......
......@@ -34,7 +34,7 @@
NSViewController *currentVC;
}
@synthesize dataTransferModel, accountModel, behaviorController, avModel, pluginModel;
@synthesize accountModel, behaviorController, avModel, pluginModel;
// Identifiers used in PreferencesWindow.xib for tabs
static auto const kGeneralPrefsIdentifier = @"GeneralPrefsIdentifier";
......@@ -57,12 +57,11 @@ static auto const kPluginPrefsIdentifer = @"PluginPrefsIdentifer";
[tb setAllowsUserCustomization:NO];
}
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(lrc::api::NewAccountModel*)accountModel dataTransferModel:(lrc::api::DataTransferModel*)dataTransferModel behaviourController:(lrc::api::BehaviorController*)behaviorController avModel: (lrc::api::AVModel*)avModel pluginModel: (lrc::api::PluginModel*)pluginModel
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(lrc::api::NewAccountModel*)accountModel behaviourController:(lrc::api::BehaviorController*)behaviorController avModel: (lrc::api::AVModel*)avModel pluginModel: (lrc::api::PluginModel*)pluginModel
{
if (self = [self initWithWindowNibName:nibNameOrNil])
{
self.accountModel = accountModel;
self.dataTransferModel = dataTransferModel;
self.behaviorController = behaviorController;
self.avModel = avModel;
self.pluginModel = pluginModel;
......@@ -74,7 +73,7 @@ static auto const kPluginPrefsIdentifer = @"PluginPrefsIdentifer";
{
[[prefsContainer subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)];
currentVC = [[GeneralPrefsVC alloc] initWithNibName:@"GeneralPrefs" bundle:nil dataTransferModel: self.dataTransferModel avModel: self.avModel];
currentVC = [[GeneralPrefsVC alloc] initWithNibName:@"GeneralPrefs" bundle:nil accountModel: self.accountModel avModel: self.avModel];
[self addCurrentVC];
}
......
......@@ -87,15 +87,14 @@ typedef NS_ENUM(NSInteger, ViewState) {
IBOutlet ChooseAccountVC* chooseAccountVC;
}
@synthesize dataTransferModel, accountModel, behaviorController, avModel, pluginModel;
@synthesize accountModel, behaviorController, avModel, pluginModel;
@synthesize wizard;
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*)accountModel dataTransferModel:( lrc::api::DataTransferModel*)dataTransferModel behaviourController:( lrc::api::BehaviorController*) behaviorController avModel: (lrc::api::AVModel*)avModel pluginModel: (lrc::api::PluginModel*)pluginModel
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*)accountModel behaviourController:( lrc::api::BehaviorController*) behaviorController avModel: (lrc::api::AVModel*)avModel pluginModel: (lrc::api::PluginModel*)pluginModel
{
if (self = [self initWithWindowNibName:nibNameOrNil])
{
self.accountModel = accountModel;
self.dataTransferModel = dataTransferModel;
self.behaviorController = behaviorController;
self.avModel = avModel;
self.pluginModel = pluginModel;
......@@ -208,7 +207,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
}
self.dataTransferModel->downloadDirectory = QString::fromNSString(path);
self.accountModel->downloadDirectory = QString::fromNSString(path);
if(appSandboxed()) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
avModel->setRecordPath(QString::fromNSString([paths objectAtIndex:0]));
......@@ -412,7 +411,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
[ringIDLabel setStringValue:@""];
if(account.profileInfo.type != lrc::api::profile::Type::RING) {
if(account.profileInfo.type != lrc::api::profile::Type::JAMI) {
self.notRingAccount = YES;
self.isSIPAccount = YES;
return;
......@@ -568,7 +567,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
return;
}
preferencesWC = [[PreferencesWC alloc] initWithWindowNibName: @"PreferencesWindow" bundle: nil accountModel:self.accountModel dataTransferModel:self.dataTransferModel behaviourController:self.behaviorController avModel: self.avModel pluginModel: self.pluginModel];
preferencesWC = [[PreferencesWC alloc] initWithWindowNibName: @"PreferencesWindow" bundle: nil accountModel:self.accountModel behaviourController:self.behaviorController avModel: self.avModel pluginModel: self.pluginModel];
[preferencesWC.window makeKeyAndOrderFront:preferencesWC.window];
}
......
......@@ -147,7 +147,7 @@
NSString *pin = backupFile ? @"" : (self.pinValue ? self.pinValue : @"");
NSString *archivePath = backupFile ? [backupFile path] : @"";
NSString *pathword = self.passwordValue ? self.passwordValue : @"";
accountToCreate = self.accountModel->createNewAccount(lrc::api::profile::Type::RING,
accountToCreate = self.accountModel->createNewAccount(lrc::api::profile::Type::JAMI,
"",
QString::fromNSString(archivePath),
QString::fromNSString(pathword),
......
......@@ -302,7 +302,7 @@ BOOL isRendevous = false;
[self display:loadingView];
[progressBar startAnimation:nil];
accountToCreate = self.accountModel->createNewAccount(lrc::api::profile::Type::RING, QString::fromNSString(displayNameField.stringValue),"",QString::fromNSString(passwordField.stringValue), "");
accountToCreate = self.accountModel->createNewAccount(lrc::api::profile::Type::JAMI, QString::fromNSString(displayNameField.stringValue),"",QString::fromNSString(passwordField.stringValue), "");
}
/**
......
......@@ -66,7 +66,7 @@
lrc::api::ConversationModel* convModel_;
QString selectedUid_;
lrc::api::profile::Type currentFilterType;
lrc::api::FilterType currentFilterType;
__unsafe_unretained IBOutlet RingWindowController *delegate;
}
......@@ -107,7 +107,7 @@ NSInteger const REQUEST_SEG = 1;
[smartView setShortcutsDelegate:self];
[smartView setDataSource: self];
currentFilterType = lrc::api::profile::Type::RING;
currentFilterType = lrc::api::FilterType::JAMI;
selectorIsPresent = true;
NSFont *searchBarFont = [NSFont systemFontOfSize: 12.0 weight: NSFontWeightLight];
NSColor *color = [NSColor secondaryLabelColor];
......@@ -162,16 +162,16 @@ NSInteger const REQUEST_SEG = 1;
return;
}
auto ringConversations = convModel_->getFilteredConversations(lrc::api::profile::Type::RING);
auto ringConversations = convModel_->getFilteredConversations(lrc::api::FilterType::JAMI);
int totalUnreadMessages = 0;
std::for_each(ringConversations.get().begin(), ringConversations.get().end(),
[&totalUnreadMessages, self] (const auto& conversation) {
totalUnreadMessages += convModel_->getNumberOfUnreadMessagesFor(conversation.get().uid);
totalUnreadMessages += conversation.get().unreadMessages;
});
[totalMsgsCount setHidden:(totalUnreadMessages == 0)];
[totalMsgsCount setIntValue:totalUnreadMessages];
auto totalRequests = [self chosenAccount].contactModel->pendingRequestCount();
auto totalRequests = [self chosenAccount].conversationModel->pendingRequestCount();
[totalInvites setHidden:(totalRequests == 0)];
[totalInvites setIntValue:totalRequests];
}
......@@ -192,8 +192,8 @@ NSInteger const REQUEST_SEG = 1;
[self reloadSelectorNotifications];
if (!convModel_->owner.contactModel->hasPendingRequests()) {
if (currentFilterType == lrc::api::profile::Type::PENDING) {
if (!convModel_->owner.conversationModel->hasPendingRequests()) {
if (currentFilterType == lrc::api::FilterType::REQUEST) {
[self selectConversationList];
}
if (selectorIsPresent) {
......@@ -304,7 +304,7 @@ NSInteger const REQUEST_SEG = 1;
});
newConversationConnection_ = QObject::connect(convModel_, &lrc::api::ConversationModel::newConversation,
[self] (const QString& convUid) {
[self reloadData];
[self reloadData];
[self updateConversationForNewContact:convUid.toNSString()];
});
conversationRemovedConnection_ = QObject::connect(convModel_, &lrc::api::ConversationModel::conversationRemoved,
......@@ -389,17 +389,17 @@ NSInteger const REQUEST_SEG = 1;
NSInteger selectedItem = [sender selectedSegment];
switch (selectedItem) {
case CONVERSATION_SEG:
if (currentFilterType != lrc::api::profile::Type::RING) {
convModel_->setFilter(lrc::api::profile::Type::RING);
if (currentFilterType != lrc::api::FilterType::JAMI) {
currentFilterType = lrc::api::FilterType::JAMI;
convModel_->setFilter(currentFilterType);
[delegate listTypeChanged];
currentFilterType = lrc::api::profile::Type::RING;
}
break;
case REQUEST_SEG:
if (currentFilterType != lrc::api::profile::Type::PENDING) {
convModel_->setFilter(lrc::api::profile::Type::PENDING);
if (currentFilterType != lrc::api::FilterType::REQUEST) {
currentFilterType = lrc::api::FilterType::REQUEST;
convModel_->setFilter(currentFilterType);
[delegate listTypeChanged];
currentFilterType = lrc::api::profile::Type::PENDING;
}
break;
default:
......@@ -409,25 +409,25 @@ NSInteger const REQUEST_SEG = 1;
-(void) selectConversationList
{
if (currentFilterType == lrc::api::profile::Type::RING)
if (currentFilterType == lrc::api::FilterType::JAMI)
return;
[listTypeSelector setSelectedSegment:CONVERSATION_SEG];
// Do not invert order of the next two lines or stack overflow
// may happen on -(void) reloadData call if filter is currently set to PENDING
currentFilterType = lrc::api::profile::Type::RING;
convModel_->setFilter(lrc::api::profile::Type::RING);
currentFilterType = lrc::api::FilterType::JAMI;
convModel_->setFilter(currentFilterType);
convModel_->setFilter("");
}
-(void) selectPendingList
{
if (currentFilterType == lrc::api::profile::Type::PENDING)
if (currentFilterType == lrc::api::FilterType::REQUEST)
return;
[listTypeSelector setSelectedSegment:REQUEST_SEG];
currentFilterType = lrc::api::profile::Type::PENDING;
convModel_->setFilter(lrc::api::profile::Type::PENDING);
currentFilterType = lrc::api::FilterType::REQUEST;
convModel_->setFilter(currentFilterType);
convModel_->setFilter("");
}
......@@ -831,7 +831,7 @@ NSInteger const REQUEST_SEG = 1;
return nil;
}
else if (contact.profileInfo.type == lrc::api::profile::Type::RING && contact.isTrusted == true) {
else if (contact.profileInfo.type == lrc::api::profile::Type::JAMI && contact.isTrusted == true) {
isRingContact = true;
}
auto conversationUD = conversation.uid;
......
......@@ -112,7 +112,7 @@ namespace Interfaces {
{
if (!contact.profileInfo.alias.isEmpty()) {
return contact.profileInfo.alias.at(0).toUpper();
} else if((contact.profileInfo.type == lrc::api::profile::Type::RING ||
} else if((contact.profileInfo.type == lrc::api::profile::Type::JAMI ||
contact.profileInfo.type == lrc::api::profile::Type::PENDING) &&
!contact.registeredName.isEmpty()) {
return contact.registeredName.at(0).toUpper();
......@@ -193,7 +193,7 @@ namespace Interfaces {
auto trimmed = contact.profileInfo.alias.trimmed().replace("\r","").replace("\n","");
if (!trimmed.isEmpty()) {
return drawDefaultUserPixmap(size, color.toLatin1(), trimmed.at(0).toUpper().toLatin1());
} else if((contact.profileInfo.type == lrc::api::profile::Type::RING ||
} else if((contact.profileInfo.type == lrc::api::profile::Type::JAMI ||
contact.profileInfo.type == lrc::api::profile::Type::PENDING) &&
!contact.registeredName.isEmpty()) {
trimmed = contact.registeredName.trimmed().replace("\r","").replace("\n","");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment