Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-libclient
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-libclient
Commits
6765592b
Commit
6765592b
authored
5 years ago
by
Sébastien Blin
Committed by
Adrien Béraud
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
accountmodel: avoid invalid pointer, just update current structure
Change-Id: I237dfce4089ec97f91b8fa4b7b188a6f1f339883
parent
1a48e70a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/newaccountmodel.cpp
+35
-22
35 additions, 22 deletions
src/newaccountmodel.cpp
with
35 additions
and
22 deletions
src/newaccountmodel.cpp
+
35
−
22
View file @
6765592b
...
@@ -103,6 +103,12 @@ public:
...
@@ -103,6 +103,12 @@ public:
*/
*/
void
updateAccounts
();
void
updateAccounts
();
/**
* Update accountInfo with details from daemon
* @param account account to update
*/
void
updateAccountDetails
(
account
::
Info
&
account
);
public
Q_SLOTS
:
public
Q_SLOTS
:
/**
/**
...
@@ -438,6 +444,32 @@ NewAccountModelPimpl::updateAccounts()
...
@@ -438,6 +444,32 @@ NewAccountModelPimpl::updateAccounts()
}
}
}
}
void
NewAccountModelPimpl
::
updateAccountDetails
(
account
::
Info
&
accountInfo
)
{
// Fill account::Info struct with details from daemon
MapStringString
details
=
ConfigurationManager
::
instance
().
getAccountDetails
(
accountInfo
.
id
);
accountInfo
.
fromDetails
(
details
);
// Fill account::Info::confProperties credentials
VectorMapStringString
credGet
=
ConfigurationManager
::
instance
().
getCredentials
(
accountInfo
.
id
);
VectorMapStringString
credToStore
;
for
(
auto
const
&
i
:
credGet
.
toStdVector
())
{
MapStringString
credMap
;
for
(
auto
const
&
j
:
i
.
toStdMap
())
{
credMap
[
j
.
first
]
=
j
.
second
;
}
credToStore
.
push_back
(
credMap
);
}
accountInfo
.
confProperties
.
credentials
.
swap
(
credToStore
);
MapStringString
volatileDetails
=
ConfigurationManager
::
instance
().
getVolatileAccountDetails
(
accountInfo
.
id
);
QString
daemonStatus
=
volatileDetails
[
DRing
::
Account
::
ConfProperties
::
Registration
::
STATUS
];
accountInfo
.
status
=
lrc
::
api
::
account
::
to_status
(
daemonStatus
);
}
void
void
NewAccountModelPimpl
::
slotAccountStatusChanged
(
const
QString
&
accountID
,
const
api
::
account
::
Status
status
)
NewAccountModelPimpl
::
slotAccountStatusChanged
(
const
QString
&
accountID
,
const
api
::
account
::
Status
status
)
{
{
...
@@ -460,8 +492,8 @@ NewAccountModelPimpl::slotAccountStatusChanged(const QString& accountID, const a
...
@@ -460,8 +492,8 @@ NewAccountModelPimpl::slotAccountStatusChanged(const QString& accountID, const a
// Detect when a new account is generated (keys are ready). During
// Detect when a new account is generated (keys are ready). During
// the generation, a Ring account got the "INITIALIZING" status.
// the generation, a Ring account got the "INITIALIZING" status.
// When keys are generated, the status will change.
// When keys are generated, the status will change.
accounts
.
erase
(
accountID
);
// The account is already added and initialized. Just update details from daemon
addTo
Accounts
(
accountI
D
);
update
Account
Detail
s
(
accountI
nfo
);
emit
linked
.
accountAdded
(
accountID
);
emit
linked
.
accountAdded
(
accountID
);
}
else
if
(
!
accountInfo
.
profileInfo
.
uri
.
isEmpty
())
{
}
else
if
(
!
accountInfo
.
profileInfo
.
uri
.
isEmpty
())
{
accountInfo
.
status
=
status
;
accountInfo
.
status
=
status
;
...
@@ -642,23 +674,7 @@ NewAccountModelPimpl::addToAccounts(const QString& accountId,
...
@@ -642,23 +674,7 @@ NewAccountModelPimpl::addToAccounts(const QString& accountId,
account
::
Info
&
newAccInfo
=
(
it
.
first
)
->
second
.
first
;
account
::
Info
&
newAccInfo
=
(
it
.
first
)
->
second
.
first
;
newAccInfo
.
id
=
accountId
;
newAccInfo
.
id
=
accountId
;
newAccInfo
.
profileInfo
.
avatar
=
authority
::
storage
::
getAccountAvatar
(
accountId
);
newAccInfo
.
profileInfo
.
avatar
=
authority
::
storage
::
getAccountAvatar
(
accountId
);
updateAccountDetails
(
newAccInfo
);
// Fill account::Info struct with details from daemon
MapStringString
details
=
ConfigurationManager
::
instance
().
getAccountDetails
(
accountId
);
newAccInfo
.
fromDetails
(
details
);
// Fill account::Info::confProperties credentials
VectorMapStringString
credGet
=
ConfigurationManager
::
instance
().
getCredentials
(
accountId
);
VectorMapStringString
credToStore
;
for
(
auto
const
&
i
:
credGet
.
toStdVector
())
{
MapStringString
credMap
;
for
(
auto
const
&
j
:
i
.
toStdMap
())
{
credMap
[
j
.
first
]
=
j
.
second
;
}
credToStore
.
push_back
(
credMap
);
}
newAccInfo
.
confProperties
.
credentials
.
swap
(
credToStore
);
// Init models for this account
// Init models for this account
newAccInfo
.
accountModel
=
&
linked
;
newAccInfo
.
accountModel
=
&
linked
;
...
@@ -669,9 +685,6 @@ NewAccountModelPimpl::addToAccounts(const QString& accountId,
...
@@ -669,9 +685,6 @@ NewAccountModelPimpl::addToAccounts(const QString& accountId,
newAccInfo
.
deviceModel
=
std
::
make_unique
<
NewDeviceModel
>
(
newAccInfo
,
callbacksHandler
);
newAccInfo
.
deviceModel
=
std
::
make_unique
<
NewDeviceModel
>
(
newAccInfo
,
callbacksHandler
);
newAccInfo
.
codecModel
=
std
::
make_unique
<
NewCodecModel
>
(
newAccInfo
,
callbacksHandler
);
newAccInfo
.
codecModel
=
std
::
make_unique
<
NewCodecModel
>
(
newAccInfo
,
callbacksHandler
);
MapStringString
volatileDetails
=
ConfigurationManager
::
instance
().
getVolatileAccountDetails
(
accountId
);
auto
daemonStatus
=
volatileDetails
[
DRing
::
Account
::
ConfProperties
::
Registration
::
STATUS
];
newAccInfo
.
status
=
lrc
::
api
::
account
::
to_status
(
daemonStatus
);
}
}
void
void
...
...
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