Skip to content
Snippets Groups Projects
Commit f703a3d2 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

iOS: add flag to avoid conversation sync on register

When an account is registered from the notification extension,
it only needs to fetch commits for one contact and not make
connections with other contacts, since the extension has limits
for time and memory.

It also do not need bootstrap conversation.

Change-Id: Ia5815dfc47176989c8df10766613f063d3211bee
parent 66cc843a
Branches
No related tags found
No related merge requests found
......@@ -42,7 +42,8 @@ enum InitFlag {
LIBJAMI_FLAG_IOS_EXTENSION = 1 << 4,
LIBJAMI_FLAG_NO_LOCAL_AUDIO = 1 << 6,
LIBJAMI_FLAG_NO_LOCAL_VIDEO = 1 << 7,
LIBJAMI_FLAG_NO_LOCAL_MEDIA = LIBJAMI_FLAG_NO_LOCAL_AUDIO | LIBJAMI_FLAG_NO_LOCAL_VIDEO
LIBJAMI_FLAG_NO_LOCAL_MEDIA = LIBJAMI_FLAG_NO_LOCAL_AUDIO | LIBJAMI_FLAG_NO_LOCAL_VIDEO,
LIBJAMI_FLAG_NO_AUTOSYNC = 1 << 8
};
/**
......
......@@ -1087,6 +1087,7 @@ JamiAccount::loadAccount(const std::string& archive_password,
[this](const std::string& uri, bool confirmed) {
if (!id_.first)
return;
if (jami::Manager::instance().syncOnRegister) {
dht::ThreadPool::io().run([w=weak(), uri, confirmed] {
if (auto shared = w.lock()) {
if (auto cm = shared->convModule()) {
......@@ -1097,6 +1098,7 @@ JamiAccount::loadAccount(const std::string& archive_password,
emitSignal<libjami::ConfigurationSignal::ContactAdded>(shared->getAccountID(), uri, confirmed);
}
});
}
},
[this](const std::string& uri, bool banned) {
if (!id_.first)
......@@ -1930,6 +1932,7 @@ JamiAccount::doRegister_()
setRegistrationState(state);
};
if (jami::Manager::instance().syncOnRegister) {
context.identityAnnouncedCb = [this](bool ok) {
if (!ok)
return;
......@@ -1971,6 +1974,7 @@ JamiAccount::doRegister_()
accountID_, getVolatileAccountDetails());
});
};
}
setRegistrationState(RegistrationState::TRYING);
dht_->run(dhtPortUsed(), config, std::move(context));
......
......@@ -141,6 +141,8 @@ std::atomic_bool Manager::initialized = {false};
bool Manager::isIOSExtension = {false};
#endif
bool Manager::syncOnRegister = {true};
static void
copy_over(const std::string& srcPath, const std::string& destPath)
{
......
......@@ -119,6 +119,8 @@ public:
static bool isIOSExtension;
#endif
static bool syncOnRegister;
/**
* Initialisation of thread (sound) and map.
* Init a new VoIPLink, audio codec and audio driver
......
......@@ -69,6 +69,8 @@ init(enum InitFlag flags) noexcept
if (flags & LIBJAMI_FLAG_IOS_EXTENSION)
manager.isIOSExtension = true;
#endif
if (flags & LIBJAMI_FLAG_NO_AUTOSYNC)
manager.syncOnRegister = false;
return true;
} catch (...) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment