Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
cc33d9c2
Commit
cc33d9c2
authored
Jul 17, 2012
by
Emmanuel Lepage Vallee
Browse files
[ #13642 ] Better contact lookup
parent
15e64364
Changes
5
Hide whitespace changes
Inline
Side-by-side
kde/src/klib/AkonadiBackend.cpp
View file @
cc33d9c2
...
...
@@ -86,14 +86,24 @@ ContactBackend* AkonadiBackend::getInstance()
///Find contact using a phone number
///@param resolveDNS check if the DNS is used by an account, then assume contact with that phone number / extension is the same as the caller
Contact
*
AkonadiBackend
::
getContactByPhone
(
const
QString
&
phoneNumber
,
bool
resolveDNS
)
Contact
*
AkonadiBackend
::
getContactByPhone
(
const
QString
&
phoneNumber
,
bool
resolveDNS
,
Account
*
a
)
{
if
(
!
resolveDNS
||
phoneNumber
.
indexOf
(
"@"
)
==
-
1
)
return
m_ContactByPhone
[
phoneNumber
];
else
if
(
!
getHostNameFromPhone
(
phoneNumber
).
isEmpty
()
&&
m_ContactByPhone
[
getUserFromPhone
(
phoneNumber
)])
{
QString
number
=
phoneNumber
;
if
(
number
.
left
(
5
)
==
"<sip:"
)
number
=
number
.
remove
(
0
,
5
);
if
(
number
.
right
(
1
)
==
">"
)
number
=
number
.
remove
(
number
.
size
()
-
1
,
1
);
Contact
*
c
=
m_ContactByPhone
[
number
];
if
(
c
)
{
return
c
;
}
else
if
(
number
.
indexOf
(
"@"
)
==
-
1
&&
a
)
return
m_ContactByPhone
[
number
+
"@"
+
a
->
getAccountHostname
()];
if
(
resolveDNS
&&
number
.
indexOf
(
"@"
)
!=
-
1
&&
!
getHostNameFromPhone
(
number
).
isEmpty
()
&&
m_ContactByPhone
[
getUserFromPhone
(
number
)])
{
foreach
(
Account
*
a
,
AccountList
::
getInstance
()
->
getAccounts
())
{
if
(
a
->
getAccountHostname
()
==
getHostNameFromPhone
(
phoneN
umber
))
return
m_ContactByPhone
[
getUserFromPhone
(
phoneN
umber
)];
if
(
a
->
getAccountHostname
()
==
getHostNameFromPhone
(
n
umber
))
return
m_ContactByPhone
[
getUserFromPhone
(
n
umber
)];
}
}
return
nullptr
;
...
...
@@ -166,7 +176,12 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
PhoneNumbers
newNumbers
;
foreach
(
KABC
::
PhoneNumber
number
,
numbers
)
{
newNumbers
<<
new
Contact
::
PhoneNumber
(
number
.
number
(),
number
.
typeLabel
());
m_ContactByPhone
[
number
.
number
()]
=
aContact
;
QString
number2
=
number
.
number
();
if
(
number2
.
left
(
5
)
==
"<sip:"
)
number2
=
number2
.
remove
(
0
,
5
);
if
(
number2
.
right
(
1
)
==
">"
)
number2
=
number2
.
remove
(
number2
.
size
()
-
1
,
1
);
m_ContactByPhone
[
number2
]
=
aContact
;
}
m_ContactByUid
[
tmp
.
uid
()]
=
aContact
;
...
...
kde/src/klib/AkonadiBackend.h
View file @
cc33d9c2
...
...
@@ -50,15 +50,15 @@ class LIB_EXPORT AkonadiBackend : public ContactBackend {
Q_OBJECT
public:
static
ContactBackend
*
getInstance
();
Contact
*
getContactByPhone
(
const
QString
&
phoneNumber
,
bool
resolveDNS
=
false
);
Contact
*
getContactByUid
(
const
QString
&
uid
);
void
editContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
void
addNewContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
virtual
void
addPhoneNumber
(
Contact
*
contact
,
QString
number
,
QString
type
);
Contact
*
getContactByPhone
(
const
QString
&
phoneNumber
,
bool
resolveDNS
=
false
,
Account
*
a
=
nullptr
);
Contact
*
getContactByUid
(
const
QString
&
uid
);
void
editContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
void
addNewContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
virtual
void
addPhoneNumber
(
Contact
*
contact
,
QString
number
,
QString
type
);
virtual
void
editContact
(
Contact
*
contact
);
virtual
void
addNewContact
(
Contact
*
contact
);
virtual
~
AkonadiBackend
(
);
virtual
void
editContact
(
Contact
*
contact
);
virtual
void
addNewContact
(
Contact
*
contact
);
virtual
~
AkonadiBackend
(
);
private:
AkonadiBackend
(
QObject
*
parent
);
...
...
kde/src/lib/Call.cpp
View file @
cc33d9c2
...
...
@@ -508,7 +508,7 @@ bool Call::isSecure() const {
Contact
*
Call
::
getContact
()
{
if
(
!
m_pContact
&&
m_ContactChanged
)
{
m_pContact
=
m_pContactBackend
->
getContactByPhone
(
m_PeerPhoneNumber
,
true
);
m_pContact
=
m_pContactBackend
->
getContactByPhone
(
m_PeerPhoneNumber
,
true
,
getAccount
()
);
}
return
m_pContact
;
}
...
...
kde/src/lib/CallModel.hpp
View file @
cc33d9c2
...
...
@@ -301,19 +301,20 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addConference(const QString & confID)
return
0
;
}
Call
*
newConf
;
Call
*
newConf
=
nullptr
;
if
(
m_sPrivateCallList_callId
[
callList
[
0
]]
->
call_real
->
getAccount
())
newConf
=
new
Call
(
confID
,
m_sPrivateCallList_callId
[
callList
[
0
]]
->
call_real
->
getAccount
()
->
getAccountId
());
InternalStruct
*
aNewStruct
=
new
InternalStruct
;
aNewStruct
->
call_real
=
newConf
;
aNewStruct
->
conference
=
true
;
m_sPrivateCallList_call
[
newConf
]
=
aNewStruct
;
m_sPrivateCallList_callId
[
confID
]
=
aNewStruct
;
if
(
newConf
)
{
InternalStruct
*
aNewStruct
=
new
InternalStruct
;
aNewStruct
->
call_real
=
newConf
;
aNewStruct
->
conference
=
true
;
m_lConfList
[
newConf
->
getConfId
()]
=
newConf
;
m_sPrivateCallList_call
[
newConf
]
=
aNewStruct
;
m_sPrivateCallList_callId
[
confID
]
=
aNewStruct
;
m_lConfList
[
newConf
->
getConfId
()]
=
newConf
;
}
return
newConf
;
}
//addConference
...
...
kde/src/lib/ContactBackend.h
View file @
cc33d9c2
...
...
@@ -31,6 +31,7 @@
//SFLPhone
class
Contact
;
class
Account
;
//Typedef
typedef
QList
<
Contact
*>
ContactList
;
...
...
@@ -44,7 +45,7 @@ public:
///Get a contact using a phone number
///@param resolveDNS interpret the number as is (false) or parse it to extract the domain and number (true)
virtual
Contact
*
getContactByPhone
(
const
QString
&
phoneNumber
,
bool
resolveDNS
=
false
)
=
0
;
virtual
Contact
*
getContactByPhone
(
const
QString
&
phoneNumber
,
bool
resolveDNS
=
false
,
Account
*
a
=
nullptr
)
=
0
;
///Return a contact (or nullptr) according to the contact unique identifier
virtual
Contact
*
getContactByUid
(
const
QString
&
uid
)
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment