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;
#else
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
#endif
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutLogUnsatisfiable"];
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"__NSConstraintBasedLayoutLogUnsatisfiable"];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
......@@ -103,6 +100,7 @@ std::unique_ptr<lrc::api::Lrc> lrc;
lrc = std::make_unique<lrc::api::Lrc>();
if([self checkForRingAccount]) {
[self setRingtonePath];
[self showMainWindow];
} else {
[self showWizard];
......@@ -353,6 +351,19 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
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
{
return !lrc->getAccountModel().getAccountList().empty();
......
......@@ -112,6 +112,9 @@
return;
}
[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];
QObject::disconnect(accountCreated);
QObject::disconnect(accountRemoved);
......
......@@ -285,7 +285,9 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
NSString *usernameString = self.registeredName;
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.delegate didCreateAccountWithSuccess:YES];
});
......
......@@ -31,6 +31,10 @@
#import <api/contactmodel.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)
{
try {
......@@ -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)
{
@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