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
GitLab 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
452317eb
Commit
452317eb
authored
10 years ago
by
Emmanuel Lepage Vallee
Browse files
Options
Downloads
Patches
Plain Diff
[ #54786 ] Add more comments to the getNumber() algo
Those future improvments were raised during a code review
parent
1db25f07
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/phonedirectorymodel.cpp
+16
-12
16 additions, 12 deletions
src/phonedirectorymodel.cpp
src/phonedirectorymodel.h
+1
-1
1 addition, 1 deletion
src/phonedirectorymodel.h
with
17 additions
and
13 deletions
src/phonedirectorymodel.cpp
+
16
−
12
View file @
452317eb
...
...
@@ -324,10 +324,11 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, Account* account
}
///Add new information to existing numbers and try to merge
PhoneNumber
*
PhoneDirectoryModel
::
fillDetails
(
NumberWrapper
*
wrap
,
const
URI
&
strippedUri
,
Account
*
account
,
Contact
*
contact
,
const
QString
&
type
,
bool
&
hasContact
)
PhoneNumber
*
PhoneDirectoryModel
::
fillDetails
(
NumberWrapper
*
wrap
,
const
URI
&
strippedUri
,
Account
*
account
,
Contact
*
contact
,
const
QString
&
type
)
{
//TODO pick the best URI
//TODO the account hostname change corner case
//TODO search for account that has the same hostname as the URI
if
(
wrap
)
{
foreach
(
PhoneNumber
*
number
,
wrap
->
numbers
)
{
...
...
@@ -364,6 +365,8 @@ PhoneNumber* PhoneDirectoryModel::fillDetails(NumberWrapper* wrap, const URI& st
));
//TODO the Display name could be used to influence the choice
//It would need to ignore all possible translated values of unknown
//and only be available when another information match
//If everything match, set the contact
if
(
hasCompatibleAccount
)
...
...
@@ -385,8 +388,6 @@ PhoneNumber* PhoneDirectoryModel::fillDetails(NumberWrapper* wrap, const URI& st
number
->
setCategory
(
NumberCategoryModel
::
instance
()
->
getCategory
(
type
));
}
hasContact
|=
number
->
contact
()
!=
nullptr
;
//We already have enough information to confirm the choice
if
(
contact
&&
number
->
contact
()
&&
((
contact
->
uid
())
==
number
->
contact
()
->
uid
()))
return
number
;
...
...
@@ -432,12 +433,9 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, const QString& t
///Create a number when a more information is available duplicated ones
PhoneNumber
*
PhoneDirectoryModel
::
getNumber
(
const
QString
&
uri
,
Contact
*
contact
,
Account
*
account
,
const
QString
&
type
)
{
//Remove extra data such as "<sip:" from the main URI
const
URI
strippedUri
(
uri
);
//Try to use a PhoneNumber with a contact when possible, work only after the
//contact are loaded
bool
hasContact
(
false
),
hasContact2
(
false
);
//See if the number is already loaded
NumberWrapper
*
wrap
=
m_hDirectory
[
strippedUri
];
NumberWrapper
*
wrap2
=
nullptr
;
...
...
@@ -452,13 +450,16 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, Contact* contact
}
//Check
PhoneNumber
*
confirmedCandidate
=
fillDetails
(
wrap
,
strippedUri
,
account
,
contact
,
type
,
hasContact
);
PhoneNumber
*
confirmedCandidate
=
fillDetails
(
wrap
,
strippedUri
,
account
,
contact
,
type
);
//URIs can be represented in multiple way, check if a more verbose version
//already exist
PhoneNumber
*
confirmedCandidate2
=
nullptr
;
if
(
!
hasContact
)
confirmedCandidate2
=
fillDetails
(
wrap2
,
strippedUri
,
account
,
contact
,
type
,
hasContact2
);
//Try to use a PhoneNumber with a contact when possible, work only after the
//contact are loaded
if
(
confirmedCandidate
&&
confirmedCandidate
->
contact
())
confirmedCandidate2
=
fillDetails
(
wrap2
,
strippedUri
,
account
,
contact
,
type
);
PhoneNumber
*
confirmedCandidate3
=
nullptr
;
...
...
@@ -492,7 +493,8 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, Contact* contact
confirmedCandidate
->
merge
(
confirmedCandidate2
);
}
//Empirical testing resulted in this as the best return order
//The merge may have failed either in the "if" above or in the merging code
if
(
confirmedCandidate2
)
return
confirmedCandidate2
;
if
(
confirmedCandidate
)
...
...
@@ -504,6 +506,8 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, Contact* contact
if
(
wrap
)
{
foreach
(
PhoneNumber
*
number
,
wrap
->
numbers
)
{
if
(((
!
account
)
||
number
->
account
()
==
account
)
&&
((
!
contact
)
||
((
*
contact
)
==
number
->
contact
())
||
(
!
number
->
contact
())))
{
//Assume this is valid until a smarter solution is implemented to merge both
//For a short time, a placeholder contact and a contact can coexist, drop the placeholder
if
(
contact
&&
(
!
number
->
contact
()
||
(
contact
->
uid
()
==
number
->
contact
()
->
uid
())))
number
->
setContact
(
contact
);
...
...
This diff is collapsed.
Click to expand it.
src/phonedirectorymodel.h
+
1
−
1
View file @
452317eb
...
...
@@ -117,7 +117,7 @@ private:
//Helpers
void
indexNumber
(
PhoneNumber
*
number
,
const
QStringList
&
names
);
void
setAccount
(
PhoneNumber
*
number
,
Account
*
account
);
PhoneNumber
*
fillDetails
(
NumberWrapper
*
wrap
,
const
URI
&
strippedUri
,
Account
*
account
,
Contact
*
contact
,
const
QString
&
type
,
bool
&
hasContact
);
PhoneNumber
*
fillDetails
(
NumberWrapper
*
wrap
,
const
URI
&
strippedUri
,
Account
*
account
,
Contact
*
contact
,
const
QString
&
type
);
//Singleton
static
PhoneDirectoryModel
*
m_spInstance
;
...
...
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