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

preferences: general

- remove clear history button
- add different type of notifications
- support notifications with actions

Change-Id: I05574cf11a22afdab4572daa6ba37602bab17eef
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent c6c1b4f7
......@@ -20,18 +20,13 @@
#import "AppDelegate.h"
//lrc
#import <callmodel.h>
#import <qapplication.h>
#import <accountmodel.h>
#import <protocolmodel.h>
#import <media/recordingmodel.h>
#import <media/textrecording.h>
#import <QItemSelectionModel>
#import <QDebug>
#import <account.h>
#import <AvailableAccountModel.h>
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <api/behaviorcontroller.h>
#import <api/conversation.h>
#import <api/newcallmodel.h>
#if ENABLE_SPARKLE
......@@ -41,6 +36,7 @@
#import "Constants.h"
#import "RingWizardWC.h"
#import "DialpadWC.h"
#import "utils.h"
#if ENABLE_SPARKLE
@interface AppDelegate() <SUUpdaterDelegate>
......@@ -57,6 +53,17 @@
@end
NSString * const MESSAGE_NOTIFICATION = @"message_notification_type";
NSString * const CALL_NOTIFICATION = @"call_notification_type";
NSString * const CONTACT_REQUEST_NOTIFICATION = @"contact_request_notification_type";
NSString * const ACCOUNT_ID = @"account_id_notification_info";
NSString * const CALL_ID = @"call_id_notification_info";
NSString * const CONVERSATION_ID = @"conversation_id_notification_info";
NSString * const CONTACT_URI = @"contact_uri_notification_info";
NSString * const NOTIFICATION_TYPE = @"contact_type_notification_info";
@implementation AppDelegate {
std::unique_ptr<lrc::api::Lrc> lrc;
......@@ -140,95 +147,165 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
- (void) connect
{
QObject::connect(&lrc->getBehaviorController(),
&lrc::api::BehaviorController::newTrustRequest,
[self] (const std::string& accountId, const std::string& contactUri) {
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ContactRequestNotifications];
if(!shouldNotify) {
return;
}
NSUserNotification* notification = [[NSUserNotification alloc] init];
auto contactModel = lrc->getAccountModel()
.getAccountInfo(accountId).contactModel.get();
NSString* name = contactModel->getContact(contactUri)
.registeredName.empty() ?
@(contactUri.c_str()) :
@(contactModel->getContact(contactUri).registeredName.c_str());
NSString* localizedMessage =
NSLocalizedString(@"Send you a contact request",
@"Notification message");
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
userInfo[ACCOUNT_ID] = @(accountId.c_str());
userInfo[CONTACT_URI] = @(contactUri.c_str());
userInfo[NOTIFICATION_TYPE] = CONTACT_REQUEST_NOTIFICATION;
[notification setTitle: name];
notification.informativeText = localizedMessage;
[notification setSoundName:NSUserNotificationDefaultSoundName];
[notification setUserInfo: userInfo];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
//ProfileModel::instance().addCollection<LocalProfileCollection>(LoadOptions::FORCE_ENABLED);
QObject::connect(&AccountModel::instance(),
&AccountModel::registrationChanged,
[=](Account* a, bool registration) {
qDebug() << "registrationChanged:" << a->id() << ":" << registration;
//track buddy for account
AccountModel::instance().subscribeToBuddies(a->id());
});
QObject::connect(&CallModel::instance(),
&CallModel::incomingCall,
[=](Call* call) {
// on incoming call set selected account match call destination account
if (call->account()) {
QModelIndex index = call->account()->index();
index = AvailableAccountModel::instance().mapFromSource(index);
QObject::connect(&lrc->getBehaviorController(),
&lrc::api::BehaviorController::showIncomingCallView,
[self] (const std::string& accountId, lrc::api::conversation::Info conversationInfo) {
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::CallNotifications];
if(!shouldNotify) {
return;
}
NSString* name = bestIDForConversation(conversationInfo, *lrc->getAccountModel().getAccountInfo(accountId).conversationModel.get());
NSUserNotification* notification = [[NSUserNotification alloc] init];
AvailableAccountModel::instance().selectionModel()->setCurrentIndex(index,
QItemSelectionModel::ClearAndSelect);
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
userInfo[ACCOUNT_ID] = @(accountId.c_str());
userInfo[CALL_ID] = @(conversationInfo.callId.c_str());
userInfo[CONVERSATION_ID] = @(conversationInfo.uid.c_str());
userInfo[NOTIFICATION_TYPE] = CALL_NOTIFICATION;
NSString* localizedTitle = [NSString stringWithFormat:
NSLocalizedString(@"Incoming call from %@", @"Incoming call from {Name}"),
name];
// try to activate action button
@try {
[notification setValue:@YES forKey:@"_showsButtons"];
}
BOOL shouldComeToForeground = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::WindowBehaviour];
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::Notifications];
if (shouldComeToForeground) {
[NSApp activateIgnoringOtherApps:YES];
if ([self.ringWindowController.window isMiniaturized]) {
[self.ringWindowController.window deminiaturize:self];
}
@catch (NSException *exception) {
NSLog(@"Action button not activable on notification");
}
[notification setUserInfo: userInfo];
[notification setOtherButtonTitle:NSLocalizedString(@"Refuse", @"Button Action")];
[notification setActionButtonTitle:NSLocalizedString(@"Accept", @"Button Action")];
[notification setTitle:localizedTitle];
[notification setSoundName:NSUserNotificationDefaultSoundName];
if(shouldNotify) {
[self showIncomingNotification:call];
}
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
});
QObject::connect(&media::RecordingModel::instance(),
&media::RecordingModel::newTextMessage,
[=](media::TextRecording* t, ContactMethod* cm) {
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::Notifications];
auto qIdx = t->instantTextMessagingModel()->index(t->instantTextMessagingModel()->rowCount()-1, 0);
// Don't show a notification if we are sending the text OR window already has focus OR user disabled notifications
if(qvariant_cast<media::Media::Direction>(qIdx.data((int)media::TextRecording::Role::Direction)) == media::Media::Direction::OUT
|| self.ringWindowController.window.isMainWindow || !shouldNotify)
QObject::connect(&lrc->getBehaviorController(),
&lrc::api::BehaviorController::newUnreadInteraction,
[self] (const std::string& accountId, const std::string& conversation,
uint64_t interactionId, const lrc::api::interaction::Info& interaction) {
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::MessagesNotifications];
if(!shouldNotify) {
return;
}
NSUserNotification* notification = [[NSUserNotification alloc] init];
NSString* localizedTitle = [NSString stringWithFormat:NSLocalizedString(@"Message from %@", @"Message from {Name}"), qIdx.data((int)media::TextRecording::Role::AuthorDisplayname).toString().toNSString()];
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
userInfo[ACCOUNT_ID] = @(accountId.c_str());
userInfo[CONVERSATION_ID] = @(conversation.c_str());
userInfo[NOTIFICATION_TYPE] = MESSAGE_NOTIFICATION;
NSString* name = @(interaction.authorUri.c_str());
auto convIt = getConversationFromUid(conversation, *lrc->getAccountModel().getAccountInfo(accountId).conversationModel.get());
auto convQueue = lrc->getAccountModel().getAccountInfo(accountId).conversationModel.get()->allFilteredConversations();
if (convIt != convQueue.end()) {
name = bestIDForConversation(*convIt, *lrc->getAccountModel().getAccountInfo(accountId).conversationModel.get());
}
NSString* localizedTitle = [NSString stringWithFormat:
NSLocalizedString(@"Incoming message from %@",@"Incoming message from {Name}"),
name];
[notification setTitle:localizedTitle];
[notification setSoundName:NSUserNotificationDefaultSoundName];
[notification setSubtitle:qIdx.data().toString().toNSString()];
[notification setSubtitle:@(interaction.body.c_str())];
[notification setUserInfo: userInfo];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
});
}
- (void) showIncomingNotification:(Call*) call{
NSUserNotification* notification = [[NSUserNotification alloc] init];
NSString* localizedTitle = [NSString stringWithFormat:
NSLocalizedString(@"Incoming call from %@", @"Incoming call from {Name}"), call->peerName().toNSString()];
[notification setTitle:localizedTitle];
[notification setSoundName:NSUserNotificationDefaultSoundName];
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didDismissAlert:(NSUserNotification *)alert {
// check if user click refuse on incoming call notifications
if(alert.activationType != NSUserNotificationActivationTypeNone) {
return;
}
// try to activate action button
@try {
[notification setValue:@YES forKey:@"_showsButtons"];
auto info = alert.userInfo;
if(!info) {
return;
}
@catch (NSException *exception) {
// private API _showsButtons has changed...
NSLog(@"Action button not activable on notification");
NSString* identifier = info[NOTIFICATION_TYPE];
NSString* callId = info[CALL_ID];
NSString* accountId = info[ACCOUNT_ID];
if(!identifier || !callId || !accountId) {
return;
}
if([identifier isEqualToString: CALL_NOTIFICATION]) {
auto accountInfo = &lrc->getAccountModel().getAccountInfo([accountId UTF8String]);
if (accountInfo == nil)
return;
auto* callModel = accountInfo->callModel.get();
callModel->hangUp([callId UTF8String]);
}
[notification setActionButtonTitle:NSLocalizedString(@"Refuse", @"Button Action")];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
if(notification.activationType == NSUserNotificationActivationTypeActionButtonClicked) {
CallModel::instance().selectedCall() << Call::Action::REFUSE;
} else {
[NSApp activateIgnoringOtherApps:YES];
if ([self.ringWindowController.window isMiniaturized]) {
auto info = notification.userInfo;
if(!info) {
return;
}
NSString* identifier = info[NOTIFICATION_TYPE];
if([identifier isEqualToString: CALL_NOTIFICATION]) {
if(notification.activationType == NSUserNotificationActivationTypeActionButtonClicked
|| notification.activationType == NSUserNotificationActivationTypeContentsClicked) {
NSString* callId = info[CALL_ID];
NSString* accountId = info[ACCOUNT_ID];
NSString *conversationId = info[CONVERSATION_ID];
auto accountInfo = &lrc->getAccountModel().getAccountInfo([accountId UTF8String]);
if (accountInfo == nil)
return;
auto* callModel = accountInfo->callModel.get();
callModel->accept([callId UTF8String]);
[self.ringWindowController.window deminiaturize:self];
[_ringWindowController showCall:callId forAccount:accountId forConversation:conversationId];
}
} else if(notification.activationType == NSUserNotificationActivationTypeContentsClicked) {
[self.ringWindowController.window deminiaturize:self];
if([identifier isEqualToString: MESSAGE_NOTIFICATION]) {
NSString* accountId = info[ACCOUNT_ID];
NSString *conversationId = info[CONVERSATION_ID];
[_ringWindowController showConversation:conversationId forAccount:accountId];
} else if([identifier isEqualToString: CONTACT_REQUEST_NOTIFICATION]) {
NSString* accountId = info[ACCOUNT_ID];
NSString *contactUri = info[CONTACT_URI];
[_ringWindowController showContactRequestFor:accountId contactUri: contactUri];
}
}
[[NSUserNotificationCenter defaultUserNotificationCenter] removeAllDeliveredNotifications];
}
- (void) showWizard
......@@ -331,7 +408,6 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
}
[self.wizard close];
[self.ringWindowController close];
delete CallModel::instance().QObject::parent();
[[NSApplication sharedApplication] terminate:self];
}
......
......@@ -42,11 +42,10 @@ namespace lrc {
@property (retain, nonatomic) id <ChooseAccountDelegate> delegate;
@property (readonly) const lrc::api::account::Info& selectedAccount;
//@property const lrc::api::NewAccountModel* accMdl_;
-(void) enable;
-(void) disable;
//-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil model:(lrc::api::NewAccountModel*) accMdl delegate:(id <ChooseAccountDelegate> )mainWindow;
-(void) updateWithDelegate:(id <ChooseAccountDelegate> )mainWindow andModel:(lrc::api::NewAccountModel*) accMdl;
- (void)selectAccount:(NSString*)accountID;
@end
......@@ -393,4 +393,14 @@ NSMutableDictionary* menuItemsTags;
[accountSelectionButton setEnabled:NO];
}
- (void)selectAccount:(NSString*)accountID {
auto accList = accMdl_->getAccountList();
if(std::find(accList.begin(), accList.end(), [accountID UTF8String]) != accList.end()) {
auto& account = accMdl_->getAccountInfo([accountID UTF8String]);
[accountSelectionManager_ setSavedAccount:account];
[self updatePhoto];
[self setPopUpButtonSelection];
}
}
@end
......@@ -30,7 +30,11 @@ namespace Preferences {
/* KVO compliant */
NSString * const WindowBehaviour = @"window_behaviour";
/* KVO compliant */
NSString * const Notifications = @"enable_notifications";
NSString * const CallNotifications = @"enable_call_notifications";
/* KVO compliant */
NSString * const MessagesNotifications = @"enable_messages_notifications";
/* KVO compliant */
NSString * const ContactRequestNotifications = @"enable_invitations_notifications";
/* download folder for incoming images*/
NSString * const DownloadFolder = @"download_folder";
}
......@@ -18,20 +18,7 @@
*/
#import "GeneralPrefsVC.h"
#import <Quartz/Quartz.h>
//Qt
#import <QSize>
#import <QtMacExtras/qmacfunctions.h>
#import <QPixmap>
//LRC
#import <categorizedhistorymodel.h>
#import <profilemodel.h>
#import <profile.h>
#import <person.h>
#import <globalinstances.h>
#import <media/recordingmodel.h>
//lrc
#import <api/datatransfermodel.h>
#if ENABLE_SPARKLE
......@@ -39,22 +26,13 @@
#endif
#import "Constants.h"
#import "views/NSImage+Extensions.h"
#import "delegates/ImageManipulationDelegate.h"
#import "utils.h"
@interface GeneralPrefsVC () {
__unsafe_unretained IBOutlet NSTextField* historyChangedLabel;
__unsafe_unretained IBOutlet NSButton* startUpButton;
__unsafe_unretained IBOutlet NSButton* toggleAutomaticUpdateCheck;
__unsafe_unretained IBOutlet NSPopUpButton* checkIntervalPopUp;
__unsafe_unretained IBOutlet NSView* sparkleContainer;
__unsafe_unretained IBOutlet NSTextField* historyTextField;
__unsafe_unretained IBOutlet NSStepper* historyStepper;
__unsafe_unretained IBOutlet NSButton* historySwitch;
__unsafe_unretained IBOutlet NSButton* photoView;
__unsafe_unretained IBOutlet NSTextField* profileNameField;
__unsafe_unretained IBOutlet NSImageView* addProfilePhotoImage;
__unsafe_unretained IBOutlet NSButton *downloadFolder;
__unsafe_unretained IBOutlet NSTextField *downloadFolderLabel;
}
......@@ -77,18 +55,7 @@
- (void)loadView
{
[super loadView];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::HistoryLimit options:NSKeyValueObservingOptionNew context:NULL];
[startUpButton setState:[self isLaunchAtStartup]];
int historyLimit = CategorizedHistoryModel::instance().historyLimit();
[historyTextField setStringValue:[NSString stringWithFormat:@"%d", historyLimit]];
[historyStepper setIntValue:historyLimit];
BOOL limited = CategorizedHistoryModel::instance().isHistoryLimited();
[historySwitch setState:limited];
[historyStepper setEnabled:limited];
[historyTextField setEnabled:limited];
#if ENABLE_SPARKLE
[sparkleContainer setHidden:NO];
SUUpdater *updater = [SUUpdater sharedUpdater];
......@@ -99,23 +66,6 @@
#else
[sparkleContainer setHidden:YES];
#endif
[photoView setWantsLayer: YES];
photoView.layer.cornerRadius = photoView.frame.size.width / 2;
photoView.layer.masksToBounds = YES;
[addProfilePhotoImage setWantsLayer: YES];
[addProfilePhotoImage setHidden:NO];
[photoView setBordered:YES];
if (auto pro = ProfileModel::instance().selectedProfile()) {
[profileNameField setStringValue:pro->person()->formattedName().toNSString()];
if (pro->person() && pro->person()->photo().isValid()) {
auto photo = GlobalInstances::pixmapManipulator().contactPhoto(pro->person(), {140,140});
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
[addProfilePhotoImage setHidden:YES];
[photoView setBordered:NO];
}
}
if (appSandboxed()) {
[downloadFolder setHidden:YES];
[downloadFolder setEnabled:NO];
......@@ -127,27 +77,6 @@
}
}
- (void) dealloc
{
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:Preferences::HistoryLimit];
}
- (IBAction)clearHistory:(id)sender {
CategorizedHistoryModel::instance().clearAllCollections();
media::RecordingModel::instance().clearAllCollections();
[historyChangedLabel setHidden:NO];
}
- (IBAction)toggleHistory:(NSButton*)sender {
CategorizedHistoryModel::instance().setHistoryLimited([sender state]);
int historyLimit = CategorizedHistoryModel::instance().historyLimit();
[historyTextField setStringValue:[NSString stringWithFormat:@"%d", historyLimit]];
[historyStepper setIntValue:historyLimit];
[historyChangedLabel setHidden:NO];
[historyStepper setEnabled:[sender state]];
[historyTextField setEnabled:[sender state]];
}
- (IBAction)changeDownloadFolder:(id)sender {
NSOpenPanel *panel = [NSOpenPanel openPanel];
......@@ -163,16 +92,6 @@
[[NSUserDefaults standardUserDefaults] setObject:path forKey:Preferences::DownloadFolder];
}
// KVO handler
-(void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject
change:(NSDictionary *)aChange context:(void *)aContext
{
if ([aKeyPath isEqualToString:Preferences::HistoryLimit]) {
CategorizedHistoryModel::instance().setHistoryLimit([[aChange objectForKey: NSKeyValueChangeNewKey] integerValue]);
[historyChangedLabel setHidden:NO];
}
}
#pragma mark - Startup API
// MIT license by Brian Dunagan
......@@ -238,48 +157,6 @@
return itemRef;
}
#pragma mark - Profile Photo edition
- (IBAction) editPhoto:(id)sender {
auto pictureTaker = [IKPictureTaker pictureTaker];
[pictureTaker beginPictureTakerSheetForWindow:self.view.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 setImage:outputImage];
[addProfilePhotoImage setHidden:YES];
[photoView setBordered:NO];
if (auto pro = ProfileModel::instance().selectedProfile()) {
QPixmap p;
auto smallImg = [NSImage imageResize:outputImage newSize:{100,100}];
if (p.loadFromData(QByteArray::fromNSData([smallImg TIFFRepresentation]))) {
pro->person()->setPhoto(QVariant(p));
}
pro->save();
}
} else if (!photoView.image){
[addProfilePhotoImage setHidden:NO];
[photoView setBordered:YES];
}
}
#pragma mark - NSTextFieldDelegate methods
-(void)controlTextDidChange:(NSNotification *)notif
{
if (auto pro = ProfileModel::instance().selectedProfile()) {
pro->person()->setFormattedName(profileNameField.stringValue.UTF8String);
pro->save();
}
}
#pragma mark - NSOpenSavePanelDelegate delegate methods
- (BOOL) panel:(id)sender shouldEnableURL:(NSURL*)url {
......
......@@ -68,4 +68,8 @@ namespace lrc {
*/
-(void) listTypeChanged;
-(void) showConversation:(NSString* )conversationId forAccount:(NSString*)accountId;
-(void) showCall:(NSString* )callId forAccount:(NSString*)accountId forConversation:(NSString*)conversationId;
-(void) showContactRequestFor:(NSString* )accountId contactUri:(NSString*)uri;
@end
......@@ -535,4 +535,57 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
[smartViewVC reloadConversationWithUid:@(conversationID.c_str())];
}
-(void) showConversation:(NSString* )conversationId forAccount:(NSString*)accountId {
auto& accInfo = self.accountModel->getAccountInfo([accountId UTF8String]);
[chooseAccountVC selectAccount: accountId];
[settingsVC setSelectedAccount: [accountId UTF8String]];
[smartViewVC setConversationModel:accInfo.conversationModel.get()];
[smartViewVC selectConversationList];
[self updateRingID];
auto convInfo = getConversationFromUid([conversationId UTF8String], *accInfo.conversationModel.get());
auto convQueue = accInfo.conversationModel.get()->allFilteredConversations();
if (convInfo != convQueue.end()) {
[conversationVC setConversationUid:convInfo->uid model:accInfo.conversationModel.get()];
[smartViewVC selectConversation: *convInfo model:accInfo.conversationModel.get()];
accInfo.conversationModel.get()->clearUnreadInteractions([conversationId UTF8String]);
}
[self changeViewTo:SHOW_CONVERSATION_SCREEN];
}
-(void) showCall:(NSString* )callId forAccount:(NSString*)accountId forConversation:(NSString*)conversationId {
auto& accInfo = self.accountModel->getAccountInfo([accountId UTF8String]);
[chooseAccountVC selectAccount: accountId];
[settingsVC setSelectedAccount:accInfo.id];
[smartViewVC setConversationModel:accInfo.conversationModel.get()];
[self updateRingID];
auto convInfo = getConversationFromUid([conversationId UTF8String], *accInfo.conversationModel.get());
auto convQueue = accInfo.conversationModel.get()->allFilteredConversations();
if (convInfo != convQueue.end()) {
if (accInfo.contactModel->getContact(convInfo->participants[0]).profileInfo.type == lrc::api::profile::Type::PENDING)
[smartViewVC selectPendingList];
else
[smartViewVC selectConversationList];
[smartViewVC selectConversation: *convInfo model:accInfo.conversationModel.get()];
}
[currentCallVC setCurrentCall:[callId UTF8String]
conversation:[conversationId UTF8String]
account:&accInfo];
[self changeViewTo:SHOW_CALL_SCREEN];
}
-(void) showContactRequestFor:(NSString* )accountId contactUri:(NSString*)uri {
auto& accInfo = self.accountModel->getAccountInfo([accountId UTF8String]);
[chooseAccountVC selectAccount: accountId];
[settingsVC setSelectedAccount:accInfo.id];
[smartViewVC setConversationModel:accInfo.conversationModel.get()];
[self updateRingID];
[smartViewVC selectPendingList];
auto convInfo = getConversationFromURI([uri UTF8String], *accInfo.conversationModel.get());
auto convQueue = accInfo.conversationModel.get()->allFilteredConversations();
if (convInfo != convQueue.end()) {
[conversationVC setConversationUid:convInfo->uid model:accInfo.conversationModel.get()];
[smartViewVC selectConversation: *convInfo model:accInfo.conversationModel.get()];
}
[self changeViewTo:SHOW_CONVERSATION_SCREEN];
}
@end
......@@ -175,6 +175,7 @@
}
// enable Notifications
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::Notifications];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::CallNotifications];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::MessagesNotifications];
}
@end
......@@ -321,7 +321,8 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
}
// enable Notifications
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::Notifications];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::CallNotifications];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::MessagesNotifications];
}
- (IBAction)cancel:(id)sender
......
......@@ -129,6 +129,19 @@ static inline lrc::api::ConversationModel::ConversationQueue::const_iterator get
});
}
/**
* This function return an iterator pointing to a Conversation::Info in ConversationModel given its participant uri. Will not work for group chat.
* @param uri URI of participant
* @param model ConversationModel in which to do the lookup
* @return iterator pointing to corresponding Conversation if any. Points to past-the-end element otherwise.
*/
static inline lrc::api::ConversationModel::ConversationQueue::const_iterator getConversationFromURI(const std::string& uri, const lrc::api::ConversationModel& model) {
return std::find_if(model.allFilteredConversations().begin(), model.allFilteredConversations().end(),
[&] (const lrc::api::conversation::Info& conv) {
return uri == conv.participants[0];
});
}
static inline void
setVideoAutoQuality(bool autoQuality, std::string accountId)
{
......
......@@ -44,8 +44,8 @@
/* Class = "NSTextFieldCell"; title = "Update"; ObjectID = "r4u-t3-gBc"; */
"r4u-t3-gBc.title" = "Update";
/* Class = "NSButtonCell"; title = "Enable Desktop Notifications"; ObjectID = "uCL-ye-tsv"; */