Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
62d39d71
Commit
62d39d71
authored
1 year ago
by
Kateryna Kostiuk
Browse files
Options
Downloads
Patches
Plain Diff
account: do not load accounts and configurations when autoload not enabled
Change-Id: I89e11e723ab0cc53c8e025bb9aa4a0b8322ec82c
parent
ff9e9bd4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/manager.cpp
+62
-36
62 additions, 36 deletions
src/manager.cpp
src/manager.h
+2
-0
2 additions, 0 deletions
src/manager.h
with
64 additions
and
36 deletions
src/manager.cpp
+
62
−
36
View file @
62d39d71
...
...
@@ -143,6 +143,8 @@ bool Manager::isIOSExtension = {false};
bool
Manager
::
syncOnRegister
=
{
true
};
bool
Manager
::
autoLoad
=
{
true
};
static
void
copy_over
(
const
std
::
filesystem
::
path
&
srcPath
,
const
std
::
filesystem
::
path
&
destPath
)
{
...
...
@@ -818,11 +820,9 @@ Manager::init(const std::filesystem::path& config_file, libjami::InitFlag flags)
// So only create the SipLink once
pimpl_
->
sipLink_
=
std
::
make_unique
<
SIPVoIPLink
>
();
check_rename
(
fileutils
::
get_cache_dir
(
PACKAGE_OLD
),
fileutils
::
get_cache_dir
());
check_rename
(
fileutils
::
get_cache_dir
(
PACKAGE_OLD
),
fileutils
::
get_cache_dir
());
check_rename
(
fileutils
::
get_data_dir
(
PACKAGE_OLD
),
fileutils
::
get_data_dir
());
check_rename
(
fileutils
::
get_config_dir
(
PACKAGE_OLD
),
fileutils
::
get_config_dir
());
check_rename
(
fileutils
::
get_config_dir
(
PACKAGE_OLD
),
fileutils
::
get_config_dir
());
pimpl_
->
ice_tf_
=
std
::
make_shared
<
dhtnet
::
IceTransportFactory
>
(
Logger
::
dhtLogger
());
...
...
@@ -838,28 +838,33 @@ Manager::init(const std::filesystem::path& config_file, libjami::InitFlag flags)
// manager can restart without being recreated (Unit tests)
pimpl_
->
finished_
=
false
;
try
{
no_errors
=
pimpl_
->
parseConfiguration
();
}
catch
(
const
YAML
::
Exception
&
e
)
{
JAMI_ERR
(
"%s"
,
e
.
what
());
no_errors
=
false
;
}
// always back up last error-free configuration
if
(
no_errors
)
{
make_backup
(
pimpl_
->
path_
);
if
(
libjami
::
LIBJAMI_FLAG_NO_AUTOLOAD
&
flags
)
{
autoLoad
=
false
;
JAMI_DBG
(
"LIBJAMI_FLAG_NO_AUTOLOAD is set, accounts will neither be loaded nor backed up"
);
}
else
{
// restore previous configuration
JAMI_WARNING
(
"Restoring last working configuration"
);
try
{
// remove accounts from broken configuration
removeAccounts
();
restore_backup
(
pimpl_
->
path_
);
pimpl_
->
parseConfiguration
();
no_errors
=
pimpl_
->
parseConfiguration
();
}
catch
(
const
YAML
::
Exception
&
e
)
{
JAMI_ERROR
(
"{}"
,
e
.
what
());
JAMI_WARNING
(
"Restoring backup failed"
);
JAMI_ERR
(
"%s"
,
e
.
what
());
no_errors
=
false
;
}
// always back up last error-free configuration
if
(
no_errors
)
{
make_backup
(
pimpl_
->
path_
);
}
else
{
// restore previous configuration
JAMI_WARNING
(
"Restoring last working configuration"
);
try
{
// remove accounts from broken configuration
removeAccounts
();
restore_backup
(
pimpl_
->
path_
);
pimpl_
->
parseConfiguration
();
}
catch
(
const
YAML
::
Exception
&
e
)
{
JAMI_ERROR
(
"{}"
,
e
.
what
());
JAMI_WARNING
(
"Restoring backup failed"
);
}
}
}
...
...
@@ -3053,21 +3058,42 @@ Manager::setAccountActive(const std::string& accountID, bool active, bool shutdo
void
Manager
::
loadAccountAndConversation
(
const
std
::
string
&
accountID
,
const
std
::
string
&
convID
)
{
if
(
const
auto
a
=
getAccount
(
accountID
))
{
a
->
enableAutoLoadConversations
(
false
);
if
(
a
->
getRegistrationState
()
==
RegistrationState
::
UNLOADED
)
{
a
->
loadConfig
();
}
a
->
setActive
(
true
);
if
(
a
->
isUsable
())
a
->
doRegister
();
if
(
auto
jamiAcc
=
std
::
dynamic_pointer_cast
<
JamiAccount
>
(
a
))
{
// load requests before loading conversation
if
(
auto
convModule
=
jamiAcc
->
convModule
())
{
convModule
->
reloadRequests
();
auto
account
=
getAccount
(
accountID
);
if
(
!
account
&&
!
autoLoad
)
{
/*
With the LIBJAMI_FLAG_NO_AUTOLOAD flag active, accounts are not
automatically created during manager initialization, nor are
their configurations set or backed up. This is because account
creation triggers the initialization of the certStore. There why
account creation now occurs here in response to a received notification.
*/
auto
accountBaseDir
=
fileutils
::
get_data_dir
();
auto
configFile
=
accountBaseDir
/
accountID
/
"config.yml"
;
try
{
if
(
account
=
accountFactory
.
createAccount
(
JamiAccount
::
ACCOUNT_TYPE
,
accountID
))
{
account
->
enableAutoLoadConversations
(
false
);
auto
configNode
=
YAML
::
LoadFile
(
configFile
.
string
());
auto
config
=
account
->
buildConfig
();
config
->
unserialize
(
configNode
);
account
->
setConfig
(
std
::
move
(
config
));
}
jamiAcc
->
loadConversation
(
convID
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
JAMI_WARN
(
"Account loading failed: %s"
,
e
.
what
());
return
;
}
}
if
(
!
account
)
{
JAMI_WARN
(
"Could not load account %s"
,
accountID
.
c_str
());
return
;
}
if
(
auto
jamiAcc
=
std
::
dynamic_pointer_cast
<
JamiAccount
>
(
account
))
{
jamiAcc
->
setActive
(
true
);
if
(
jamiAcc
->
isUsable
())
jamiAcc
->
doRegister
();
if
(
auto
convModule
=
jamiAcc
->
convModule
())
{
convModule
->
reloadRequests
();
}
jamiAcc
->
loadConversation
(
convID
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/manager.h
+
2
−
0
View file @
62d39d71
...
...
@@ -124,6 +124,8 @@ public:
static
bool
syncOnRegister
;
static
bool
autoLoad
;
/**
* Initialisation of thread (sound) and map.
* Init a new VoIPLink, audio codec and audio driver.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment