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
b2c1f8d4
Commit
b2c1f8d4
authored
10 years ago
by
Emmanuel Lepage Vallee
Browse files
Options
Downloads
Patches
Plain Diff
[ #52259 ] Add more agressive phone number matching
parent
38a84336
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/phonedirectorymodel.cpp
+54
-3
54 additions, 3 deletions
src/phonedirectorymodel.cpp
with
54 additions
and
3 deletions
src/phonedirectorymodel.cpp
+
54
−
3
View file @
b2c1f8d4
...
@@ -315,23 +315,73 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, const QString& t
...
@@ -315,23 +315,73 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, const QString& t
return
number
;
return
number
;
}
}
/**
* This version of getNumber() try to get a phone number with a contact from an URI and account
* It will also try to attach an account to existing numbers. This is not 100% reliable, but
* it is correct often enough to do it.
*/
PhoneNumber
*
PhoneDirectoryModel
::
getNumber
(
const
QString
&
uri
,
Account
*
account
,
const
QString
&
type
)
PhoneNumber
*
PhoneDirectoryModel
::
getNumber
(
const
QString
&
uri
,
Account
*
account
,
const
QString
&
type
)
{
{
const
QString
strippedUri
=
PhoneNumber
::
stripUri
(
uri
);
const
QString
strippedUri
=
PhoneNumber
::
stripUri
(
uri
);
//Try to use a PhoneNumber with a contact when possible, work only after the
//contact are loaded
bool
hasContact
=
false
;
//See if the number is already loaded
//See if the number is already loaded
NumberWrapper
*
wrap
=
m_hDirectory
[
strippedUri
];
NumberWrapper
*
wrap
=
m_hDirectory
[
strippedUri
];
if
((
!
wrap
)
&&
account
&&
uri
.
indexOf
(
'@'
)
==
-
1
)
{
NumberWrapper
*
wrap2
=
nullptr
;
//Try to see if there is a better candidate with a suffix (LAN only)
if
(
uri
.
indexOf
(
'@'
)
==
-
1
)
{
//Append the account hostname
//Append the account hostname
wrap
=
m_hDirectory
[
strippedUri
+
'@'
+
account
->
hostname
()];
wrap
2
=
m_hDirectory
[
strippedUri
+
'@'
+
account
->
hostname
()];
}
}
if
(
wrap
)
{
if
(
wrap
)
{
foreach
(
PhoneNumber
*
number
,
wrap
->
numbers
)
{
foreach
(
PhoneNumber
*
number
,
wrap
->
numbers
)
{
//Not perfect, but better than ignoring the high probabilities
//Not perfect, but better than ignoring the high probabilities
//TODO only do it is hostname match
if
(
!
number
->
account
())
number
->
setAccount
(
account
);
if
((
!
number
->
m_hasType
)
&&
(
!
type
.
isEmpty
()))
{
number
->
setCategory
(
NumberCategoryModel
::
instance
()
->
getCategory
(
type
));
}
hasContact
|=
number
->
contact
()
!=
nullptr
;
}
}
//If the second candidate has a contact, choose it (LAN only)
if
(
wrap2
&&
(
!
hasContact
))
{
foreach
(
PhoneNumber
*
number
,
wrap2
->
numbers
)
{
//Not perfect, but better than ignoring the high probabilities
//TODO only do it is hostname match
if
(
!
number
->
account
())
if
(
!
number
->
account
())
number
->
setAccount
(
account
);
number
->
setAccount
(
account
);
if
((
!
number
->
m_hasType
)
&&
(
!
type
.
isEmpty
()))
{
if
((
!
number
->
m_hasType
)
&&
(
!
type
.
isEmpty
()))
{
number
->
setCategory
(
NumberCategoryModel
::
instance
()
->
getCategory
(
type
));
number
->
setCategory
(
NumberCategoryModel
::
instance
()
->
getCategory
(
type
));
}
}
if
(
number
->
contact
())
{
return
number
;
}
}
}
//Do the opposite, the URI has a suffix, try without
if
((
!
wrap
)
&&
account
&&
uri
.
indexOf
(
'@'
)
!=
-
1
)
{
const
QString
prefixOnly
=
strippedUri
.
left
(
uri
.
indexOf
(
'@'
));
NumberWrapper
*
potentialwrap
=
m_hDirectory
[
prefixOnly
];
if
(
potentialwrap
)
{
foreach
(
PhoneNumber
*
number
,
potentialwrap
->
numbers
)
{
if
(
number
->
account
()
==
account
)
return
number
;
}
}
}
//No better candidates were found than the original assumption, use it
if
(
wrap
)
{
foreach
(
PhoneNumber
*
number
,
wrap
->
numbers
)
{
if
((
!
account
)
||
number
->
account
()
==
account
)
if
((
!
account
)
||
number
->
account
()
==
account
)
return
number
;
return
number
;
}
}
...
@@ -357,6 +407,7 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, Account* account
...
@@ -357,6 +407,7 @@ PhoneNumber* PhoneDirectoryModel::getNumber(const QString& uri, Account* account
PhoneNumber
*
PhoneDirectoryModel
::
getNumber
(
const
QString
&
uri
,
Contact
*
contact
,
Account
*
account
,
const
QString
&
type
)
PhoneNumber
*
PhoneDirectoryModel
::
getNumber
(
const
QString
&
uri
,
Contact
*
contact
,
Account
*
account
,
const
QString
&
type
)
{
{
const
QString
strippedUri
=
PhoneNumber
::
stripUri
(
uri
);
const
QString
strippedUri
=
PhoneNumber
::
stripUri
(
uri
);
//See if the number is already loaded
//See if the number is already loaded
NumberWrapper
*
wrap
=
m_hDirectory
[
strippedUri
];
NumberWrapper
*
wrap
=
m_hDirectory
[
strippedUri
];
if
(
wrap
)
{
if
(
wrap
)
{
...
...
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