Commit 0c0801e2 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

fix: ringtone path

Change-Id: I4e7adc3493be7a862ba1d804e12a0c726c2ae696
parent 3cbc166a
...@@ -85,9 +85,6 @@ std::unique_ptr<lrc::api::Lrc> lrc; ...@@ -85,9 +85,6 @@ std::unique_ptr<lrc::api::Lrc> lrc;
#else #else
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"]; [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
#endif #endif
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutLogUnsatisfiable"];
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"__NSConstraintBasedLayoutLogUnsatisfiable"];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
...@@ -103,6 +100,7 @@ std::unique_ptr<lrc::api::Lrc> lrc; ...@@ -103,6 +100,7 @@ std::unique_ptr<lrc::api::Lrc> lrc;
lrc = std::make_unique<lrc::api::Lrc>(); lrc = std::make_unique<lrc::api::Lrc>();
if([self checkForRingAccount]) { if([self checkForRingAccount]) {
[self setRingtonePath];
[self showMainWindow]; [self showMainWindow];
} else { } else {
[self showWizard]; [self showWizard];
...@@ -353,6 +351,19 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet ...@@ -353,6 +351,19 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
return lrc->activeCalls(); return lrc->activeCalls();
} }
-(void)setRingtonePath {
std::vector<std::string> accounts = lrc->getAccountModel().getAccountList();
NSFileManager *fileManager = [NSFileManager defaultManager];
for (auto account: accounts) {
lrc::api::account::ConfProperties_t accountProperties = lrc->getAccountModel().getAccountConfig(account);
NSString *ringtonePath = @(accountProperties.Ringtone.ringtonePath.c_str());
if (![fileManager fileExistsAtPath: ringtonePath]) {
accountProperties.Ringtone.ringtonePath = [defaultRingtonePath() UTF8String];
lrc->getAccountModel().setAccountConfig(account, accountProperties);
}
}
}
- (BOOL) checkForRingAccount - (BOOL) checkForRingAccount
{ {
return !lrc->getAccountModel().getAccountList().empty(); return !lrc->getAccountModel().getAccountList().empty();
......
...@@ -112,6 +112,9 @@ ...@@ -112,6 +112,9 @@
return; return;
} }
[self.delegate didLinkAccountWithSuccess:YES]; [self.delegate didLinkAccountWithSuccess:YES];
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(accountID);
accountProperties.Ringtone.ringtonePath = [defaultRingtonePath() UTF8String];
self.accountModel->setAccountConfig(accountID, accountProperties);
[self registerDefaultPreferences]; [self registerDefaultPreferences];
QObject::disconnect(accountCreated); QObject::disconnect(accountCreated);
QObject::disconnect(accountRemoved); QObject::disconnect(accountRemoved);
......
...@@ -285,7 +285,9 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2; ...@@ -285,7 +285,9 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
NSString *usernameString = self.registeredName; NSString *usernameString = self.registeredName;
self.accountModel->registerName(accountID, [passwordString UTF8String], [usernameString UTF8String]); self.accountModel->registerName(accountID, [passwordString UTF8String], [usernameString UTF8String]);
} }
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(accountID);
accountProperties.Ringtone.ringtonePath = [defaultRingtonePath() UTF8String];
self.accountModel->setAccountConfig(accountID, accountProperties);
[self registerDefaultPreferences]; [self registerDefaultPreferences];
[self.delegate didCreateAccountWithSuccess:YES]; [self.delegate didCreateAccountWithSuccess:YES];
}); });
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
#import <api/contactmodel.h> #import <api/contactmodel.h>
#import <api/contact.h> #import <api/contact.h>
//Qt
#import <QtCore/QDir>
#import <qapplication.h>
static inline NSString* bestIDForConversation(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model) static inline NSString* bestIDForConversation(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{ {
try { try {
...@@ -101,6 +105,13 @@ static inline NSString* bestNameForConversation(const lrc::api::conversation::In ...@@ -101,6 +105,13 @@ static inline NSString* bestNameForConversation(const lrc::api::conversation::In
} }
} }
static inline NSString* defaultRingtonePath() {
QDir ringtonesDir(QCoreApplication::applicationDirPath());
ringtonesDir.cdUp();
ringtonesDir.cd("Resources/ringtones/");
return [ringtonesDir.path().toNSString() stringByAppendingString:@"/default.opus"];
}
static inline lrc::api::profile::Type profileType(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model) static inline lrc::api::profile::Type profileType(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{ {
@try { @try {
......
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