Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
d8ff1b14
Commit
d8ff1b14
authored
Apr 13, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(components): replace `broghammerus_reticulatus` variables by `camelusBactrianus`
parent
c714ad8d
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
979 additions
and
979 deletions
+979
-979
AssistantModel.cpp
linphone-desktop/src/components/assistant/AssistantModel.cpp
+33
-33
AssistantModel.hpp
linphone-desktop/src/components/assistant/AssistantModel.hpp
+4
-4
CallModel.cpp
linphone-desktop/src/components/call/CallModel.cpp
+58
-58
CallModel.hpp
linphone-desktop/src/components/call/CallModel.hpp
+8
-8
CallsListModel.cpp
linphone-desktop/src/components/calls/CallsListModel.cpp
+34
-34
CallsListModel.hpp
linphone-desktop/src/components/calls/CallsListModel.hpp
+7
-7
Camera.cpp
linphone-desktop/src/components/camera/Camera.cpp
+38
-38
Camera.hpp
linphone-desktop/src/components/camera/Camera.hpp
+9
-9
MSFunctions.cpp
linphone-desktop/src/components/camera/MSFunctions.cpp
+3
-3
MSFunctions.hpp
linphone-desktop/src/components/camera/MSFunctions.hpp
+12
-12
ChatModel.cpp
linphone-desktop/src/components/chat/ChatModel.cpp
+103
-103
ChatModel.hpp
linphone-desktop/src/components/chat/ChatModel.hpp
+10
-10
ChatProxyModel.cpp
linphone-desktop/src/components/chat/ChatProxyModel.cpp
+40
-40
ChatProxyModel.hpp
linphone-desktop/src/components/chat/ChatProxyModel.hpp
+6
-6
AbstractCodecsModel.cpp
...one-desktop/src/components/codecs/AbstractCodecsModel.cpp
+32
-32
AbstractCodecsModel.hpp
...one-desktop/src/components/codecs/AbstractCodecsModel.hpp
+6
-6
ContactModel.cpp
linphone-desktop/src/components/contact/ContactModel.cpp
+29
-29
ContactModel.hpp
linphone-desktop/src/components/contact/ContactModel.hpp
+8
-8
VcardModel.cpp
linphone-desktop/src/components/contact/VcardModel.cpp
+65
-65
VcardModel.hpp
linphone-desktop/src/components/contact/VcardModel.hpp
+9
-9
ContactsListModel.cpp
...one-desktop/src/components/contacts/ContactsListModel.cpp
+17
-17
ContactsListModel.hpp
...one-desktop/src/components/contacts/ContactsListModel.hpp
+4
-4
ContactsListProxyModel.cpp
...esktop/src/components/contacts/ContactsListProxyModel.cpp
+23
-23
ContactsListProxyModel.hpp
...esktop/src/components/contacts/ContactsListProxyModel.hpp
+7
-7
CoreHandlers.cpp
linphone-desktop/src/components/core/CoreHandlers.cpp
+11
-11
CoreHandlers.hpp
linphone-desktop/src/components/core/CoreHandlers.hpp
+9
-9
CoreManager.cpp
linphone-desktop/src/components/core/CoreManager.cpp
+33
-33
CoreManager.hpp
linphone-desktop/src/components/core/CoreManager.hpp
+25
-25
Notifier.cpp
linphone-desktop/src/components/notifier/Notifier.cpp
+25
-25
Notifier.hpp
linphone-desktop/src/components/notifier/Notifier.hpp
+4
-4
AccountSettingsModel.cpp
...-desktop/src/components/settings/AccountSettingsModel.cpp
+62
-62
AccountSettingsModel.hpp
...-desktop/src/components/settings/AccountSettingsModel.hpp
+8
-8
SettingsModel.cpp
linphone-desktop/src/components/settings/SettingsModel.cpp
+32
-32
SettingsModel.hpp
linphone-desktop/src/components/settings/SettingsModel.hpp
+2
-2
SipAddressObserver.cpp
...sktop/src/components/sip-addresses/SipAddressObserver.cpp
+12
-12
SipAddressObserver.hpp
...sktop/src/components/sip-addresses/SipAddressObserver.hpp
+11
-11
SipAddressesModel.cpp
...esktop/src/components/sip-addresses/SipAddressesModel.cpp
+127
-127
SipAddressesModel.hpp
...esktop/src/components/sip-addresses/SipAddressesModel.hpp
+21
-21
SmartSearchBarModel.cpp
...p/src/components/smart-search-bar/SmartSearchBarModel.cpp
+26
-26
SmartSearchBarModel.hpp
...p/src/components/smart-search-bar/SmartSearchBarModel.hpp
+3
-3
TimelineModel.cpp
linphone-desktop/src/components/timeline/TimelineModel.cpp
+2
-2
TimelineModel.hpp
linphone-desktop/src/components/timeline/TimelineModel.hpp
+1
-1
No files found.
linphone-desktop/src/components/assistant/AssistantModel.cpp
View file @
d8ff1b14
...
...
@@ -34,7 +34,7 @@ using namespace std;
class
AssistantModel
::
Handlers
:
public
linphone
::
AccountCreatorListener
{
public:
Handlers
(
AssistantModel
*
assistant
)
{
m
_a
ssistant
=
assistant
;
m
A
ssistant
=
assistant
;
}
void
onCreateAccount
(
...
...
@@ -43,14 +43,14 @@ public:
const
string
&
)
override
{
if
(
status
==
linphone
::
AccountCreatorStatusAccountCreated
)
emit
m
_a
ssistant
->
createStatusChanged
(
""
);
emit
m
A
ssistant
->
createStatusChanged
(
""
);
else
{
if
(
status
==
linphone
::
AccountCreatorStatusRequestFailed
)
emit
m
_a
ssistant
->
createStatusChanged
(
tr
(
"requestFailed"
));
emit
m
A
ssistant
->
createStatusChanged
(
tr
(
"requestFailed"
));
else
if
(
status
==
linphone
::
AccountCreatorStatusServerError
)
emit
m
_a
ssistant
->
createStatusChanged
(
tr
(
"cannotSendSms"
));
emit
m
A
ssistant
->
createStatusChanged
(
tr
(
"cannotSendSms"
));
else
emit
m
_a
ssistant
->
createStatusChanged
(
tr
(
"accountAlreadyExists"
));
emit
m
A
ssistant
->
createStatusChanged
(
tr
(
"accountAlreadyExists"
));
}
}
...
...
@@ -61,12 +61,12 @@ public:
)
override
{
if
(
status
==
linphone
::
AccountCreatorStatusAccountExist
||
status
==
linphone
::
AccountCreatorStatusAccountExistWithAlias
)
{
CoreManager
::
getInstance
()
->
getCore
()
->
addProxyConfig
(
creator
->
configure
());
emit
m
_a
ssistant
->
loginStatusChanged
(
""
);
emit
m
A
ssistant
->
loginStatusChanged
(
""
);
}
else
{
if
(
status
==
linphone
::
AccountCreatorStatusRequestFailed
)
emit
m
_a
ssistant
->
loginStatusChanged
(
tr
(
"requestFailed"
));
emit
m
A
ssistant
->
loginStatusChanged
(
tr
(
"requestFailed"
));
else
emit
m
_a
ssistant
->
loginStatusChanged
(
tr
(
"loginWithUsernameFailed"
));
emit
m
A
ssistant
->
loginStatusChanged
(
tr
(
"loginWithUsernameFailed"
));
}
}
...
...
@@ -79,12 +79,12 @@ public:
status
==
linphone
::
AccountCreatorStatusAccountActivated
||
status
==
linphone
::
AccountCreatorStatusAccountAlreadyActivated
)
emit
m
_a
ssistant
->
activateStatusChanged
(
""
);
emit
m
A
ssistant
->
activateStatusChanged
(
""
);
else
{
if
(
status
==
linphone
::
AccountCreatorStatusRequestFailed
)
emit
m
_a
ssistant
->
activateStatusChanged
(
tr
(
"requestFailed"
));
emit
m
A
ssistant
->
activateStatusChanged
(
tr
(
"requestFailed"
));
else
emit
m
_a
ssistant
->
activateStatusChanged
(
tr
(
"smsActivationFailed"
));
emit
m
A
ssistant
->
activateStatusChanged
(
tr
(
"smsActivationFailed"
));
}
}
...
...
@@ -96,12 +96,12 @@ public:
if
(
status
==
linphone
::
AccountCreatorStatusAccountActivated
)
{
CoreManager
::
getInstance
()
->
getAccountSettingsModel
()
->
addOrUpdateProxyConfig
(
creator
->
configure
());
emit
m
_a
ssistant
->
activateStatusChanged
(
""
);
emit
m
A
ssistant
->
activateStatusChanged
(
""
);
}
else
{
if
(
status
==
linphone
::
AccountCreatorStatusRequestFailed
)
emit
m
_a
ssistant
->
activateStatusChanged
(
tr
(
"requestFailed"
));
emit
m
A
ssistant
->
activateStatusChanged
(
tr
(
"requestFailed"
));
else
emit
m
_a
ssistant
->
activateStatusChanged
(
tr
(
"emailActivationFailed"
));
emit
m
A
ssistant
->
activateStatusChanged
(
tr
(
"emailActivationFailed"
));
}
}
...
...
@@ -142,40 +142,40 @@ public:
// ) override {}
private:
AssistantModel
*
m
_a
ssistant
;
AssistantModel
*
m
A
ssistant
;
};
// -----------------------------------------------------------------------------
AssistantModel
::
AssistantModel
(
QObject
*
parent
)
:
QObject
(
parent
)
{
m
_h
andlers
=
make_shared
<
AssistantModel
::
Handlers
>
(
this
);
m
H
andlers
=
make_shared
<
AssistantModel
::
Handlers
>
(
this
);
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
m
_account_c
reator
=
core
->
createAccountCreator
(
m
AccountC
reator
=
core
->
createAccountCreator
(
core
->
getConfig
()
->
getString
(
"assistant"
,
"xmlrpc_url"
,
DEFAULT_XMLRPC_URL
)
);
m
_account_creator
->
setListener
(
m_h
andlers
);
m
AccountCreator
->
setListener
(
mH
andlers
);
}
// -----------------------------------------------------------------------------
void
AssistantModel
::
activate
()
{
if
(
m
_account_c
reator
->
getEmail
().
empty
())
m
_account_c
reator
->
activateAccount
();
if
(
m
AccountC
reator
->
getEmail
().
empty
())
m
AccountC
reator
->
activateAccount
();
else
m
_account_c
reator
->
isAccountActivated
();
m
AccountC
reator
->
isAccountActivated
();
}
void
AssistantModel
::
create
()
{
m
_account_c
reator
->
createAccount
();
m
AccountC
reator
->
createAccount
();
}
void
AssistantModel
::
login
()
{
m
_account_c
reator
->
isAccountExist
();
m
AccountC
reator
->
isAccountExist
();
}
void
AssistantModel
::
reset
()
{
m
_account_c
reator
->
reset
();
m
AccountC
reator
->
reset
();
emit
emailChanged
(
""
,
""
);
emit
passwordChanged
(
""
,
""
);
...
...
@@ -186,14 +186,14 @@ void AssistantModel::reset () {
// -----------------------------------------------------------------------------
QString
AssistantModel
::
getEmail
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m
_account_c
reator
->
getEmail
());
return
::
Utils
::
linphoneStringToQString
(
m
AccountC
reator
->
getEmail
());
}
void
AssistantModel
::
setEmail
(
const
QString
&
email
)
{
shared_ptr
<
linphone
::
Config
>
config
=
CoreManager
::
getInstance
()
->
getCore
()
->
getConfig
();
QString
error
;
switch
(
m
_account_c
reator
->
setEmail
(
::
Utils
::
qStringToLinphoneString
(
email
)))
{
switch
(
m
AccountC
reator
->
setEmail
(
::
Utils
::
qStringToLinphoneString
(
email
)))
{
case
linphone
:
:
AccountCreatorEmailStatusOk
:
break
;
case
linphone
:
:
AccountCreatorEmailStatusMalformed
:
...
...
@@ -208,14 +208,14 @@ void AssistantModel::setEmail (const QString &email) {
}
QString
AssistantModel
::
getPassword
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m
_account_c
reator
->
getPassword
());
return
::
Utils
::
linphoneStringToQString
(
m
AccountC
reator
->
getPassword
());
}
void
AssistantModel
::
setPassword
(
const
QString
&
password
)
{
shared_ptr
<
linphone
::
Config
>
config
=
CoreManager
::
getInstance
()
->
getCore
()
->
getConfig
();
QString
error
;
switch
(
m
_account_c
reator
->
setPassword
(
::
Utils
::
qStringToLinphoneString
(
password
)))
{
switch
(
m
AccountC
reator
->
setPassword
(
::
Utils
::
qStringToLinphoneString
(
password
)))
{
case
linphone
:
:
AccountCreatorPasswordStatusOk
:
break
;
case
linphone
:
:
AccountCreatorPasswordStatusTooShort
:
...
...
@@ -238,27 +238,27 @@ void AssistantModel::setPassword (const QString &password) {
}
QString
AssistantModel
::
getPhoneNumber
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m
_account_c
reator
->
getPhoneNumber
());
return
::
Utils
::
linphoneStringToQString
(
m
AccountC
reator
->
getPhoneNumber
());
}
void
AssistantModel
::
setPhoneNumber
(
const
QString
&
phone
_n
umber
)
{
void
AssistantModel
::
setPhoneNumber
(
const
QString
&
phone
N
umber
)
{
// shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString
error
;
// TODO: use the future wrapped function: `set_phone_number`.
emit
phoneNumberChanged
(
phone
_n
umber
,
error
);
emit
phoneNumberChanged
(
phone
N
umber
,
error
);
}
QString
AssistantModel
::
getUsername
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m
_account_c
reator
->
getUsername
());
return
::
Utils
::
linphoneStringToQString
(
m
AccountC
reator
->
getUsername
());
}
void
AssistantModel
::
setUsername
(
const
QString
&
username
)
{
shared_ptr
<
linphone
::
Config
>
config
=
CoreManager
::
getInstance
()
->
getCore
()
->
getConfig
();
QString
error
;
switch
(
m
_account_c
reator
->
setUsername
(
::
Utils
::
qStringToLinphoneString
(
username
)))
{
switch
(
m
AccountC
reator
->
setUsername
(
::
Utils
::
qStringToLinphoneString
(
username
)))
{
case
linphone
:
:
AccountCreatorUsernameStatusOk
:
break
;
case
linphone
:
:
AccountCreatorUsernameStatusTooShort
:
...
...
linphone-desktop/src/components/assistant/AssistantModel.hpp
View file @
d8ff1b14
...
...
@@ -50,7 +50,7 @@ public:
signals:
void
emailChanged
(
const
QString
&
email
,
const
QString
&
error
);
void
passwordChanged
(
const
QString
&
password
,
const
QString
&
error
);
void
phoneNumberChanged
(
const
QString
&
phone
_n
umber
,
const
QString
&
error
);
void
phoneNumberChanged
(
const
QString
&
phone
N
umber
,
const
QString
&
error
);
void
usernameChanged
(
const
QString
&
username
,
const
QString
&
error
);
void
activateStatusChanged
(
const
QString
&
error
);
...
...
@@ -65,13 +65,13 @@ private:
void
setPassword
(
const
QString
&
password
);
QString
getPhoneNumber
()
const
;
void
setPhoneNumber
(
const
QString
&
phone
_n
umber
);
void
setPhoneNumber
(
const
QString
&
phone
N
umber
);
QString
getUsername
()
const
;
void
setUsername
(
const
QString
&
username
);
std
::
shared_ptr
<
linphone
::
AccountCreator
>
m
_account_c
reator
;
std
::
shared_ptr
<
Handlers
>
m
_h
andlers
;
std
::
shared_ptr
<
linphone
::
AccountCreator
>
m
AccountC
reator
;
std
::
shared_ptr
<
Handlers
>
m
H
andlers
;
};
#endif // ASSISTANT_MODEL_H_
linphone-desktop/src/components/call/CallModel.cpp
View file @
d8ff1b14
...
...
@@ -36,9 +36,9 @@ using namespace std;
// =============================================================================
CallModel
::
CallModel
(
shared_ptr
<
linphone
::
Call
>
linphone
_c
all
)
{
Q_ASSERT
(
linphone
_c
all
!=
nullptr
);
m
_linphone_call
=
linphone_c
all
;
CallModel
::
CallModel
(
shared_ptr
<
linphone
::
Call
>
linphone
C
all
)
{
Q_ASSERT
(
linphone
C
all
!=
nullptr
);
m
LinphoneCall
=
linphoneC
all
;
// Deal with auto-answer.
{
...
...
@@ -57,42 +57,42 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
QObject
::
connect
(
&
(
*
CoreManager
::
getInstance
()
->
getHandlers
()),
&
CoreHandlers
::
callStateChanged
,
this
,
[
this
](
const
s
td
::
s
hared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
if
(
call
!=
m
_linphone_c
all
)
this
,
[
this
](
const
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
if
(
call
!=
m
LinphoneC
all
)
return
;
switch
(
state
)
{
case
linphone
:
:
CallStateEnd
:
case
linphone
:
:
CallStateError
:
stopAutoAnswerTimer
();
m
_paused_by_r
emote
=
false
;
m
PausedByR
emote
=
false
;
break
;
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateRefered
:
case
linphone
:
:
CallStateReleased
:
case
linphone
:
:
CallStateStreamsRunning
:
m
_paused_by_r
emote
=
false
;
m
PausedByR
emote
=
false
;
break
;
case
linphone
:
:
CallStatePausedByRemote
:
m
_paused_by_r
emote
=
true
;
m
PausedByR
emote
=
true
;
break
;
case
linphone
:
:
CallStatePausing
:
m
_paused_by_u
ser
=
true
;
m
PausedByU
ser
=
true
;
break
;
case
linphone
:
:
CallStateResuming
:
m
_paused_by_u
ser
=
false
;
m
PausedByU
ser
=
false
;
break
;
case
linphone
:
:
CallStateUpdatedByRemote
:
if
(
!
m
_linphone_c
all
->
getCurrentParams
()
->
videoEnabled
()
&&
m
_linphone_c
all
->
getRemoteParams
()
->
videoEnabled
()
!
m
LinphoneC
all
->
getCurrentParams
()
->
videoEnabled
()
&&
m
LinphoneC
all
->
getRemoteParams
()
->
videoEnabled
()
)
{
m
_linphone_c
all
->
deferUpdate
();
m
LinphoneC
all
->
deferUpdate
();
emit
videoRequested
();
}
...
...
@@ -109,8 +109,8 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
// -----------------------------------------------------------------------------
void
CallModel
::
setRecordFile
(
shared_ptr
<
linphone
::
CallParams
>
&
call
_p
arams
)
{
call
_p
arams
->
setRecordFile
(
void
CallModel
::
setRecordFile
(
shared_ptr
<
linphone
::
CallParams
>
&
call
P
arams
)
{
call
P
arams
->
setRecordFile
(
::
Utils
::
qStringToLinphoneString
(
CoreManager
::
getInstance
()
->
getSettingsModel
()
->
getSavedVideosFolder
()
+
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh:mm:ss"
)
...
...
@@ -124,31 +124,31 @@ void CallModel::accept () {
stopAutoAnswerTimer
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
_linphone_c
all
);
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
LinphoneC
all
);
params
->
enableVideo
(
false
);
setRecordFile
(
params
);
App
::
getInstance
()
->
getCallsWindow
()
->
show
();
m
_linphone_c
all
->
acceptWithParams
(
params
);
m
LinphoneC
all
->
acceptWithParams
(
params
);
}
void
CallModel
::
acceptWithVideo
()
{
stopAutoAnswerTimer
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
_linphone_c
all
);
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
LinphoneC
all
);
params
->
enableVideo
(
true
);
setRecordFile
(
params
);
App
::
getInstance
()
->
getCallsWindow
()
->
show
();
m
_linphone_c
all
->
acceptWithParams
(
params
);
m
LinphoneC
all
->
acceptWithParams
(
params
);
}
void
CallModel
::
terminate
()
{
CoreManager
*
core
=
CoreManager
::
getInstance
();
core
->
lockVideoRender
();
m
_linphone_c
all
->
terminate
();
m
LinphoneC
all
->
terminate
();
core
->
unlockVideoRender
();
}
...
...
@@ -158,54 +158,54 @@ void CallModel::transfer () {
void
CallModel
::
acceptVideoRequest
()
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
_linphone_c
all
);
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
LinphoneC
all
);
params
->
enableVideo
(
true
);
m
_linphone_c
all
->
acceptUpdate
(
params
);
m
LinphoneC
all
->
acceptUpdate
(
params
);
}
void
CallModel
::
rejectVideoRequest
()
{
m
_linphone_call
->
acceptUpdate
(
m_linphone_c
all
->
getCurrentParams
());
m
LinphoneCall
->
acceptUpdate
(
mLinphoneC
all
->
getCurrentParams
());
}
void
CallModel
::
takeSnapshot
()
{
static
QString
old
_n
ame
;
QString
new
_n
ame
=
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh:mm:ss"
)
+
".jpg"
;
static
QString
old
N
ame
;
QString
new
N
ame
=
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh:mm:ss"
)
+
".jpg"
;
if
(
new
_name
==
old_n
ame
)
{
if
(
new
Name
==
oldN
ame
)
{
qWarning
()
<<
"Unable to take snapshot. Wait one second."
;
return
;
}
old
_name
=
new_n
ame
;
old
Name
=
newN
ame
;
qInfo
()
<<
"Take snapshot of call:"
<<
&
m
_linphone_c
all
;
qInfo
()
<<
"Take snapshot of call:"
<<
&
m
LinphoneC
all
;
m
_linphone_c
all
->
takeVideoSnapshot
(
m
LinphoneC
all
->
takeVideoSnapshot
(
::
Utils
::
qStringToLinphoneString
(
CoreManager
::
getInstance
()
->
getSettingsModel
()
->
getSavedScreenshotsFolder
()
+
new
_n
ame
CoreManager
::
getInstance
()
->
getSettingsModel
()
->
getSavedScreenshotsFolder
()
+
new
N
ame
)
);
}
void
CallModel
::
startRecording
()
{
if
(
m
_r
ecording
)
if
(
m
R
ecording
)
return
;
qInfo
()
<<
"Start recording call:"
<<
&
m
_linphone_c
all
;
qInfo
()
<<
"Start recording call:"
<<
&
m
LinphoneC
all
;
m
_linphone_c
all
->
startRecording
();
m
_r
ecording
=
true
;
m
LinphoneC
all
->
startRecording
();
m
R
ecording
=
true
;
emit
recordingChanged
(
true
);
}
void
CallModel
::
stopRecording
()
{
if
(
m
_r
ecording
)
{
qInfo
()
<<
"Stop recording call:"
<<
&
m
_linphone_c
all
;
if
(
m
R
ecording
)
{
qInfo
()
<<
"Stop recording call:"
<<
&
m
LinphoneC
all
;
m
_r
ecording
=
false
;
m
_linphone_c
all
->
stopRecording
();
m
R
ecording
=
false
;
m
LinphoneC
all
->
stopRecording
();
emit
recordingChanged
(
false
);
}
...
...
@@ -222,11 +222,11 @@ void CallModel::stopAutoAnswerTimer () const {
}
QString
CallModel
::
getSipAddress
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m
_linphone_c
all
->
getRemoteAddress
()
->
asStringUriOnly
());
return
::
Utils
::
linphoneStringToQString
(
m
LinphoneC
all
->
getRemoteAddress
()
->
asStringUriOnly
());
}
CallModel
::
CallStatus
CallModel
::
getStatus
()
const
{
switch
(
m
_linphone_c
all
->
getState
())
{
switch
(
m
LinphoneC
all
->
getState
())
{
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateStreamsRunning
:
return
CallStatusConnected
;
...
...
@@ -245,7 +245,7 @@ CallModel::CallStatus CallModel::getStatus () const {
case
linphone
:
:
CallStateUpdating
:
case
linphone
:
:
CallStateUpdatedByRemote
:
return
m
_paused_by_r
emote
?
CallStatusPaused
:
CallStatusConnected
;
return
m
PausedByR
emote
?
CallStatusPaused
:
CallStatusConnected
;
case
linphone
:
:
CallStateEarlyUpdatedByRemote
:
case
linphone
:
:
CallStateEarlyUpdating
:
...
...
@@ -259,17 +259,17 @@ CallModel::CallStatus CallModel::getStatus () const {
break
;
}
return
m
_linphone_c
all
->
getDir
()
==
linphone
::
CallDirIncoming
?
CallStatusIncoming
:
CallStatusOutgoing
;
return
m
LinphoneC
all
->
getDir
()
==
linphone
::
CallDirIncoming
?
CallStatusIncoming
:
CallStatusOutgoing
;
}
// -----------------------------------------------------------------------------
int
CallModel
::
getDuration
()
const
{
return
m
_linphone_c
all
->
getDuration
();
return
m
LinphoneC
all
->
getDuration
();
}
float
CallModel
::
getQuality
()
const
{
return
m
_linphone_c
all
->
getCurrentQuality
();
return
m
LinphoneC
all
->
getCurrentQuality
();
}
// -----------------------------------------------------------------------------
...
...
@@ -287,11 +287,11 @@ inline float computeVu (float volume) {
}
float
CallModel
::
getMicroVu
()
const
{
return
computeVu
(
m
_linphone_c
all
->
getRecordVolume
());
return
computeVu
(
m
LinphoneC
all
->
getRecordVolume
());
}
float
CallModel
::
getSpeakerVu
()
const
{
return
computeVu
(
m
_linphone_c
all
->
getPlayVolume
());
return
computeVu
(
m
LinphoneC
all
->
getPlayVolume
());
}
// -----------------------------------------------------------------------------
...
...
@@ -312,11 +312,11 @@ void CallModel::setMicroMuted (bool status) {
// -----------------------------------------------------------------------------
bool
CallModel
::
getPausedByUser
()
const
{
return
m
_paused_by_u
ser
;
return
m
PausedByU
ser
;
}
void
CallModel
::
setPausedByUser
(
bool
status
)
{
switch
(
m
_linphone_c
all
->
getState
())
{
switch
(
m
LinphoneC
all
->
getState
())
{
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateStreamsRunning
:
case
linphone
:
:
CallStatePaused
:
...
...
@@ -326,25 +326,25 @@ void CallModel::setPausedByUser (bool status) {
}
if
(
status
)
{
if
(
!
m
_paused_by_u
ser
)
m
_linphone_c
all
->
pause
();
if
(
!
m
PausedByU
ser
)
m
LinphoneC
all
->
pause
();
return
;
}
if
(
m
_paused_by_u
ser
)
m
_linphone_c
all
->
resume
();
if
(
m
PausedByU
ser
)
m
LinphoneC
all
->
resume
();
}
// -----------------------------------------------------------------------------
bool
CallModel
::
getVideoEnabled
()
const
{
shared_ptr
<
const
linphone
::
CallParams
>
params
=
m
_linphone_c
all
->
getCurrentParams
();
shared_ptr
<
const
linphone
::
CallParams
>
params
=
m
LinphoneC
all
->
getCurrentParams
();
return
params
&&
params
->
videoEnabled
()
&&
getStatus
()
==
CallStatusConnected
;
}
void
CallModel
::
setVideoEnabled
(
bool
status
)
{
switch
(
m
_linphone_c
all
->
getState
())
{
switch
(
m
LinphoneC
all
->
getState
())
{
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateStreamsRunning
:
break
;
...
...
@@ -355,16 +355,16 @@ void CallModel::setVideoEnabled (bool status) {
return
;
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
_linphone_c
all
);
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m
LinphoneC
all
);
params
->
enableVideo
(
status
);
m
_linphone_c
all
->
update
(
params
);
m
LinphoneC
all
->
update
(
params
);
}
// -----------------------------------------------------------------------------
bool
CallModel
::
getUpdating
()
const
{
switch
(
m
_linphone_c
all
->
getState
())
{
switch
(
m
LinphoneC
all
->
getState
())
{
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateStreamsRunning
:
case
linphone
:
:
CallStatePaused
:
...
...
@@ -379,5 +379,5 @@ bool CallModel::getUpdating () const {
}
bool
CallModel
::
getRecording
()
const
{
return
m
_r
ecording
;
return
m
R
ecording
;
}
linphone-desktop/src/components/call/CallModel.hpp
View file @
d8ff1b14
...
...
@@ -61,14 +61,14 @@ public:
Q_ENUM
(
CallStatus
);
CallModel
(
std
::
shared_ptr
<
linphone
::
Call
>
linphone
_c
all
);
CallModel
(
std
::
shared_ptr
<
linphone
::
Call
>
linphone
C
all
);
~
CallModel
()
=
default
;
std
::
shared_ptr
<
linphone
::
Call
>
getLinphoneCall
()
const
{
return
m
_linphone_c
all
;
return
m
LinphoneC
all
;
}
static
void
setRecordFile
(
std
::
shared_ptr
<
linphone
::
CallParams
>
&
call
_p
arams
);
static
void
setRecordFile
(
std
::
shared_ptr
<
linphone
::
CallParams
>
&
call
P
arams
);
Q_INVOKABLE
void
accept
();
Q_INVOKABLE
void
acceptWithVideo
();
...
...
@@ -96,7 +96,7 @@ private:
CallStatus
getStatus
()
const
;
bool
isOutgoing
()
const
{
return
m
_linphone_c
all
->
getDir
()
==
linphone
::
CallDirOutgoing
;
return
m
LinphoneC
all
->
getDir
()
==
linphone
::
CallDirOutgoing
;
}
int
getDuration
()
const
;
...
...
@@ -117,11 +117,11 @@ private:
bool
getRecording
()
const
;
bool
m
_paused_by_r
emote
=
false
;
bool
m
_paused_by_u
ser
=
false
;
bool
m
_r
ecording
=
false
;
bool
m
PausedByR
emote
=
false
;
bool
m
PausedByU
ser
=
false
;
bool
m
R
ecording
=
false
;
std
::
shared_ptr
<
linphone
::
Call
>
m
_linphone_c
all
;
std
::
shared_ptr
<
linphone
::
Call
>
m
LinphoneC
all
;
};
#endif // CALL_MODEL_H_
linphone-desktop/src/components/calls/CallsListModel.cpp
View file @
d8ff1b14
...
...
@@ -38,11 +38,11 @@ using namespace std;
inline
QList
<
CallModel
*>::
iterator
findCall
(
QList
<
CallModel
*>
&
list
,
const
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
const
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
)
{
return
find_if
(
list
.
begin
(),
list
.
end
(),
[
linphone
_c
all
](
CallModel
*
call
)
{
return
linphone
_c
all
==
call
->
getLinphoneCall
();
list
.
begin
(),
list
.
end
(),
[
linphone
C
all
](
CallModel
*
call
)
{
return
linphone
C
all
==
call
->
getLinphoneCall
();
}
);
}
...
...
@@ -50,24 +50,24 @@ inline QList<CallModel *>::iterator findCall (
// -----------------------------------------------------------------------------
CallsListModel
::
CallsListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
m
_core_h
andlers
=
CoreManager
::
getInstance
()
->
getHandlers
();
m
CoreH
andlers
=
CoreManager
::
getInstance
()
->
getHandlers
();
QObject
::
connect
(
&
(
*
m
_core_h
andlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
,
linphone
::
CallState
state
)
{
&
(
*
m
CoreH
andlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
,
linphone
::
CallState
state
)
{
switch
(
state
)
{
case
linphone
:
:
CallStateIncomingReceived
:
case
linphone
:
:
CallStateOutgoingInit
:
addCall
(
linphone
_c
all
);
addCall
(
linphone
C
all
);
break
;
case
linphone
:
:
CallStateEnd
:
case
linphone
:
:
CallStateError
:
removeCall
(
linphone
_c
all
);
removeCall
(
linphone
C
all
);
break
;
case
linphone
:
:
CallStateStreamsRunning
:
{
int
index
=
static_cast
<
int
>
(
distance
(
m
_list
.
begin
(),
findCall
(
m_list
,
linphone_c
all
)));
emit
callRunning
(
index
,
&
linphone
_c
all
->
getData
<
CallModel
>
(
"call-model"
));
int
index
=
static_cast
<
int
>
(
distance
(
m
List
.
begin
(),
findCall
(
mList
,
linphoneC
all
)));
emit
callRunning
(
index
,
&
linphone
C
all
->
getData
<
CallModel
>
(
"call-model"
));
}
break
;
...
...
@@ -79,7 +79,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
}
int
CallsListModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m
_l
ist
.
count
();
return
m
L
ist
.
count
();
}
QHash
<
int
,
QByteArray
>
CallsListModel
::
roleNames
()
const
{
...
...
@@ -91,25 +91,25 @@ QHash<int, QByteArray> CallsListModel::roleNames () const {
QVariant
CallsListModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
_l
ist
.
count
())
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
L
ist
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
QVariant
::
fromValue
(
m
_l
ist
[
row
]);
return
QVariant
::
fromValue
(
m
L
ist
[
row
]);
return
QVariant
();
}
CallModel
*
CallsListModel
::
getCall
(
const
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
)
const
{
auto
it
=
findCall
(
*
(
const_cast
<
QList
<
CallModel
*>
*>
(
&
m
_list
)),
linphone_c
all
);
return
it
!=
m
_l
ist
.
end
()
?
*
it
:
nullptr
;
CallModel
*
CallsListModel
::
getCall
(
const
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
)
const
{
auto
it
=
findCall
(
*
(
const_cast
<
QList
<
CallModel
*>
*>
(
&
m
List
)),
linphoneC
all
);
return
it
!=
m
L
ist
.
end
()
?
*
it
:
nullptr
;
}
// -----------------------------------------------------------------------------
void
CallsListModel
::
launchAudioCall
(
const
QString
&
sip
_u
ri
)
const
{
void
CallsListModel
::
launchAudioCall
(
const
QString
&
sip
U
ri
)
const
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
Address
>
address
=
core
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
_u
ri
));
shared_ptr
<
linphone
::
Address
>
address
=
core
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
U
ri
));
if
(
!
address
)
return
;
...
...
@@ -121,9 +121,9 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const {
core
->
inviteAddressWithParams
(
address
,
params
);
}
void
CallsListModel
::
launchVideoCall
(
const
QString
&
sip
_u
ri
)
const
{
void
CallsListModel
::
launchVideoCall
(
const
QString
&
sip
U
ri
)
const
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
Address
>
address
=
core
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
_u
ri
));
shared_ptr
<
linphone
::
Address
>
address
=
core
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
U
ri
));
if
(
!
address
)
return
;
...
...
@@ -155,13 +155,13 @@ bool CallsListModel::removeRow (int row, const QModelIndex &parent) {
bool
CallsListModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
{
int
limit
=
row
+
count
-
1
;
if
(
row
<
0
||
count
<
0
||
limit
>=
m
_l
ist
.
count
())
if
(
row
<
0
||
count
<
0
||
limit
>=
m
L
ist
.
count
())
return
false
;
beginRemoveRows
(
parent
,
row
,
limit
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
m
_l
ist
.
takeAt
(
row
)
->
deleteLater
();
m
L
ist
.
takeAt
(
row
)
->
deleteLater
();
endRemoveRows
();
...
...
@@ -170,38 +170,38 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent)
// -----------------------------------------------------------------------------
void
CallsListModel
::
addCall
(
const
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
)
{
if
(
linphone
_c
all
->
getDir
()
==
linphone
::
CallDirOutgoing
)
void
CallsListModel
::
addCall
(
const
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
)
{
if
(
linphone
C
all
->
getDir
()
==
linphone
::
CallDirOutgoing
)
App
::
getInstance
()
->
getCallsWindow
()
->
show
();
CallModel
*
call
=
new
CallModel
(
linphone
_c
all
);
CallModel
*
call
=
new
CallModel
(
linphone
C
all
);
qInfo
()
<<
"Add call:"
<<
call
;
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
call
,
QQmlEngine
::
CppOwnership
);
linphone
_c
all
->
setData
(
"call-model"
,
*
call
);
linphone
C
all
->
setData
(
"call-model"
,
*
call
);
int
row
=
m
_l
ist
.
count
();
int
row
=
m
L
ist
.
count
();
beginInsertRows
(
QModelIndex
(),
row
,
row
);
m
_l
ist
<<
call
;
m
L
ist
<<
call
;
endInsertRows
();
}
void
CallsListModel
::
removeCall
(
const
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
)
{
void
CallsListModel
::
removeCall
(
const
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
)
{
// TODO: It will be (maybe) necessary to use a single scheduled function in the future.
QTimer
::
singleShot
(
DELAY_BEFORE_REMOVE_CALL
,
this
,
[
this
,
linphone
_c
all
]()
{
CallModel
*
call
=
&
linphone
_c
all
->
getData
<
CallModel
>
(
"call-model"
);
linphone
_c
all
->
unsetData
(
"call-model"
);
DELAY_BEFORE_REMOVE_CALL
,
this
,
[
this
,
linphone
C
all
]()
{
CallModel
*
call
=
&
linphone
C
all
->
getData
<
CallModel
>
(
"call-model"
);
linphone
C
all
->
unsetData
(
"call-model"
);
qInfo
()
<<
"Removing call:"
<<
call
;
int
index
=
m
_l
ist
.
indexOf
(
call
);
int
index
=
m
L
ist
.
indexOf
(
call
);
if
(
index
==
-
1
||
!
removeRow
(
index
))
qWarning
()
<<
"Unable to remove call:"
<<
call
;
if
(
m
_l
ist
.
empty
())
if
(
m
L
ist
.
empty
())
App
::
getInstance
()
->
getCallsWindow
()
->
close
();
}
);
...
...
linphone-desktop/src/components/calls/CallsListModel.hpp
View file @
d8ff1b14
...
...
@@ -43,10 +43,10 @@ public:
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
CallModel
*
getCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
)
const
;
CallModel
*
getCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
)
const
;
Q_INVOKABLE
void
launchAudioCall
(
const
QString
&
sip
_u
ri
)
const
;
Q_INVOKABLE
void
launchVideoCall
(
const
QString
&
sip
_u
ri
)
const
;
Q_INVOKABLE
void
launchAudioCall
(
const
QString
&
sip
U
ri
)
const
;
Q_INVOKABLE
void
launchVideoCall
(
const
QString
&
sip
U
ri
)
const
;
Q_INVOKABLE
int
getRunningCallsNumber
()
const
;
...
...
@@ -59,12 +59,12 @@ private:
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
())
override
;
void
addCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
);
void
removeCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
linphone
_c
all
);
void
addCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
);
void
removeCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
linphone
C
all
);
QList
<
CallModel
*>
m
_l
ist
;
QList
<
CallModel
*>
m
L
ist
;
std
::
shared_ptr
<
CoreHandlers
>
m
_core_h
andlers
;
std
::
shared_ptr
<
CoreHandlers
>
m
CoreH
andlers
;
};
#endif // CALLS_LIST_MODEL_H_
linphone-desktop/src/components/camera/Camera.cpp
View file @
d8ff1b14
...
...
@@ -47,24 +47,24 @@ struct ContextInfo {
// -----------------------------------------------------------------------------
CameraRenderer
::
CameraRenderer
()
{
m
_context_i
nfo
=
new
ContextInfo
();
m
ContextI
nfo
=
new
ContextInfo
();
}
CameraRenderer
::~
CameraRenderer
()
{
qInfo
()
<<
QStringLiteral
(
"Delete context info:"
)
<<
m
_context_i
nfo
;
qInfo
()
<<
QStringLiteral
(
"Delete context info:"
)
<<
m
ContextI
nfo
;
CoreManager
*
core
=
CoreManager
::
getInstance
();
core
->
lockVideoRender
();
if
(
m
_is_p
review
)
if
(
m
IsP
review
)
CoreManager
::
getInstance
()
->
getCore
()
->
setNativePreviewWindowId
(
nullptr
);
else
if
(
m
_linphone_c
all
)
m
_linphone_c
all
->
setNativeVideoWindowId
(
nullptr
);
else
if
(
m
LinphoneC
all
)
m
LinphoneC
all
->
setNativeVideoWindowId
(
nullptr
);
core
->
unlockVideoRender
();
delete
m
_context_i
nfo
;
delete
m
ContextI
nfo
;
}
QOpenGLFramebufferObject
*
CameraRenderer
::
createFramebufferObject
(
const
QSize
&
size
)
{
...
...
@@ -78,10 +78,10 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
// It's not the same thread as render.
core
->
lockVideoRender
();
m
_context_i
nfo
->
width
=
size
.
width
();
m
_context_i
nfo
->
height
=
size
.
height
();
m
_context_i
nfo
->
functions
=
MSFunctions
::
getInstance
()
->
getFunctions
();
m
_update_context_i
nfo
=
true
;
m
ContextI
nfo
->
width
=
size
.
width
();
m
ContextI
nfo
->
height
=
size
.
height
();
m
ContextI
nfo
->
functions
=
MSFunctions
::
getInstance
()
->
getFunctions
();
m
UpdateContextI
nfo
=
true
;
updateWindowId
();
...
...
@@ -91,7 +91,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
}
void
CameraRenderer
::
render
()
{
if
(
!
m
_linphone_c
all
)
if
(
!
m
LinphoneC
all
)
return
;
// Draw with ms filter.
...
...
@@ -102,48 +102,48 @@ void CameraRenderer::render () {
f
->
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
CoreManager
*
core
=
CoreManager
::
getInstance
();
MSFunctions
*
ms
_f
unctions
=
MSFunctions
::
getInstance
();
MSFunctions
*
ms
F
unctions
=
MSFunctions
::
getInstance
();
core
->
lockVideoRender
();
ms
_f
unctions
->
bind
(
f
);
m
_linphone_call
->
oglRender
(
m_is_p
review
);
ms
_f
unctions
->
bind
(
nullptr
);
ms
F
unctions
->
bind
(
f
);
m
LinphoneCall
->
oglRender
(
mIsP
review
);
ms
F
unctions
->
bind
(
nullptr
);
core
->
unlockVideoRender
();
}
// Synchronize opengl calls with QML.
if
(
m
_w
indow
)
m
_w
indow
->
resetOpenGLState
();
if
(
m
W
indow
)
m
W
indow
->
resetOpenGLState
();
}
void
CameraRenderer
::
synchronize
(
QQuickFramebufferObject
*
item
)
{
// No mutex needed here. It's a synchronized area.
m
_w
indow
=
item
->
window
();
m
W
indow
=
item
->
window
();
Camera
*
camera
=
qobject_cast
<
Camera
*>
(
item
);
m
_linphone_c
all
=
camera
->
getCall
()
->
getLinphoneCall
();
m
_is_preview
=
camera
->
m_is_p
review
;
m
LinphoneC
all
=
camera
->
getCall
()
->
getLinphoneCall
();
m
IsPreview
=
camera
->
mIsP
review
;
updateWindowId
();
}
void
CameraRenderer
::
updateWindowId
()
{
if
(
!
m
_update_context_i
nfo
)
if
(
!
m
UpdateContextI
nfo
)
return
;
m
_update_context_i
nfo
=
false
;
m
UpdateContextI
nfo
=
false
;
qInfo
()
<<
"Thread"
<<
QThread
::
currentThread
()
<<
QStringLiteral
(
"Set context info (width: %1, height: %2, is_preview: %3):"
)
.
arg
(
m
_context_info
->
width
).
arg
(
m_context_info
->
height
).
arg
(
m_is_preview
)
<<
m_context_i
nfo
;
.
arg
(
m
ContextInfo
->
width
).
arg
(
mContextInfo
->
height
).
arg
(
mIsPreview
)
<<
mContextI
nfo
;
if
(
m
_is_p
review
)
CoreManager
::
getInstance
()
->
getCore
()
->
setNativePreviewWindowId
(
m
_context_i
nfo
);
else
if
(
m
_linphone_c
all
)
m
_linphone_call
->
setNativeVideoWindowId
(
m_context_i
nfo
);
if
(
m
IsP
review
)
CoreManager
::
getInstance
()
->
getCore
()
->
setNativePreviewWindowId
(
m
ContextI
nfo
);
else
if
(
m
LinphoneC
all
)
m
LinphoneCall
->
setNativeVideoWindowId
(
mContextI
nfo
);
}
// -----------------------------------------------------------------------------
...
...
@@ -155,16 +155,16 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
// The fbo content must be y-mirrored because the ms rendering is y-inverted.
setMirrorVertically
(
true
);
m
_refresh_t
imer
=
new
QTimer
(
this
);
m
_refresh_t
imer
->
setInterval
(
1
/
MAX_FPS
*
1000
);
m
RefreshT
imer
=
new
QTimer
(
this
);
m
RefreshT
imer
->
setInterval
(
1
/
MAX_FPS
*
1000
);
QObject
::
connect
(
m
_refresh_t
imer
,
&
QTimer
::
timeout
,
m
RefreshT
imer
,
&
QTimer
::
timeout
,
this
,
&
QQuickFramebufferObject
::
update
,
Qt
::
DirectConnection
);
m
_refresh_t
imer
->
start
();
m
RefreshT
imer
->
start
();
}
QQuickFramebufferObject
::
Renderer
*
Camera
::
createRenderer
()
const
{
...
...
@@ -178,25 +178,25 @@ void Camera::mousePressEvent (QMouseEvent *) {
// -----------------------------------------------------------------------------
CallModel
*
Camera
::
getCall
()
const
{
return
m
_c
all
;
return
m
C
all
;
}
void
Camera
::
setCall
(
CallModel
*
call
)
{
if
(
m
_c
all
!=
call
)
{
m
_c
all
=
call
;
if
(
m
C
all
!=
call
)
{
m
C
all
=
call
;
update
();
emit
callChanged
(
m
_c
all
);
emit
callChanged
(
m
C
all
);
}
}
bool
Camera
::
getIsPreview
()
const
{
return
m
_is_p
review
;
return
m
IsP
review
;
}
void
Camera
::
setIsPreview
(
bool
status
)
{
if
(
m
_is_p
review
!=
status
)
{
m
_is_p
review
=
status
;
if
(
m
IsP
review
!=
status
)
{
m
IsP
review
=
status
;
update
();
emit
isPreviewChanged
(
status
);
...
...
linphone-desktop/src/components/camera/Camera.hpp
View file @
d8ff1b14
...
...
@@ -53,13 +53,13 @@ protected:
private:
void
updateWindowId
();
ContextInfo
*
m
_context_i
nfo
;
bool
m
_update_context_i
nfo
=
false
;
ContextInfo
*
m
ContextI
nfo
;
bool
m
UpdateContextI
nfo
=
false
;
bool
m
_is_p
review
=
false
;
std
::
shared_ptr
<
linphone
::
Call
>
m
_linphone_c
all
;
bool
m
IsP
review
=
false
;
std
::
shared_ptr
<
linphone
::
Call
>
m
LinphoneC
all
;
QQuickWindow
*
m
_w
indow
;
QQuickWindow
*
m
W
indow
;
};
// -----------------------------------------------------------------------------
...
...
@@ -80,7 +80,7 @@ public:
signals:
void
callChanged
(
CallModel
*
call
);
void
isPreviewChanged
(
bool
is
_p
review
);
void
isPreviewChanged
(
bool
is
P
review
);
protected:
void
mousePressEvent
(
QMouseEvent
*
event
)
override
;
...
...
@@ -92,10 +92,10 @@ private:
bool
getIsPreview
()
const
;
void
setIsPreview
(
bool
status
);
bool
m
_is_p
review
=
false
;
CallModel
*
m
_c
all
=
nullptr
;
bool
m
IsP
review
=
false
;
CallModel
*
m
C
all
=
nullptr
;
QTimer
*
m
_refresh_t
imer
;
QTimer
*
m
RefreshT
imer
;
};
#endif // CAMERA_H_
linphone-desktop/src/components/camera/MSFunctions.cpp
View file @
d8ff1b14
...
...
@@ -27,12 +27,12 @@
// =============================================================================
MSFunctions
*
MSFunctions
::
m
_i
nstance
=
nullptr
;
MSFunctions
*
MSFunctions
::
m
I
nstance
=
nullptr
;
// -----------------------------------------------------------------------------
MSFunctions
::
MSFunctions
()
{
OpenGlFunctions
*
f
=
m
_f
unctions
=
new
OpenGlFunctions
();
OpenGlFunctions
*
f
=
m
F
unctions
=
new
OpenGlFunctions
();
f
->
glActiveTexture
=
qtResolveGlActiveTexture
;
f
->
glAttachShader
=
qtResolveGlAttachShader
;
...
...
@@ -73,5 +73,5 @@ MSFunctions::MSFunctions () {
}
MSFunctions
::~
MSFunctions
()
{
delete
m
_f
unctions
;
delete
m
F
unctions
;
}
linphone-desktop/src/components/camera/MSFunctions.hpp
View file @
d8ff1b14
...
...
@@ -26,16 +26,16 @@
#include <QOpenGLFunctions>
#define GL_ASSERT() \
Q_ASSERT(m
_instance->m_q_f
unctions != NULL); \
Q_ASSERT(QOpenGLContext::currentContext()->functions() == m
_instance->m_q_f
unctions);
Q_ASSERT(m
Instance->mQtF
unctions != NULL); \
Q_ASSERT(QOpenGLContext::currentContext()->functions() == m
Instance->mQtF
unctions);
#define GL_CALL(CALL) \
GL_ASSERT() \
m
_instance->m_q_f
unctions->CALL;
m
Instance->mQtF
unctions->CALL;
#define GL_CALL_RET(CALL) \
GL_ASSERT() \
return m
_instance->m_q_f
unctions->CALL;
return m
Instance->mQtF
unctions->CALL;
// =============================================================================
...
...
@@ -46,20 +46,20 @@ public:
~
MSFunctions
();
void
bind
(
QOpenGLFunctions
*
f
)
{
m
_q_f
unctions
=
f
;
// Qt functions.
m
QtF
unctions
=
f
;
// Qt functions.
}
OpenGlFunctions
*
getFunctions
()
{
return
m
_f
unctions
;
// Own implementation.
return
m
F
unctions
;
// Own implementation.
}
// ---------------------------------------------------------------------------
static
MSFunctions
*
getInstance
()
{
if
(
!
m
_i
nstance
)
m
_i
nstance
=
new
MSFunctions
();
if
(
!
m
I
nstance
)
m
I
nstance
=
new
MSFunctions
();
return
m
_i
nstance
;
return
m
I
nstance
;
}
// ---------------------------------------------------------------------------
...
...
@@ -213,10 +213,10 @@ public:
private:
MSFunctions
();
OpenGlFunctions
*
m
_f
unctions
=
nullptr
;
QOpenGLFunctions
*
m
_q_f
unctions
=
nullptr
;
OpenGlFunctions
*
m
F
unctions
=
nullptr
;
QOpenGLFunctions
*
m
QtF
unctions
=
nullptr
;
static
MSFunctions
*
m
_i
nstance
;
static
MSFunctions
*
m
I
nstance
;
};
#undef GL_CALL
...
...
linphone-desktop/src/components/chat/ChatModel.cpp
View file @
d8ff1b14
...
...
@@ -46,19 +46,19 @@ using namespace std;
// =============================================================================
inline
void
fillThumbnailProperty
(
QVariantMap
&
dest
,
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
string
file
_i
d
=
message
->
getAppdata
();
if
(
!
file
_i
d
.
empty
()
&&
!
dest
.
contains
(
"thumbnail"
))
string
file
I
d
=
message
->
getAppdata
();
if
(
!
file
I
d
.
empty
()
&&
!
dest
.
contains
(
"thumbnail"
))
dest
[
"thumbnail"
]
=
QStringLiteral
(
"image://%1/%2"
)
.
arg
(
ThumbnailProvider
::
PROVIDER_ID
).
arg
(
::
Utils
::
linphoneStringToQString
(
file
_i
d
));
.
arg
(
ThumbnailProvider
::
PROVIDER_ID
).
arg
(
::
Utils
::
linphoneStringToQString
(
file
I
d
));
}
inline
void
createThumbnail
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
if
(
!
message
->
getAppdata
().
empty
())
return
;
QString
thumbnail
_p
ath
=
::
Utils
::
linphoneStringToQString
(
message
->
getFileTransferFilepath
());
QString
thumbnail
P
ath
=
::
Utils
::
linphoneStringToQString
(
message
->
getFileTransferFilepath
());
QImage
image
(
thumbnail
_p
ath
);
QImage
image
(
thumbnail
P
ath
);
if
(
image
.
isNull
())
return
;
...
...
@@ -68,25 +68,25 @@ inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
);
QString
uuid
=
QUuid
::
createUuid
().
toString
();
QString
file
_i
d
=
QStringLiteral
(
"%1.jpg"
).
arg
(
uuid
.
mid
(
1
,
uuid
.
length
()
-
2
));
QString
file
I
d
=
QStringLiteral
(
"%1.jpg"
).
arg
(
uuid
.
mid
(
1
,
uuid
.
length
()
-
2
));
if
(
!
thumbnail
.
save
(
::
Utils
::
linphoneStringToQString
(
Paths
::
getThumbnailsDirpath
())
+
file
_i
d
,
"jpg"
,
100
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to create thumbnail of: `%1`."
).
arg
(
thumbnail
_p
ath
);
if
(
!
thumbnail
.
save
(
::
Utils
::
linphoneStringToQString
(
Paths
::
getThumbnailsDirpath
())
+
file
I
d
,
"jpg"
,
100
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to create thumbnail of: `%1`."
).
arg
(
thumbnail
P
ath
);
return
;
}
message
->
setAppdata
(
::
Utils
::
qStringToLinphoneString
(
file
_i
d
));
message
->
setAppdata
(
::
Utils
::
qStringToLinphoneString
(
file
I
d
));
}
inline
void
removeFileMessageThumbnail
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
if
(
message
&&
message
->
getFileTransferInformation
())
{
message
->
cancelFileTransfer
();
string
file
_i
d
=
message
->
getAppdata
();
if
(
!
file
_i
d
.
empty
())
{
QString
thumbnail
_path
=
::
Utils
::
linphoneStringToQString
(
Paths
::
getThumbnailsDirpath
()
+
file_i
d
);
if
(
!
QFile
::
remove
(
thumbnail
_p
ath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
thumbnail
_p
ath
);
string
file
I
d
=
message
->
getAppdata
();
if
(
!
file
I
d
.
empty
())
{
QString
thumbnail
Path
=
::
Utils
::
linphoneStringToQString
(
Paths
::
getThumbnailsDirpath
()
+
fileI
d
);
if
(
!
QFile
::
remove
(
thumbnail
P
ath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
thumbnail
P
ath
);
}
}
}
...
...
@@ -97,22 +97,22 @@ class ChatModel::MessageHandlers : public linphone::ChatMessageListener {
friend
class
ChatModel
;
public:
MessageHandlers
(
ChatModel
*
chat
_model
)
:
m_chat_model
(
chat_m
odel
)
{}
MessageHandlers
(
ChatModel
*
chat
Model
)
:
mChatModel
(
chatM
odel
)
{}
~
MessageHandlers
()
=
default
;
private:
QList
<
ChatEntryData
>::
iterator
findMessageEntry
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
return
find_if
(
m
_chat_model
->
m_entries
.
begin
(),
m_chat_model
->
m_e
ntries
.
end
(),
[
&
message
](
const
ChatEntryData
&
pair
)
{
m
ChatModel
->
mEntries
.
begin
(),
mChatModel
->
mE
ntries
.
end
(),
[
&
message
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
message
;
}
);
}
void
signalDataChanged
(
const
QList
<
ChatEntryData
>::
iterator
&
it
)
{
int
row
=
static_cast
<
int
>
(
distance
(
m
_chat_model
->
m_e
ntries
.
begin
(),
it
));
emit
m
_chat_model
->
dataChanged
(
m_chat_model
->
index
(
row
,
0
),
m_chat_m
odel
->
index
(
row
,
0
));
int
row
=
static_cast
<
int
>
(
distance
(
m
ChatModel
->
mE
ntries
.
begin
(),
it
));
emit
m
ChatModel
->
dataChanged
(
mChatModel
->
index
(
row
,
0
),
mChatM
odel
->
index
(
row
,
0
));
}
shared_ptr
<
linphone
::
Buffer
>
onFileTransferSend
(
...
...
@@ -131,11 +131,11 @@ private:
size_t
offset
,
size_t
)
override
{
if
(
!
m
_chat_m
odel
)
if
(
!
m
ChatM
odel
)
return
;
auto
it
=
findMessageEntry
(
message
);
if
(
it
==
m
_chat_model
->
m_e
ntries
.
end
())
if
(
it
==
m
ChatModel
->
mE
ntries
.
end
())
return
;
(
*
it
).
first
[
"fileOffset"
]
=
static_cast
<
quint64
>
(
offset
);
...
...
@@ -144,11 +144,11 @@ private:
}
void
onMsgStateChanged
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
,
linphone
::
ChatMessageState
state
)
override
{
if
(
!
m
_chat_m
odel
)
if
(
!
m
ChatM
odel
)
return
;
auto
it
=
findMessageEntry
(
message
);
if
(
it
==
m
_chat_model
->
m_e
ntries
.
end
())
if
(
it
==
m
ChatModel
->
mE
ntries
.
end
())
return
;
// File message downloaded.
...
...
@@ -163,7 +163,7 @@ private:
signalDataChanged
(
it
);
}
ChatModel
*
m
_chat_m
odel
;
ChatModel
*
m
ChatM
odel
;
};
// -----------------------------------------------------------------------------
...
...
@@ -171,17 +171,17 @@ private:
ChatModel
::
ChatModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
CoreManager
*
core
=
CoreManager
::
getInstance
();
m
_core_h
andlers
=
core
->
getHandlers
();
m
_message_h
andlers
=
make_shared
<
MessageHandlers
>
(
this
);
m
CoreH
andlers
=
core
->
getHandlers
();
m
MessageH
andlers
=
make_shared
<
MessageHandlers
>
(
this
);
core
->
getSipAddressesModel
()
->
connectToChatModel
(
this
);
QObject
::
connect
(
&
(
*
m
_core_h
andlers
),
&
CoreHandlers
::
messageReceived
,
this
,
&
ChatModel
::
handleMessageReceived
);
QObject
::
connect
(
&
(
*
m
_core_h
andlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
&
ChatModel
::
handleCallStateChanged
);
QObject
::
connect
(
&
(
*
m
CoreH
andlers
),
&
CoreHandlers
::
messageReceived
,
this
,
&
ChatModel
::
handleMessageReceived
);
QObject
::
connect
(
&
(
*
m
CoreH
andlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
&
ChatModel
::
handleCallStateChanged
);
}
ChatModel
::~
ChatModel
()
{
m
_message_handlers
->
m_chat_m
odel
=
nullptr
;
m
MessageHandlers
->
mChatM
odel
=
nullptr
;
}
QHash
<
int
,
QByteArray
>
ChatModel
::
roleNames
()
const
{
...
...
@@ -192,20 +192,20 @@ QHash<int, QByteArray> ChatModel::roleNames () const {
}
int
ChatModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m
_e
ntries
.
count
();
return
m
E
ntries
.
count
();
}
QVariant
ChatModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
_e
ntries
.
count
())
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
E
ntries
.
count
())
return
QVariant
();
switch
(
role
)
{
case
Roles
:
:
ChatEntry
:
return
QVariant
::
fromValue
(
m
_e
ntries
[
row
].
first
);
return
QVariant
::
fromValue
(
m
E
ntries
[
row
].
first
);
case
Roles
:
:
SectionDate
:
return
QVariant
::
fromValue
(
m
_e
ntries
[
row
].
first
[
"timestamp"
].
toDate
());
return
QVariant
::
fromValue
(
m
E
ntries
[
row
].
first
[
"timestamp"
].
toDate
());
}
return
QVariant
();
...
...
@@ -218,51 +218,51 @@ bool ChatModel::removeRow (int row, const QModelIndex &) {
bool
ChatModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
{
int
limit
=
row
+
count
-
1
;
if
(
row
<
0
||
count
<
0
||
limit
>=
m
_e
ntries
.
count
())
if
(
row
<
0
||
count
<
0
||
limit
>=
m
E
ntries
.
count
())
return
false
;
beginRemoveRows
(
parent
,
row
,
limit
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
removeEntry
(
m
_e
ntries
[
row
]);
m
_e
ntries
.
removeAt
(
row
);
removeEntry
(
m
E
ntries
[
row
]);
m
E
ntries
.
removeAt
(
row
);
}
endRemoveRows
();
if
(
m
_e
ntries
.
count
()
==
0
)
if
(
m
E
ntries
.
count
()
==
0
)
emit
allEntriesRemoved
();
return
true
;
}
QString
ChatModel
::
getSipAddress
()
const
{
if
(
!
m
_chat_r
oom
)
if
(
!
m
ChatR
oom
)
return
""
;
return
::
Utils
::
linphoneStringToQString
(
m
_chat_r
oom
->
getPeerAddress
()
->
asStringUriOnly
()
m
ChatR
oom
->
getPeerAddress
()
->
asStringUriOnly
()
);
}
void
ChatModel
::
setSipAddress
(
const
QString
&
sip
_a
ddress
)
{
if
(
sip
_address
==
getSipAddress
()
||
sip_a
ddress
.
isEmpty
())
void
ChatModel
::
setSipAddress
(
const
QString
&
sip
A
ddress
)
{
if
(
sip
Address
==
getSipAddress
()
||
sipA
ddress
.
isEmpty
())
return
;
beginResetModel
();
// Invalid old sip address entries.
m
_e
ntries
.
clear
();
m
E
ntries
.
clear
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
m
_chat_room
=
core
->
getChatRoomFromUri
(
::
Utils
::
qStringToLinphoneString
(
sip_a
ddress
));
m
ChatRoom
=
core
->
getChatRoomFromUri
(
::
Utils
::
qStringToLinphoneString
(
sipA
ddress
));
if
(
m
_chat_r
oom
->
getUnreadMessagesCount
()
>
0
)
if
(
m
ChatR
oom
->
getUnreadMessagesCount
()
>
0
)
resetMessagesCount
();
// Get messages.
for
(
auto
&
message
:
m
_chat_r
oom
->
getHistory
(
0
))
{
for
(
auto
&
message
:
m
ChatR
oom
->
getHistory
(
0
))
{
QVariantMap
map
;
fillMessageEntry
(
map
,
message
);
...
...
@@ -271,16 +271,16 @@ void ChatModel::setSipAddress (const QString &sip_address) {
if
(
message
->
getState
()
==
linphone
::
ChatMessageStateInProgress
)
map
[
"status"
]
=
linphone
::
ChatMessageStateNotDelivered
;
m
_e
ntries
<<
qMakePair
(
map
,
static_pointer_cast
<
void
>
(
message
));
m
E
ntries
<<
qMakePair
(
map
,
static_pointer_cast
<
void
>
(
message
));
}
// Get calls.
for
(
auto
&
call
_log
:
core
->
getCallHistoryForAddress
(
m_chat_r
oom
->
getPeerAddress
()))
insertCall
(
call
_l
og
);
for
(
auto
&
call
Log
:
core
->
getCallHistoryForAddress
(
mChatR
oom
->
getPeerAddress
()))
insertCall
(
call
L
og
);
endResetModel
();
emit
sipAddressChanged
(
sip
_a
ddress
);
emit
sipAddressChanged
(
sip
A
ddress
);
}
// -----------------------------------------------------------------------------
...
...
@@ -298,10 +298,10 @@ void ChatModel::removeAllEntries () {
beginResetModel
();
for
(
auto
&
entry
:
m
_e
ntries
)
for
(
auto
&
entry
:
m
E
ntries
)
removeEntry
(
entry
);
m
_e
ntries
.
clear
();
m
E
ntries
.
clear
();
endResetModel
();
...
...
@@ -309,28 +309,28 @@ void ChatModel::removeAllEntries () {
}
void
ChatModel
::
sendMessage
(
const
QString
&
message
)
{
if
(
!
m
_chat_r
oom
)
if
(
!
m
ChatR
oom
)
return
;
shared_ptr
<
linphone
::
ChatMessage
>
_message
=
m
_chat_r
oom
->
createMessage
(
::
Utils
::
qStringToLinphoneString
(
message
));
_message
->
setListener
(
m
_message_h
andlers
);
shared_ptr
<
linphone
::
ChatMessage
>
_message
=
m
ChatR
oom
->
createMessage
(
::
Utils
::
qStringToLinphoneString
(
message
));
_message
->
setListener
(
m
MessageH
andlers
);
insertMessageAtEnd
(
_message
);
m
_chat_r
oom
->
sendChatMessage
(
_message
);
m
ChatR
oom
->
sendChatMessage
(
_message
);
emit
messageSent
(
_message
);
}
void
ChatModel
::
resendMessage
(
int
id
)
{
if
(
!
m
_chat_r
oom
)
if
(
!
m
ChatR
oom
)
return
;
if
(
id
<
0
||
id
>
m
_e
ntries
.
count
())
{
if
(
id
<
0
||
id
>
m
E
ntries
.
count
())
{
qWarning
()
<<
QStringLiteral
(
"Entry %1 not exists."
).
arg
(
id
);
return
;
}
const
ChatEntryData
&
entry
=
m
_e
ntries
[
id
];
const
ChatEntryData
&
entry
=
m
E
ntries
[
id
];
const
QVariantMap
&
map
=
entry
.
first
;
if
(
map
[
"type"
]
!=
EntryType
::
MessageEntry
)
{
...
...
@@ -345,8 +345,8 @@ void ChatModel::resendMessage (int id) {
shared_ptr
<
linphone
::
ChatMessage
>
message
=
static_pointer_cast
<
linphone
::
ChatMessage
>
(
entry
.
second
);
shared_ptr
<
linphone
::
ChatMessage
>
message2
=
message
->
clone
();
message2
->
setListener
(
m
_message_h
andlers
);
m
_chat_r
oom
->
sendChatMessage
(
message2
);
message2
->
setListener
(
m
MessageH
andlers
);
m
ChatR
oom
->
sendChatMessage
(
message2
);
removeEntry
(
id
);
insertMessageAtEnd
(
message2
);
...
...
@@ -360,7 +360,7 @@ void ChatModel::resendMessage (int id) {
}
void
ChatModel
::
sendFileMessage
(
const
QString
&
path
)
{
if
(
!
m
_chat_r
oom
)
if
(
!
m
ChatR
oom
)
return
;
QFile
file
(
path
);
...
...
@@ -373,28 +373,28 @@ void ChatModel::sendFileMessage (const QString &path) {
content
->
setSize
(
file
.
size
());
content
->
setName
(
::
Utils
::
qStringToLinphoneString
(
QFileInfo
(
file
).
fileName
()));
shared_ptr
<
linphone
::
ChatMessage
>
message
=
m
_chat_r
oom
->
createFileTransferMessage
(
content
);
shared_ptr
<
linphone
::
ChatMessage
>
message
=
m
ChatR
oom
->
createFileTransferMessage
(
content
);
message
->
setFileTransferFilepath
(
::
Utils
::
qStringToLinphoneString
(
path
));
message
->
setListener
(
m
_message_h
andlers
);
message
->
setListener
(
m
MessageH
andlers
);
createThumbnail
(
message
);
insertMessageAtEnd
(
message
);
m
_chat_r
oom
->
sendChatMessage
(
message
);
m
ChatR
oom
->
sendChatMessage
(
message
);
emit
messageSent
(
message
);
}
void
ChatModel
::
downloadFile
(
int
id
,
const
QString
&
download
_p
ath
)
{
if
(
!
m
_chat_r
oom
)
void
ChatModel
::
downloadFile
(
int
id
,
const
QString
&
download
P
ath
)
{
if
(
!
m
ChatR
oom
)
return
;
if
(
id
<
0
||
id
>
m
_e
ntries
.
count
())
{
if
(
id
<
0
||
id
>
m
E
ntries
.
count
())
{
qWarning
()
<<
QStringLiteral
(
"Entry %1 not exists."
).
arg
(
id
);
return
;
}
const
ChatEntryData
&
entry
=
m
_e
ntries
[
id
];
const
ChatEntryData
&
entry
=
m
E
ntries
[
id
];
if
(
entry
.
first
[
"type"
]
!=
EntryType
::
MessageEntry
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to download entry %1. It's not a message."
).
arg
(
id
);
return
;
...
...
@@ -419,12 +419,12 @@ void ChatModel::downloadFile (int id, const QString &download_path) {
}
message
->
setFileTransferFilepath
(
::
Utils
::
qStringToLinphoneString
(
download
_p
ath
.
startsWith
(
"file://"
)
?
download
_p
ath
.
mid
(
sizeof
(
"file://"
)
-
1
)
:
download
_p
ath
::
Utils
::
qStringToLinphoneString
(
download
P
ath
.
startsWith
(
"file://"
)
?
download
P
ath
.
mid
(
sizeof
(
"file://"
)
-
1
)
:
download
P
ath
)
);
message
->
setListener
(
m
_message_h
andlers
);
message
->
setListener
(
m
MessageH
andlers
);
if
(
message
->
downloadFile
()
<
0
)
qWarning
()
<<
QStringLiteral
(
"Unable to download file of entry %1."
).
arg
(
id
);
...
...
@@ -447,23 +447,23 @@ void ChatModel::fillMessageEntry (QVariantMap &dest, const shared_ptr<linphone::
}
}
void
ChatModel
::
fillCallStartEntry
(
QVariantMap
&
dest
,
const
shared_ptr
<
linphone
::
CallLog
>
&
call
_l
og
)
{
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
(
call
_l
og
->
getStartDate
()
*
1000
);
void
ChatModel
::
fillCallStartEntry
(
QVariantMap
&
dest
,
const
shared_ptr
<
linphone
::
CallLog
>
&
call
L
og
)
{
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
(
call
L
og
->
getStartDate
()
*
1000
);
dest
[
"type"
]
=
EntryType
::
CallEntry
;
dest
[
"timestamp"
]
=
timestamp
;
dest
[
"isOutgoing"
]
=
call
_l
og
->
getDir
()
==
linphone
::
CallDirOutgoing
;
dest
[
"status"
]
=
call
_l
og
->
getStatus
();
dest
[
"isOutgoing"
]
=
call
L
og
->
getDir
()
==
linphone
::
CallDirOutgoing
;
dest
[
"status"
]
=
call
L
og
->
getStatus
();
dest
[
"isStart"
]
=
true
;
}
void
ChatModel
::
fillCallEndEntry
(
QVariantMap
&
dest
,
const
shared_ptr
<
linphone
::
CallLog
>
&
call
_l
og
)
{
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
((
call
_log
->
getStartDate
()
+
call_l
og
->
getDuration
())
*
1000
);
void
ChatModel
::
fillCallEndEntry
(
QVariantMap
&
dest
,
const
shared_ptr
<
linphone
::
CallLog
>
&
call
L
og
)
{
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
((
call
Log
->
getStartDate
()
+
callL
og
->
getDuration
())
*
1000
);
dest
[
"type"
]
=
EntryType
::
CallEntry
;
dest
[
"timestamp"
]
=
timestamp
;
dest
[
"isOutgoing"
]
=
call
_l
og
->
getDir
()
==
linphone
::
CallDirOutgoing
;
dest
[
"status"
]
=
call
_l
og
->
getStatus
();
dest
[
"isOutgoing"
]
=
call
L
og
->
getDir
()
==
linphone
::
CallDirOutgoing
;
dest
[
"status"
]
=
call
L
og
->
getStatus
();
dest
[
"isStart"
]
=
false
;
}
...
...
@@ -476,7 +476,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
case
ChatModel
:
:
MessageEntry
:
{
shared_ptr
<
linphone
::
ChatMessage
>
message
=
static_pointer_cast
<
linphone
::
ChatMessage
>
(
pair
.
second
);
removeFileMessageThumbnail
(
message
);
m
_chat_r
oom
->
deleteMessage
(
message
);
m
ChatR
oom
->
deleteMessage
(
message
);
break
;
}
...
...
@@ -485,15 +485,15 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
// WARNING: Unable to remove symmetric call here. (start/end)
// We are between `beginRemoveRows` and `endRemoveRows`.
// A solution is to schedule a `removeEntry` call in the Qt main loop.
shared_ptr
<
void
>
linphone
_p
tr
=
pair
.
second
;
shared_ptr
<
void
>
linphone
P
tr
=
pair
.
second
;
QTimer
::
singleShot
(
0
,
this
,
[
this
,
linphone
_p
tr
]()
{
auto
it
=
find_if
(
m
_entries
.
begin
(),
m_entries
.
end
(),
[
linphone_p
tr
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
linphone
_p
tr
;
0
,
this
,
[
this
,
linphone
P
tr
]()
{
auto
it
=
find_if
(
m
Entries
.
begin
(),
mEntries
.
end
(),
[
linphoneP
tr
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
linphone
P
tr
;
});
if
(
it
!=
m
_e
ntries
.
end
())
removeEntry
(
static_cast
<
int
>
(
distance
(
m
_e
ntries
.
begin
(),
it
)));
if
(
it
!=
m
E
ntries
.
end
())
removeEntry
(
static_cast
<
int
>
(
distance
(
m
E
ntries
.
begin
(),
it
)));
}
);
}
...
...
@@ -507,28 +507,28 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
}
}
void
ChatModel
::
insertCall
(
const
shared_ptr
<
linphone
::
CallLog
>
&
call
_l
og
)
{
auto
insert
_e
ntry
=
[
this
](
void
ChatModel
::
insertCall
(
const
shared_ptr
<
linphone
::
CallLog
>
&
call
L
og
)
{
auto
insert
E
ntry
=
[
this
](
const
ChatEntryData
&
pair
,
const
QList
<
ChatEntryData
>::
iterator
*
start
=
NULL
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
m
_entries
.
begin
(),
m_e
ntries
.
end
(),
pair
,
start
?
*
start
:
m
Entries
.
begin
(),
mE
ntries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
return
a
.
first
[
"timestamp"
]
<
b
.
first
[
"timestamp"
];
}
);
int
row
=
static_cast
<
int
>
(
distance
(
m
_e
ntries
.
begin
(),
it
));
int
row
=
static_cast
<
int
>
(
distance
(
m
E
ntries
.
begin
(),
it
));
beginInsertRows
(
QModelIndex
(),
row
,
row
);
it
=
m
_e
ntries
.
insert
(
it
,
pair
);
it
=
m
E
ntries
.
insert
(
it
,
pair
);
endInsertRows
();
return
it
;
};
linphone
::
CallStatus
status
=
call
_l
og
->
getStatus
();
linphone
::
CallStatus
status
=
call
L
og
->
getStatus
();
// Ignore aborted calls.
if
(
status
==
linphone
::
CallStatusAborted
)
...
...
@@ -536,43 +536,43 @@ void ChatModel::insertCall (const shared_ptr<linphone::CallLog> &call_log) {
// Add start call.
QVariantMap
start
;
fillCallStartEntry
(
start
,
call
_l
og
);
auto
it
=
insert
_entry
(
qMakePair
(
start
,
static_pointer_cast
<
void
>
(
call_l
og
)));
fillCallStartEntry
(
start
,
call
L
og
);
auto
it
=
insert
Entry
(
qMakePair
(
start
,
static_pointer_cast
<
void
>
(
callL
og
)));
// Add end call. (if necessary)
if
(
status
==
linphone
::
CallStatusSuccess
)
{
QVariantMap
end
;
fillCallEndEntry
(
end
,
call
_l
og
);
insert
_entry
(
qMakePair
(
end
,
static_pointer_cast
<
void
>
(
call_l
og
)),
&
it
);
fillCallEndEntry
(
end
,
call
L
og
);
insert
Entry
(
qMakePair
(
end
,
static_pointer_cast
<
void
>
(
callL
og
)),
&
it
);
}
}
void
ChatModel
::
insertMessageAtEnd
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
int
row
=
m
_e
ntries
.
count
();
int
row
=
m
E
ntries
.
count
();
beginInsertRows
(
QModelIndex
(),
row
,
row
);
QVariantMap
map
;
fillMessageEntry
(
map
,
message
);
m
_e
ntries
<<
qMakePair
(
map
,
static_pointer_cast
<
void
>
(
message
));
m
E
ntries
<<
qMakePair
(
map
,
static_pointer_cast
<
void
>
(
message
));
endInsertRows
();
}
void
ChatModel
::
resetMessagesCount
()
{
m
_chat_r
oom
->
markAsRead
();
m
ChatR
oom
->
markAsRead
();
emit
messagesCountReset
();
}
// -----------------------------------------------------------------------------
void
ChatModel
::
handleCallStateChanged
(
const
s
td
::
s
hared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
if
(
m
_chat_r
oom
==
call
->
getChatRoom
()
&&
(
state
==
linphone
::
CallStateEnd
||
state
==
linphone
::
CallStateError
))
void
ChatModel
::
handleCallStateChanged
(
const
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
if
(
m
ChatR
oom
==
call
->
getChatRoom
()
&&
(
state
==
linphone
::
CallStateEnd
||
state
==
linphone
::
CallStateError
))
insertCall
(
call
->
getCallLog
());
}
void
ChatModel
::
handleMessageReceived
(
const
s
td
::
s
hared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
if
(
m
_chat_r
oom
==
message
->
getChatRoom
())
{
void
ChatModel
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
if
(
m
ChatR
oom
==
message
->
getChatRoom
())
{
insertMessageAtEnd
(
message
);
resetMessagesCount
();
...
...
linphone-desktop/src/components/chat/ChatModel.hpp
View file @
d8ff1b14
...
...
@@ -86,7 +86,7 @@ public:
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
())
override
;
QString
getSipAddress
()
const
;
void
setSipAddress
(
const
QString
&
sip
_a
ddress
);
void
setSipAddress
(
const
QString
&
sip
A
ddress
);
void
removeEntry
(
int
id
);
void
removeAllEntries
();
...
...
@@ -97,10 +97,10 @@ public:
void
sendFileMessage
(
const
QString
&
path
);
void
downloadFile
(
int
id
,
const
QString
&
download
_p
ath
);
void
downloadFile
(
int
id
,
const
QString
&
download
P
ath
);
signals:
void
sipAddressChanged
(
const
QString
&
sip
_a
ddress
);
void
sipAddressChanged
(
const
QString
&
sip
A
ddress
);
void
allEntriesRemoved
();
void
messageSent
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
...
...
@@ -112,12 +112,12 @@ private:
typedef
QPair
<
QVariantMap
,
std
::
shared_ptr
<
void
>
>
ChatEntryData
;
void
fillMessageEntry
(
QVariantMap
&
dest
,
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
fillCallStartEntry
(
QVariantMap
&
dest
,
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call
_l
og
);
void
fillCallEndEntry
(
QVariantMap
&
dest
,
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call
_l
og
);
void
fillCallStartEntry
(
QVariantMap
&
dest
,
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call
L
og
);
void
fillCallEndEntry
(
QVariantMap
&
dest
,
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call
L
og
);
void
removeEntry
(
ChatEntryData
&
pair
);
void
insertCall
(
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call
_l
og
);
void
insertCall
(
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call
L
og
);
void
insertMessageAtEnd
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
resetMessagesCount
();
...
...
@@ -125,11 +125,11 @@ private:
void
handleCallStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
);
void
handleMessageReceived
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
QList
<
ChatEntryData
>
m
_e
ntries
;
std
::
shared_ptr
<
linphone
::
ChatRoom
>
m
_chat_r
oom
;
QList
<
ChatEntryData
>
m
E
ntries
;
std
::
shared_ptr
<
linphone
::
ChatRoom
>
m
ChatR
oom
;
std
::
shared_ptr
<
CoreHandlers
>
m
_core_h
andlers
;
std
::
shared_ptr
<
MessageHandlers
>
m
_message_h
andlers
;
std
::
shared_ptr
<
CoreHandlers
>
m
CoreH
andlers
;
std
::
shared_ptr
<
MessageHandlers
>
m
MessageH
andlers
;
};
#endif // CHAT_MODEL_H_
linphone-desktop/src/components/chat/ChatProxyModel.cpp
View file @
d8ff1b14
...
...
@@ -30,32 +30,32 @@ using namespace std;
class
ChatProxyModel
::
ChatModelFilter
:
public
QSortFilterProxyModel
{
public:
ChatModelFilter
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
setSourceModel
(
&
m
_chat_m
odel
);
setSourceModel
(
&
m
ChatM
odel
);
}
ChatModel
::
EntryType
getEntryTypeFilter
()
{
return
m
_entry_type_f
ilter
;
return
m
EntryTypeF
ilter
;
}
void
setEntryTypeFilter
(
ChatModel
::
EntryType
type
)
{
m
_entry_type_f
ilter
=
type
;
m
EntryTypeF
ilter
=
type
;
invalidate
();
}
protected:
bool
filterAcceptsRow
(
int
source
_r
ow
,
const
QModelIndex
&
)
const
override
{
if
(
m
_entry_type_f
ilter
==
ChatModel
::
EntryType
::
GenericEntry
)
bool
filterAcceptsRow
(
int
source
R
ow
,
const
QModelIndex
&
)
const
override
{
if
(
m
EntryTypeF
ilter
==
ChatModel
::
EntryType
::
GenericEntry
)
return
true
;
QModelIndex
index
=
sourceModel
()
->
index
(
source
_r
ow
,
0
,
QModelIndex
());
QModelIndex
index
=
sourceModel
()
->
index
(
source
R
ow
,
0
,
QModelIndex
());
const
QVariantMap
&
data
=
index
.
data
().
toMap
();
return
data
[
"type"
].
toInt
()
==
m
_entry_type_f
ilter
;
return
data
[
"type"
].
toInt
()
==
m
EntryTypeF
ilter
;
}
private:
ChatModel
m
_chat_m
odel
;
ChatModel
::
EntryType
m
_entry_type_f
ilter
=
ChatModel
::
EntryType
::
GenericEntry
;
ChatModel
m
ChatM
odel
;
ChatModel
::
EntryType
m
EntryTypeF
ilter
=
ChatModel
::
EntryType
::
GenericEntry
;
};
// =============================================================================
...
...
@@ -63,34 +63,34 @@ private:
const
int
ChatProxyModel
::
ENTRIES_CHUNK_SIZE
=
50
;
ChatProxyModel
::
ChatProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
m
_chat_model_f
ilter
=
new
ChatModelFilter
(
this
);
m
ChatModelF
ilter
=
new
ChatModelFilter
(
this
);
setSourceModel
(
m
_chat_model_f
ilter
);
setSourceModel
(
m
ChatModelF
ilter
);
ChatModel
*
chat
=
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
());
ChatModel
*
chat
=
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
());
QObject
::
connect
(
chat
,
&
ChatModel
::
messageReceived
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
m
_n_max_displayed_e
ntries
++
;
m
MaxDisplayedE
ntries
++
;
}
);
QObject
::
connect
(
chat
,
&
ChatModel
::
messageSent
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
m
_n_max_displayed_e
ntries
++
;
m
MaxDisplayedE
ntries
++
;
}
);
}
void
ChatProxyModel
::
loadMoreEntries
()
{
int
count
=
rowCount
();
int
parent
_count
=
m_chat_model_f
ilter
->
rowCount
();
int
parent
Count
=
mChatModelF
ilter
->
rowCount
();
if
(
count
<
parent
_c
ount
)
{
// Do not increase `m
_n_max_displayed_e
ntries` if it's not necessary...
if
(
count
<
parent
C
ount
)
{
// Do not increase `m
MaxDisplayedE
ntries` if it's not necessary...
// Limit qml calls.
if
(
count
==
m
_n_max_displayed_e
ntries
)
m
_n_max_displayed_e
ntries
+=
ENTRIES_CHUNK_SIZE
;
if
(
count
==
m
MaxDisplayedE
ntries
)
m
MaxDisplayedE
ntries
+=
ENTRIES_CHUNK_SIZE
;
invalidateFilter
();
...
...
@@ -101,59 +101,59 @@ void ChatProxyModel::loadMoreEntries () {
}
void
ChatProxyModel
::
setEntryTypeFilter
(
ChatModel
::
EntryType
type
)
{
if
(
m
_chat_model_f
ilter
->
getEntryTypeFilter
()
!=
type
)
{
m
_chat_model_f
ilter
->
setEntryTypeFilter
(
type
);
if
(
m
ChatModelF
ilter
->
getEntryTypeFilter
()
!=
type
)
{
m
ChatModelF
ilter
->
setEntryTypeFilter
(
type
);
emit
entryTypeFilterChanged
(
type
);
}
}
void
ChatProxyModel
::
removeEntry
(
int
id
)
{
QModelIndex
source
_i
ndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
removeEntry
(
m
_chat_model_filter
->
mapToSource
(
source_i
ndex
).
row
()
QModelIndex
source
I
ndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
removeEntry
(
m
ChatModelFilter
->
mapToSource
(
sourceI
ndex
).
row
()
);
}
void
ChatProxyModel
::
removeAllEntries
()
{
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
removeAllEntries
();
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
removeAllEntries
();
}
void
ChatProxyModel
::
sendMessage
(
const
QString
&
message
)
{
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
sendMessage
(
message
);
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
sendMessage
(
message
);
}
void
ChatProxyModel
::
resendMessage
(
int
id
)
{
QModelIndex
source
_i
ndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
resendMessage
(
m
_chat_model_filter
->
mapToSource
(
source_i
ndex
).
row
()
QModelIndex
source
I
ndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
resendMessage
(
m
ChatModelFilter
->
mapToSource
(
sourceI
ndex
).
row
()
);
}
void
ChatProxyModel
::
sendFileMessage
(
const
QString
&
path
)
{
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
sendFileMessage
(
path
);
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
sendFileMessage
(
path
);
}
void
ChatProxyModel
::
downloadFile
(
int
id
,
const
QString
&
download
_p
ath
)
{
QModelIndex
source
_i
ndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
downloadFile
(
m
_chat_model_filter
->
mapToSource
(
source_index
).
row
(),
download_p
ath
void
ChatProxyModel
::
downloadFile
(
int
id
,
const
QString
&
download
P
ath
)
{
QModelIndex
source
I
ndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
downloadFile
(
m
ChatModelFilter
->
mapToSource
(
sourceIndex
).
row
(),
downloadP
ath
);
}
// -----------------------------------------------------------------------------
bool
ChatProxyModel
::
filterAcceptsRow
(
int
source
_r
ow
,
const
QModelIndex
&
)
const
{
return
m
_chat_model_filter
->
rowCount
()
-
source_row
<=
m_n_max_displayed_e
ntries
;
bool
ChatProxyModel
::
filterAcceptsRow
(
int
source
R
ow
,
const
QModelIndex
&
)
const
{
return
m
ChatModelFilter
->
rowCount
()
-
sourceRow
<=
mMaxDisplayedE
ntries
;
}
// -----------------------------------------------------------------------------
QString
ChatProxyModel
::
getSipAddress
()
const
{
return
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
getSipAddress
();
return
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
getSipAddress
();
}
void
ChatProxyModel
::
setSipAddress
(
const
QString
&
sip
_a
ddress
)
{
static_cast
<
ChatModel
*>
(
m
_chat_model_f
ilter
->
sourceModel
())
->
setSipAddress
(
sip
_a
ddress
void
ChatProxyModel
::
setSipAddress
(
const
QString
&
sip
A
ddress
)
{
static_cast
<
ChatModel
*>
(
m
ChatModelF
ilter
->
sourceModel
())
->
setSipAddress
(
sip
A
ddress
);
}
linphone-desktop/src/components/chat/ChatProxyModel.hpp
View file @
d8ff1b14
...
...
@@ -50,23 +50,23 @@ public:
Q_INVOKABLE
void
sendFileMessage
(
const
QString
&
path
);
Q_INVOKABLE
void
downloadFile
(
int
id
,
const
QString
&
download
_p
ath
);
Q_INVOKABLE
void
downloadFile
(
int
id
,
const
QString
&
download
P
ath
);
signals:
void
sipAddressChanged
(
const
QString
&
sip
_a
ddress
);
void
sipAddressChanged
(
const
QString
&
sip
A
ddress
);
void
moreEntriesLoaded
(
int
n
);
void
entryTypeFilterChanged
(
ChatModel
::
EntryType
type
);
protected:
bool
filterAcceptsRow
(
int
source
_row
,
const
QModelIndex
&
source_p
arent
)
const
override
;
bool
filterAcceptsRow
(
int
source
Row
,
const
QModelIndex
&
sourceP
arent
)
const
override
;
private:
QString
getSipAddress
()
const
;
void
setSipAddress
(
const
QString
&
sip
_a
ddress
);
void
setSipAddress
(
const
QString
&
sip
A
ddress
);
ChatModelFilter
*
m
_chat_model_f
ilter
;
int
m
_n_max_displayed_e
ntries
=
ENTRIES_CHUNK_SIZE
;
ChatModelFilter
*
m
ChatModelF
ilter
;
int
m
MaxDisplayedE
ntries
=
ENTRIES_CHUNK_SIZE
;
static
const
int
ENTRIES_CHUNK_SIZE
;
};
...
...
linphone-desktop/src/components/codecs/AbstractCodecsModel.cpp
View file @
d8ff1b14
...
...
@@ -38,7 +38,7 @@ inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map
AbstractCodecsModel
::
AbstractCodecsModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{}
int
AbstractCodecsModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m
_c
odecs
.
count
();
return
m
C
odecs
.
count
();
}
QHash
<
int
,
QByteArray
>
AbstractCodecsModel
::
roleNames
()
const
{
...
...
@@ -50,11 +50,11 @@ QHash<int, QByteArray> AbstractCodecsModel::roleNames () const {
QVariant
AbstractCodecsModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
_c
odecs
.
count
())
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
C
odecs
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
m
_c
odecs
[
row
];
return
m
C
odecs
[
row
];
return
QVariant
();
}
...
...
@@ -62,9 +62,9 @@ QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const {
// -----------------------------------------------------------------------------
void
AbstractCodecsModel
::
enableCodec
(
int
id
,
bool
status
)
{
Q_ASSERT
(
id
>=
0
&&
id
<
m
_c
odecs
.
count
());
Q_ASSERT
(
id
>=
0
&&
id
<
m
C
odecs
.
count
());
QVariantMap
&
map
=
m
_c
odecs
[
id
];
QVariantMap
&
map
=
m
C
odecs
[
id
];
shared_ptr
<
linphone
::
PayloadType
>
codec
=
getCodecFromMap
(
map
);
codec
->
enable
(
status
);
...
...
@@ -78,9 +78,9 @@ void AbstractCodecsModel::moveCodec (int source, int destination) {
}
void
AbstractCodecsModel
::
setBitrate
(
int
id
,
int
bitrate
)
{
Q_ASSERT
(
id
>=
0
&&
id
<
m
_c
odecs
.
count
());
Q_ASSERT
(
id
>=
0
&&
id
<
m
C
odecs
.
count
());
QVariantMap
&
map
=
m
_c
odecs
[
id
];
QVariantMap
&
map
=
m
C
odecs
[
id
];
shared_ptr
<
linphone
::
PayloadType
>
codec
=
getCodecFromMap
(
map
);
codec
->
setNormalBitrate
(
bitrate
);
...
...
@@ -89,13 +89,13 @@ void AbstractCodecsModel::setBitrate (int id, int bitrate) {
emit
dataChanged
(
index
(
id
,
0
),
index
(
id
,
0
));
}
void
AbstractCodecsModel
::
setRecvFmtp
(
int
id
,
const
QString
&
recv
_f
mtp
)
{
Q_ASSERT
(
id
>=
0
&&
id
<
m
_c
odecs
.
count
());
void
AbstractCodecsModel
::
setRecvFmtp
(
int
id
,
const
QString
&
recv
F
mtp
)
{
Q_ASSERT
(
id
>=
0
&&
id
<
m
C
odecs
.
count
());
QVariantMap
&
map
=
m
_c
odecs
[
id
];
QVariantMap
&
map
=
m
C
odecs
[
id
];
shared_ptr
<
linphone
::
PayloadType
>
codec
=
getCodecFromMap
(
map
);
codec
->
setRecvFmtp
(
::
Utils
::
qStringToLinphoneString
(
recv
_f
mtp
));
codec
->
setRecvFmtp
(
::
Utils
::
qStringToLinphoneString
(
recv
F
mtp
));
map
[
"recvFmtp"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getRecvFmtp
());
emit
dataChanged
(
index
(
id
,
0
),
index
(
id
,
0
));
...
...
@@ -104,43 +104,43 @@ void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) {
// -----------------------------------------------------------------------------
bool
AbstractCodecsModel
::
moveRows
(
const
QModelIndex
&
source
_p
arent
,
int
source
_r
ow
,
const
QModelIndex
&
source
P
arent
,
int
source
R
ow
,
int
count
,
const
QModelIndex
&
destination
_p
arent
,
int
destination
_c
hild
const
QModelIndex
&
destination
P
arent
,
int
destination
C
hild
)
{
int
limit
=
source
_r
ow
+
count
-
1
;
int
limit
=
source
R
ow
+
count
-
1
;
{
int
n
_codecs
=
m_c
odecs
.
count
();
int
n
Codecs
=
mC
odecs
.
count
();
if
(
source
_r
ow
<
0
||
destination
_c
hild
<
0
||
source
R
ow
<
0
||
destination
C
hild
<
0
||
count
<
0
||
destination
_child
>
n_c
odecs
||
limit
>=
n
_c
odecs
||
(
source
_row
<=
destination_child
&&
source_row
+
count
>=
destination_c
hild
)
destination
Child
>
nC
odecs
||
limit
>=
n
C
odecs
||
(
source
Row
<=
destinationChild
&&
sourceRow
+
count
>=
destinationC
hild
)
)
return
false
;
}
beginMoveRows
(
source
_parent
,
source_row
,
limit
,
destination_parent
,
destination_c
hild
);
beginMoveRows
(
source
Parent
,
sourceRow
,
limit
,
destinationParent
,
destinationC
hild
);
// Update UI.
if
(
destination
_child
>
source_r
ow
)
{
--
destination
_c
hild
;
for
(
int
i
=
source
_r
ow
;
i
<=
limit
;
++
i
)
{
m
_codecs
.
move
(
source_row
,
destination_child
+
i
-
source_r
ow
);
if
(
destination
Child
>
sourceR
ow
)
{
--
destination
C
hild
;
for
(
int
i
=
source
R
ow
;
i
<=
limit
;
++
i
)
{
m
Codecs
.
move
(
sourceRow
,
destinationChild
+
i
-
sourceR
ow
);
}
}
else
{
for
(
int
i
=
source
_r
ow
;
i
<=
limit
;
++
i
)
m
_codecs
.
move
(
source_row
+
i
-
source_row
,
destination_child
+
i
-
source_r
ow
);
for
(
int
i
=
source
R
ow
;
i
<=
limit
;
++
i
)
m
Codecs
.
move
(
sourceRow
+
i
-
sourceRow
,
destinationChild
+
i
-
sourceR
ow
);
}
// Update linphone codecs list.
list
<
shared_ptr
<
linphone
::
PayloadType
>
>
codecs
;
for
(
const
auto
&
map
:
m
_c
odecs
)
for
(
const
auto
&
map
:
m
C
odecs
)
codecs
.
push_back
(
getCodecFromMap
(
map
));
updateCodecs
(
codecs
);
...
...
@@ -151,7 +151,7 @@ bool AbstractCodecsModel::moveRows (
// -----------------------------------------------------------------------------
void
AbstractCodecsModel
::
addCodec
(
s
td
::
s
hared_ptr
<
linphone
::
PayloadType
>
&
codec
)
{
void
AbstractCodecsModel
::
addCodec
(
shared_ptr
<
linphone
::
PayloadType
>
&
codec
)
{
QVariantMap
map
;
map
[
"bitrate"
]
=
codec
->
getNormalBitrate
();
...
...
@@ -167,5 +167,5 @@ void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &code
map
[
"recvFmtp"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getRecvFmtp
());
map
[
"__codec"
]
=
QVariant
::
fromValue
(
codec
);
m
_c
odecs
<<
map
;
m
C
odecs
<<
map
;
}
linphone-desktop/src/components/codecs/AbstractCodecsModel.hpp
View file @
d8ff1b14
...
...
@@ -49,15 +49,15 @@ public:
Q_INVOKABLE
void
moveCodec
(
int
source
,
int
destination
);
Q_INVOKABLE
void
setBitrate
(
int
id
,
int
bitrate
);
Q_INVOKABLE
void
setRecvFmtp
(
int
id
,
const
QString
&
recv
_f
mtp
);
Q_INVOKABLE
void
setRecvFmtp
(
int
id
,
const
QString
&
recv
F
mtp
);
protected:
bool
moveRows
(
const
QModelIndex
&
source
_p
arent
,
int
source
_r
ow
,
const
QModelIndex
&
source
P
arent
,
int
source
R
ow
,
int
count
,
const
QModelIndex
&
destination
_p
arent
,
int
destination
_c
hild
const
QModelIndex
&
destination
P
arent
,
int
destination
C
hild
)
override
;
void
addCodec
(
std
::
shared_ptr
<
linphone
::
PayloadType
>
&
codec
);
...
...
@@ -65,7 +65,7 @@ protected:
virtual
void
updateCodecs
(
std
::
list
<
std
::
shared_ptr
<
linphone
::
PayloadType
>
>
&
codecs
)
=
0
;
private:
QList
<
QVariantMap
>
m
_c
odecs
;
QList
<
QVariantMap
>
m
C
odecs
;
};
Q_DECLARE_METATYPE
(
std
::
shared_ptr
<
linphone
::
PayloadType
>
);
...
...
linphone-desktop/src/components/contact/ContactModel.cpp
View file @
d8ff1b14
...
...
@@ -30,12 +30,12 @@ using namespace std;
// =============================================================================
ContactModel
::
ContactModel
(
QObject
*
parent
,
shared_ptr
<
linphone
::
Friend
>
linphone
_f
riend
)
:
QObject
(
parent
)
{
m
_linphone_friend
=
linphone_f
riend
;
m
_vcard
=
make_shared
<
VcardModel
>
(
linphone_f
riend
->
getVcard
());
ContactModel
::
ContactModel
(
QObject
*
parent
,
shared_ptr
<
linphone
::
Friend
>
linphone
F
riend
)
:
QObject
(
parent
)
{
m
LinphoneFriend
=
linphoneF
riend
;
m
Vcard
=
make_shared
<
VcardModel
>
(
linphoneF
riend
->
getVcard
());
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
m
_v
card
.
get
(),
QQmlEngine
::
CppOwnership
);
m
_linphone_f
riend
->
setData
(
"contact-model"
,
*
this
);
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
m
V
card
.
get
(),
QQmlEngine
::
CppOwnership
);
m
LinphoneF
riend
->
setData
(
"contact-model"
,
*
this
);
}
ContactModel
::
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
)
:
QObject
(
parent
)
{
...
...
@@ -45,17 +45,17 @@ ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent
if
(
engine
->
objectOwnership
(
vcard
)
==
QQmlEngine
::
CppOwnership
)
throw
invalid_argument
(
"A contact is already linked to this vcard."
);
m
_linphone_friend
=
linphone
::
Friend
::
newFromVcard
(
vcard
->
m_v
card
);
m
_linphone_f
riend
->
setData
(
"contact-model"
,
*
this
);
m
LinphoneFriend
=
linphone
::
Friend
::
newFromVcard
(
vcard
->
mV
card
);
m
LinphoneF
riend
->
setData
(
"contact-model"
,
*
this
);
m
_v
card
.
reset
(
vcard
);
m
V
card
.
reset
(
vcard
);
engine
->
setObjectOwnership
(
vcard
,
QQmlEngine
::
CppOwnership
);
}
void
ContactModel
::
refreshPresence
()
{
Presence
::
PresenceStatus
status
=
static_cast
<
Presence
::
PresenceStatus
>
(
m
_linphone_f
riend
->
getConsolidatedPresence
()
m
LinphoneF
riend
->
getConsolidatedPresence
()
);
emit
presenceStatusChanged
(
status
);
...
...
@@ -63,41 +63,41 @@ void ContactModel::refreshPresence () {
}
void
ContactModel
::
startEdit
()
{
m
_linphone_f
riend
->
edit
();
m
_old_sip_addresses
=
m_v
card
->
getSipAddresses
();
m
LinphoneF
riend
->
edit
();
m
OldSipAddresses
=
mV
card
->
getSipAddresses
();
}
void
ContactModel
::
endEdit
()
{
m
_linphone_f
riend
->
done
();
m
LinphoneF
riend
->
done
();
QVariantList
sip
_addresses
=
m_v
card
->
getSipAddresses
();
QVariantList
sip
Addresses
=
mV
card
->
getSipAddresses
();
QSet
<
QString
>
done
;
for
(
const
auto
&
variant
_a
:
m_old_sip_a
ddresses
)
{
for
(
const
auto
&
variant
A
:
mOldSipA
ddresses
)
{
next:
const
QString
&
sip
_address
=
variant_a
.
toString
();
if
(
done
.
contains
(
sip
_a
ddress
))
const
QString
&
sip
Address
=
variantA
.
toString
();
if
(
done
.
contains
(
sip
A
ddress
))
continue
;
done
.
insert
(
sip
_a
ddress
);
done
.
insert
(
sip
A
ddress
);
// Check if old sip address exists in new set => No changes.
for
(
const
auto
&
variant
_b
:
sip_a
ddresses
)
{
if
(
sip
_address
==
variant_b
.
toString
())
for
(
const
auto
&
variant
B
:
sipA
ddresses
)
{
if
(
sip
Address
==
variantB
.
toString
())
goto
next
;
}
emit
sipAddressRemoved
(
sip
_a
ddress
);
emit
sipAddressRemoved
(
sip
A
ddress
);
}
m
_old_sip_a
ddresses
.
clear
();
m
OldSipA
ddresses
.
clear
();
for
(
const
auto
&
variant
:
sip
_a
ddresses
)
{
const
QString
&
sip
_a
ddress
=
variant
.
toString
();
if
(
done
.
contains
(
sip
_a
ddress
))
for
(
const
auto
&
variant
:
sip
A
ddresses
)
{
const
QString
&
sip
A
ddress
=
variant
.
toString
();
if
(
done
.
contains
(
sip
A
ddress
))
continue
;
done
.
insert
(
sip
_a
ddress
);
done
.
insert
(
sip
A
ddress
);
emit
sipAddressAdded
(
sip
_a
ddress
);
emit
sipAddressAdded
(
sip
A
ddress
);
}
emit
contactUpdated
();
...
...
@@ -105,14 +105,14 @@ next:
void
ContactModel
::
abortEdit
()
{
// TODO: call linphone friend abort function when available.
// m
_linphone_f
riend->abort();
m
_old_sip_a
ddresses
.
clear
();
// m
LinphoneF
riend->abort();
m
OldSipA
ddresses
.
clear
();
emit
contactUpdated
();
}
Presence
::
PresenceStatus
ContactModel
::
getPresenceStatus
()
const
{
return
static_cast
<
Presence
::
PresenceStatus
>
(
m
_linphone_f
riend
->
getConsolidatedPresence
());
return
static_cast
<
Presence
::
PresenceStatus
>
(
m
LinphoneF
riend
->
getConsolidatedPresence
());
}
Presence
::
PresenceLevel
ContactModel
::
getPresenceLevel
()
const
{
...
...
linphone-desktop/src/components/contact/ContactModel.hpp
View file @
d8ff1b14
...
...
@@ -40,12 +40,12 @@ class ContactModel : public QObject {
friend
class
SmartSearchBarModel
;
public:
ContactModel
(
QObject
*
parent
,
std
::
shared_ptr
<
linphone
::
Friend
>
linphone
_f
riend
);
ContactModel
(
QObject
*
parent
,
std
::
shared_ptr
<
linphone
::
Friend
>
linphone
F
riend
);
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
);
~
ContactModel
()
=
default
;
std
::
shared_ptr
<
VcardModel
>
getVcardModel
()
const
{
return
m
_v
card
;
return
m
V
card
;
}
void
refreshPresence
();
...
...
@@ -58,21 +58,21 @@ signals:
void
contactUpdated
();
void
presenceStatusChanged
(
Presence
::
PresenceStatus
status
);
void
presenceLevelChanged
(
Presence
::
PresenceLevel
level
);
void
sipAddressAdded
(
const
QString
&
sip
_a
ddress
);
void
sipAddressRemoved
(
const
QString
&
sip
_a
ddress
);
void
sipAddressAdded
(
const
QString
&
sip
A
ddress
);
void
sipAddressRemoved
(
const
QString
&
sip
A
ddress
);
private:
Presence
::
PresenceStatus
getPresenceStatus
()
const
;
Presence
::
PresenceLevel
getPresenceLevel
()
const
;
VcardModel
*
getVcardModelPtr
()
const
{
return
m
_v
card
.
get
();
return
m
V
card
.
get
();
}
QVariantList
m
_old_sip_a
ddresses
;
QVariantList
m
OldSipA
ddresses
;
std
::
shared_ptr
<
VcardModel
>
m
_v
card
;
std
::
shared_ptr
<
linphone
::
Friend
>
m
_linphone_f
riend
;
std
::
shared_ptr
<
VcardModel
>
m
V
card
;
std
::
shared_ptr
<
linphone
::
Friend
>
m
LinphoneF
riend
;
};
Q_DECLARE_METATYPE
(
ContactModel
*
);
...
...
linphone-desktop/src/components/contact/VcardModel.cpp
View file @
d8ff1b14
...
...
@@ -74,33 +74,33 @@ inline shared_ptr<belcard::BelCardPhoto> findBelCardPhoto (const list<shared_ptr
VcardModel
::~
VcardModel
()
{
// If it's a detached Vcard, the linked photo must be destroyed from fs.
if
(
App
::
getInstance
()
->
getEngine
()
->
objectOwnership
(
this
)
!=
QQmlEngine
::
CppOwnership
)
{
shared_ptr
<
belcard
::
BelCardPhoto
>
photo
(
findBelCardPhoto
(
m
_v
card
->
getVcard
()
->
getPhotos
()));
shared_ptr
<
belcard
::
BelCardPhoto
>
photo
(
findBelCardPhoto
(
m
V
card
->
getVcard
()
->
getPhotos
()));
if
(
!
photo
)
return
;
QString
image
_p
ath
(
QString
image
P
ath
(
::
Utils
::
linphoneStringToQString
(
Paths
::
getAvatarsDirpath
()
+
photo
->
getValue
().
substr
(
sizeof
(
VCARD_SCHEME
)
-
1
)
)
);
if
(
!
QFile
::
remove
(
image
_p
ath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
image
_p
ath
);
if
(
!
QFile
::
remove
(
image
P
ath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
image
P
ath
);
}
}
// -----------------------------------------------------------------------------
QString
VcardModel
::
getUsername
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m
_v
card
->
getFullName
());
return
::
Utils
::
linphoneStringToQString
(
m
V
card
->
getFullName
());
}
void
VcardModel
::
setUsername
(
const
QString
&
username
)
{
if
(
username
.
length
()
==
0
||
username
==
getUsername
())
return
;
m
_v
card
->
setFullName
(
::
Utils
::
qStringToLinphoneString
(
username
));
m
V
card
->
setFullName
(
::
Utils
::
qStringToLinphoneString
(
username
));
emit
vcardUpdated
();
}
...
...
@@ -108,7 +108,7 @@ void VcardModel::setUsername (const QString &username) {
QString
VcardModel
::
getAvatar
()
const
{
// Find desktop avatar.
list
<
shared_ptr
<
belcard
::
BelCardPhoto
>
>
photos
=
m
_v
card
->
getVcard
()
->
getPhotos
();
list
<
shared_ptr
<
belcard
::
BelCardPhoto
>
>
photos
=
m
V
card
->
getVcard
()
->
getPhotos
();
shared_ptr
<
belcard
::
BelCardPhoto
>
photo
=
findBelCardPhoto
(
photos
);
// No path found.
...
...
@@ -130,11 +130,11 @@ bool VcardModel::setAvatar (const QString &path) {
QFileInfo
info
(
file
);
QString
uuid
=
QUuid
::
createUuid
().
toString
();
QString
file
_i
d
=
QStringLiteral
(
"%1.%2"
)
QString
file
I
d
=
QStringLiteral
(
"%1.%2"
)
.
arg
(
uuid
.
mid
(
1
,
uuid
.
length
()
-
2
))
// Remove `{}`.
.
arg
(
info
.
suffix
());
QString
dest
=
::
Utils
::
linphoneStringToQString
(
Paths
::
getAvatarsDirpath
())
+
file
_i
d
;
QString
dest
=
::
Utils
::
linphoneStringToQString
(
Paths
::
getAvatarsDirpath
())
+
file
I
d
;
if
(
!
file
.
copy
(
dest
))
return
false
;
...
...
@@ -142,26 +142,26 @@ bool VcardModel::setAvatar (const QString &path) {
qInfo
()
<<
QStringLiteral
(
"Update avatar of `%1`. (path=%2)"
).
arg
(
getUsername
()).
arg
(
dest
);
// 2. Edit vcard.
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
list
<
shared_ptr
<
belcard
::
BelCardPhoto
>
>
photos
=
belcard
->
getPhotos
();
// 3. Remove oldest photo.
shared_ptr
<
belcard
::
BelCardPhoto
>
old
_p
hoto
=
findBelCardPhoto
(
photos
);
if
(
old
_p
hoto
)
{
QString
image
_p
ath
(
shared_ptr
<
belcard
::
BelCardPhoto
>
old
P
hoto
=
findBelCardPhoto
(
photos
);
if
(
old
P
hoto
)
{
QString
image
P
ath
(
::
Utils
::
linphoneStringToQString
(
Paths
::
getAvatarsDirpath
()
+
old
_p
hoto
->
getValue
().
substr
(
sizeof
(
VCARD_SCHEME
)
-
1
)
Paths
::
getAvatarsDirpath
()
+
old
P
hoto
->
getValue
().
substr
(
sizeof
(
VCARD_SCHEME
)
-
1
)
)
);
if
(
!
QFile
::
remove
(
image
_p
ath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
image
_p
ath
);
belcard
->
removePhoto
(
old
_p
hoto
);
if
(
!
QFile
::
remove
(
image
P
ath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
image
P
ath
);
belcard
->
removePhoto
(
old
P
hoto
);
}
// 4. Update.
shared_ptr
<
belcard
::
BelCardPhoto
>
photo
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardPhoto
>
();
photo
->
setValue
(
VCARD_SCHEME
+
::
Utils
::
qStringToLinphoneString
(
file
_i
d
));
photo
->
setValue
(
VCARD_SCHEME
+
::
Utils
::
qStringToLinphoneString
(
file
I
d
));
if
(
!
belcard
->
addPhoto
(
photo
))
return
false
;
...
...
@@ -187,7 +187,7 @@ inline shared_ptr<belcard::BelCardAddress> getOrCreateBelCardAddress (shared_ptr
}
QVariantMap
VcardModel
::
getAddress
()
const
{
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
m
_v
card
->
getVcard
()
->
getAddresses
();
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
m
V
card
->
getVcard
()
->
getAddresses
();
QVariantMap
map
;
if
(
addresses
.
empty
())
...
...
@@ -203,25 +203,25 @@ QVariantMap VcardModel::getAddress () const {
}
void
VcardModel
::
setStreet
(
const
QString
&
street
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
_v
card
->
getVcard
());
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
V
card
->
getVcard
());
address
->
setStreet
(
::
Utils
::
qStringToLinphoneString
(
street
));
emit
vcardUpdated
();
}
void
VcardModel
::
setLocality
(
const
QString
&
locality
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
_v
card
->
getVcard
());
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
V
card
->
getVcard
());
address
->
setLocality
(
::
Utils
::
qStringToLinphoneString
(
locality
));
emit
vcardUpdated
();
}
void
VcardModel
::
setPostalCode
(
const
QString
&
postal
_c
ode
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
_v
card
->
getVcard
());
address
->
setPostalCode
(
::
Utils
::
qStringToLinphoneString
(
postal
_c
ode
));
void
VcardModel
::
setPostalCode
(
const
QString
&
postal
C
ode
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
V
card
->
getVcard
());
address
->
setPostalCode
(
::
Utils
::
qStringToLinphoneString
(
postal
C
ode
));
emit
vcardUpdated
();
}
void
VcardModel
::
setCountry
(
const
QString
&
country
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
_v
card
->
getVcard
());
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m
V
card
->
getVcard
());
address
->
setCountry
(
::
Utils
::
qStringToLinphoneString
(
country
));
emit
vcardUpdated
();
}
...
...
@@ -232,37 +232,37 @@ QVariantList VcardModel::getSipAddresses () const {
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
QVariantList
list
;
for
(
const
auto
&
address
:
m
_v
card
->
getVcard
()
->
getImpp
())
{
for
(
const
auto
&
address
:
m
V
card
->
getVcard
()
->
getImpp
())
{
string
value
=
address
->
getValue
();
shared_ptr
<
linphone
::
Address
>
l
_a
ddress
=
core
->
createAddress
(
value
);
shared_ptr
<
linphone
::
Address
>
l
inphoneA
ddress
=
core
->
createAddress
(
value
);
if
(
l
_a
ddress
)
list
.
append
(
::
Utils
::
linphoneStringToQString
(
l
_a
ddress
->
asStringUriOnly
()));
if
(
l
inphoneA
ddress
)
list
.
append
(
::
Utils
::
linphoneStringToQString
(
l
inphoneA
ddress
->
asStringUriOnly
()));
}
return
list
;
}
bool
VcardModel
::
addSipAddress
(
const
QString
&
sip
_a
ddress
)
{
bool
VcardModel
::
addSipAddress
(
const
QString
&
sip
A
ddress
)
{
// Check sip address format.
shared_ptr
<
linphone
::
Address
>
l
_a
ddress
=
CoreManager
::
getInstance
()
->
getCore
()
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
_a
ddress
)
shared_ptr
<
linphone
::
Address
>
l
inphoneA
ddress
=
CoreManager
::
getInstance
()
->
getCore
()
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
A
ddress
)
);
if
(
!
l
_a
ddress
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to add invalid sip address on vcard: `%1`."
).
arg
(
sip
_a
ddress
);
if
(
!
l
inphoneA
ddress
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to add invalid sip address on vcard: `%1`."
).
arg
(
sip
A
ddress
);
return
false
;
}
// Add sip address in belcard.
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardImpp
>
();
value
->
setValue
(
l
_a
ddress
->
asStringUriOnly
());
value
->
setValue
(
l
inphoneA
ddress
->
asStringUriOnly
());
qInfo
()
<<
QStringLiteral
(
"Add new sip address on vcard: `%1`."
).
arg
(
sip
_a
ddress
);
qInfo
()
<<
QStringLiteral
(
"Add new sip address on vcard: `%1`."
).
arg
(
sip
A
ddress
);
if
(
!
belcard
->
addImpp
(
value
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add sip address on vcard: `%1`."
).
arg
(
sip
_a
ddress
);
qWarning
()
<<
QStringLiteral
(
"Unable to add sip address on vcard: `%1`."
).
arg
(
sip
A
ddress
);
return
false
;
}
...
...
@@ -270,33 +270,33 @@ bool VcardModel::addSipAddress (const QString &sip_address) {
return
true
;
}
void
VcardModel
::
removeSipAddress
(
const
QString
&
sip
_a
ddress
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
void
VcardModel
::
removeSipAddress
(
const
QString
&
sip
A
ddress
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
list
<
shared_ptr
<
belcard
::
BelCardImpp
>
>
addresses
=
belcard
->
getImpp
();
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
findBelCardValue
(
addresses
,
sip
_a
ddress
);
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
findBelCardValue
(
addresses
,
sip
A
ddress
);
if
(
!
value
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to remove sip address on vcard: `%1`."
).
arg
(
sip
_a
ddress
);
qWarning
()
<<
QStringLiteral
(
"Unable to remove sip address on vcard: `%1`."
).
arg
(
sip
A
ddress
);
return
;
}
if
(
addresses
.
size
()
==
1
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to remove the only existing sip address on vcard: `%1`."
)
.
arg
(
sip
_a
ddress
);
.
arg
(
sip
A
ddress
);
return
;
}
qInfo
()
<<
QStringLiteral
(
"Remove sip address on vcard: `%1`."
).
arg
(
sip
_a
ddress
);
qInfo
()
<<
QStringLiteral
(
"Remove sip address on vcard: `%1`."
).
arg
(
sip
A
ddress
);
belcard
->
removeImpp
(
value
);
emit
vcardUpdated
();
}
bool
VcardModel
::
updateSipAddress
(
const
QString
&
old
_sip_address
,
const
QString
&
sip_a
ddress
)
{
if
(
old
_sip_address
==
sip_address
||
!
addSipAddress
(
sip_a
ddress
))
bool
VcardModel
::
updateSipAddress
(
const
QString
&
old
SipAddress
,
const
QString
&
sipA
ddress
)
{
if
(
old
SipAddress
==
sipAddress
||
!
addSipAddress
(
sipA
ddress
))
return
false
;
removeSipAddress
(
old
_sip_a
ddress
);
removeSipAddress
(
old
SipA
ddress
);
return
true
;
}
...
...
@@ -306,14 +306,14 @@ bool VcardModel::updateSipAddress (const QString &old_sip_address, const QString
QVariantList
VcardModel
::
getCompanies
()
const
{
QVariantList
list
;
for
(
const
auto
&
company
:
m
_v
card
->
getVcard
()
->
getRoles
())
for
(
const
auto
&
company
:
m
V
card
->
getVcard
()
->
getRoles
())
list
.
append
(
::
Utils
::
linphoneStringToQString
(
company
->
getValue
()));
return
list
;
}
bool
VcardModel
::
addCompany
(
const
QString
&
company
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardRole
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardRole
>
();
value
->
setValue
(
::
Utils
::
qStringToLinphoneString
(
company
));
...
...
@@ -329,7 +329,7 @@ bool VcardModel::addCompany (const QString &company) {
}
void
VcardModel
::
removeCompany
(
const
QString
&
company
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardRole
>
value
=
findBelCardValue
(
belcard
->
getRoles
(),
company
);
if
(
!
value
)
{
...
...
@@ -343,11 +343,11 @@ void VcardModel::removeCompany (const QString &company) {
emit
vcardUpdated
();
}
bool
VcardModel
::
updateCompany
(
const
QString
&
old
_c
ompany
,
const
QString
&
company
)
{
if
(
old
_c
ompany
==
company
||
!
addCompany
(
company
))
bool
VcardModel
::
updateCompany
(
const
QString
&
old
C
ompany
,
const
QString
&
company
)
{
if
(
old
C
ompany
==
company
||
!
addCompany
(
company
))
return
false
;
removeCompany
(
old
_c
ompany
);
removeCompany
(
old
C
ompany
);
return
true
;
}
...
...
@@ -357,14 +357,14 @@ bool VcardModel::updateCompany (const QString &old_company, const QString &compa
QVariantList
VcardModel
::
getEmails
()
const
{
QVariantList
list
;
for
(
const
auto
&
email
:
m
_v
card
->
getVcard
()
->
getEmails
())
for
(
const
auto
&
email
:
m
V
card
->
getVcard
()
->
getEmails
())
list
.
append
(
::
Utils
::
linphoneStringToQString
(
email
->
getValue
()));
return
list
;
}
bool
VcardModel
::
addEmail
(
const
QString
&
email
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardEmail
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardEmail
>
();
value
->
setValue
(
::
Utils
::
qStringToLinphoneString
(
email
));
...
...
@@ -380,7 +380,7 @@ bool VcardModel::addEmail (const QString &email) {
}
void
VcardModel
::
removeEmail
(
const
QString
&
email
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardEmail
>
value
=
findBelCardValue
(
belcard
->
getEmails
(),
email
);
if
(
!
value
)
{
...
...
@@ -394,11 +394,11 @@ void VcardModel::removeEmail (const QString &email) {
emit
vcardUpdated
();
}
bool
VcardModel
::
updateEmail
(
const
QString
&
old
_e
mail
,
const
QString
&
email
)
{
if
(
old
_e
mail
==
email
||
!
addEmail
(
email
))
bool
VcardModel
::
updateEmail
(
const
QString
&
old
E
mail
,
const
QString
&
email
)
{
if
(
old
E
mail
==
email
||
!
addEmail
(
email
))
return
false
;
removeEmail
(
old
_e
mail
);
removeEmail
(
old
E
mail
);
return
true
;
}
...
...
@@ -408,14 +408,14 @@ bool VcardModel::updateEmail (const QString &old_email, const QString &email) {
QVariantList
VcardModel
::
getUrls
()
const
{
QVariantList
list
;
for
(
const
auto
&
url
:
m
_v
card
->
getVcard
()
->
getURLs
())
for
(
const
auto
&
url
:
m
V
card
->
getVcard
()
->
getURLs
())
list
.
append
(
::
Utils
::
linphoneStringToQString
(
url
->
getValue
()));
return
list
;
}
bool
VcardModel
::
addUrl
(
const
QString
&
url
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardURL
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardURL
>
();
value
->
setValue
(
::
Utils
::
qStringToLinphoneString
(
url
));
...
...
@@ -431,7 +431,7 @@ bool VcardModel::addUrl (const QString &url) {
}
void
VcardModel
::
removeUrl
(
const
QString
&
url
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
_v
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m
V
card
->
getVcard
();
shared_ptr
<
belcard
::
BelCardURL
>
value
=
findBelCardValue
(
belcard
->
getURLs
(),
url
);
if
(
!
value
)
{
...
...
@@ -445,11 +445,11 @@ void VcardModel::removeUrl (const QString &url) {
emit
vcardUpdated
();
}
bool
VcardModel
::
updateUrl
(
const
QString
&
old
_u
rl
,
const
QString
&
url
)
{
if
(
old
_u
rl
==
url
||
!
addUrl
(
url
))
bool
VcardModel
::
updateUrl
(
const
QString
&
old
U
rl
,
const
QString
&
url
)
{
if
(
old
U
rl
==
url
||
!
addUrl
(
url
))
return
false
;
removeUrl
(
old
_u
rl
);
removeUrl
(
old
U
rl
);
return
true
;
}
linphone-desktop/src/components/contact/VcardModel.hpp
View file @
d8ff1b14
...
...
@@ -42,32 +42,32 @@ class VcardModel : public QObject {
friend
class
ContactModel
;
public:
VcardModel
(
std
::
shared_ptr
<
linphone
::
Vcard
>
vcard
)
:
m
_v
card
(
vcard
)
{}
VcardModel
(
std
::
shared_ptr
<
linphone
::
Vcard
>
vcard
)
:
m
V
card
(
vcard
)
{}
~
VcardModel
();
QString
getUsername
()
const
;
QVariantList
getSipAddresses
()
const
;
Q_INVOKABLE
bool
addSipAddress
(
const
QString
&
sip
_a
ddress
);
Q_INVOKABLE
void
removeSipAddress
(
const
QString
&
sip
_a
ddress
);
Q_INVOKABLE
bool
updateSipAddress
(
const
QString
&
old
_sip_address
,
const
QString
&
sip_a
ddress
);
Q_INVOKABLE
bool
addSipAddress
(
const
QString
&
sip
A
ddress
);
Q_INVOKABLE
void
removeSipAddress
(
const
QString
&
sip
A
ddress
);
Q_INVOKABLE
bool
updateSipAddress
(
const
QString
&
old
SipAddress
,
const
QString
&
sipA
ddress
);
Q_INVOKABLE
bool
addCompany
(
const
QString
&
company
);
Q_INVOKABLE
void
removeCompany
(
const
QString
&
company
);
Q_INVOKABLE
bool
updateCompany
(
const
QString
&
old
_c
ompany
,
const
QString
&
company
);
Q_INVOKABLE
bool
updateCompany
(
const
QString
&
old
C
ompany
,
const
QString
&
company
);
Q_INVOKABLE
bool
addEmail
(
const
QString
&
email
);
Q_INVOKABLE
void
removeEmail
(
const
QString
&
email
);
Q_INVOKABLE
bool
updateEmail
(
const
QString
&
old
_e
mail
,
const
QString
&
email
);
Q_INVOKABLE
bool
updateEmail
(
const
QString
&
old
E
mail
,
const
QString
&
email
);
Q_INVOKABLE
bool
addUrl
(
const
QString
&
url
);
Q_INVOKABLE
void
removeUrl
(
const
QString
&
url
);
Q_INVOKABLE
bool
updateUrl
(
const
QString
&
old
_u
rl
,
const
QString
&
url
);
Q_INVOKABLE
bool
updateUrl
(
const
QString
&
old
U
rl
,
const
QString
&
url
);
Q_INVOKABLE
void
setStreet
(
const
QString
&
street
);
Q_INVOKABLE
void
setLocality
(
const
QString
&
locality
);
Q_INVOKABLE
void
setPostalCode
(
const
QString
&
postal
_c
ode
);
Q_INVOKABLE
void
setPostalCode
(
const
QString
&
postal
C
ode
);
Q_INVOKABLE
void
setCountry
(
const
QString
&
country
);
signals:
...
...
@@ -84,7 +84,7 @@ private:
QVariantList
getEmails
()
const
;
QVariantList
getUrls
()
const
;
std
::
shared_ptr
<
linphone
::
Vcard
>
m
_v
card
;
std
::
shared_ptr
<
linphone
::
Vcard
>
m
V
card
;
};
Q_DECLARE_METATYPE
(
VcardModel
*
);
...
...
linphone-desktop/src/components/contacts/ContactsListModel.cpp
View file @
d8ff1b14
...
...
@@ -33,11 +33,11 @@ using namespace std;
// =============================================================================
ContactsListModel
::
ContactsListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
m
_linphone_f
riends
=
CoreManager
::
getInstance
()
->
getCore
()
->
getFriendsLists
().
front
();
m
LinphoneF
riends
=
CoreManager
::
getInstance
()
->
getCore
()
->
getFriendsLists
().
front
();
// Init contacts with linphone friends list.
for
(
const
auto
&
friend_
:
m_linphone_f
riends
->
getFriends
())
{
ContactModel
*
contact
=
new
ContactModel
(
this
,
friend_
);
for
(
const
auto
&
_friend
:
mLinphoneF
riends
->
getFriends
())
{
ContactModel
*
contact
=
new
ContactModel
(
this
,
_friend
);
// See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
// The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
...
...
@@ -48,7 +48,7 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare
}
int
ContactsListModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m
_l
ist
.
count
();
return
m
L
ist
.
count
();
}
QHash
<
int
,
QByteArray
>
ContactsListModel
::
roleNames
()
const
{
...
...
@@ -60,11 +60,11 @@ QHash<int, QByteArray> ContactsListModel::roleNames () const {
QVariant
ContactsListModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
_l
ist
.
count
())
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
L
ist
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
QVariant
::
fromValue
(
m
_l
ist
[
row
]);
return
QVariant
::
fromValue
(
m
L
ist
[
row
]);
return
QVariant
();
}
...
...
@@ -76,15 +76,15 @@ bool ContactsListModel::removeRow (int row, const QModelIndex &parent) {
bool
ContactsListModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
{
int
limit
=
row
+
count
-
1
;
if
(
row
<
0
||
count
<
0
||
limit
>=
m
_l
ist
.
count
())
if
(
row
<
0
||
count
<
0
||
limit
>=
m
L
ist
.
count
())
return
false
;
beginRemoveRows
(
parent
,
row
,
limit
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
ContactModel
*
contact
=
m
_l
ist
.
takeAt
(
row
);
ContactModel
*
contact
=
m
L
ist
.
takeAt
(
row
);
m
_linphone_friends
->
removeFriend
(
contact
->
m_linphone_f
riend
);
m
LinphoneFriends
->
removeFriend
(
contact
->
mLinphoneF
riend
);
emit
contactRemoved
(
contact
);
contact
->
deleteLater
();
...
...
@@ -104,7 +104,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
qInfo
()
<<
"Add contact:"
<<
contact
;
if
(
m
_linphone_friends
->
addFriend
(
contact
->
m_linphone_f
riend
)
!=
m
LinphoneFriends
->
addFriend
(
contact
->
mLinphoneF
riend
)
!=
linphone
::
FriendListStatus
::
FriendListStatusOK
)
{
qWarning
()
<<
"Unable to add friend from vcard:"
<<
vcard
;
...
...
@@ -112,7 +112,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
return
nullptr
;
}
int
row
=
m
_l
ist
.
count
();
int
row
=
m
L
ist
.
count
();
beginInsertRows
(
QModelIndex
(),
row
,
row
);
addContact
(
contact
);
...
...
@@ -126,7 +126,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
void
ContactsListModel
::
removeContact
(
ContactModel
*
contact
)
{
qInfo
()
<<
"Removing contact:"
<<
contact
;
int
index
=
m
_l
ist
.
indexOf
(
contact
);
int
index
=
m
L
ist
.
indexOf
(
contact
);
if
(
index
==
-
1
||
!
removeRow
(
index
))
qWarning
()
<<
"Unable to remove contact:"
<<
contact
;
}
...
...
@@ -141,15 +141,15 @@ void ContactsListModel::addContact (ContactModel *contact) {
}
);
QObject
::
connect
(
contact
,
&
ContactModel
::
sipAddressAdded
,
this
,
[
this
,
contact
](
const
QString
&
sip
_a
ddress
)
{
emit
sipAddressAdded
(
contact
,
sip
_a
ddress
);
contact
,
&
ContactModel
::
sipAddressAdded
,
this
,
[
this
,
contact
](
const
QString
&
sip
A
ddress
)
{
emit
sipAddressAdded
(
contact
,
sip
A
ddress
);
}
);
QObject
::
connect
(
contact
,
&
ContactModel
::
sipAddressRemoved
,
this
,
[
this
,
contact
](
const
QString
&
sip
_a
ddress
)
{
emit
sipAddressRemoved
(
contact
,
sip
_a
ddress
);
contact
,
&
ContactModel
::
sipAddressRemoved
,
this
,
[
this
,
contact
](
const
QString
&
sip
A
ddress
)
{
emit
sipAddressRemoved
(
contact
,
sip
A
ddress
);
}
);
m
_l
ist
<<
contact
;
m
L
ist
<<
contact
;
}
linphone-desktop/src/components/contacts/ContactsListModel.hpp
View file @
d8ff1b14
...
...
@@ -56,14 +56,14 @@ signals:
void
contactRemoved
(
const
ContactModel
*
contact
);
void
contactUpdated
(
ContactModel
*
contact
);
void
sipAddressAdded
(
ContactModel
*
contact
,
const
QString
&
sip
_a
ddress
);
void
sipAddressRemoved
(
ContactModel
*
contact
,
const
QString
&
sip
_a
ddress
);
void
sipAddressAdded
(
ContactModel
*
contact
,
const
QString
&
sip
A
ddress
);
void
sipAddressRemoved
(
ContactModel
*
contact
,
const
QString
&
sip
A
ddress
);
private:
void
addContact
(
ContactModel
*
contact
);
QList
<
ContactModel
*>
m
_l
ist
;
std
::
shared_ptr
<
linphone
::
FriendList
>
m
_linphone_f
riends
;
QList
<
ContactModel
*>
m
L
ist
;
std
::
shared_ptr
<
linphone
::
FriendList
>
m
LinphoneF
riends
;
};
#endif // CONTACTS_LIST_MODEL_H_
linphone-desktop/src/components/contacts/ContactsListProxyModel.cpp
View file @
d8ff1b14
...
...
@@ -51,7 +51,7 @@ using namespace std;
// a separator like ` word`.
//
// - [_.-;@ ] is the main pattern (a separator).
const
QRegExp
ContactsListProxyModel
::
m
_search_s
eparators
(
"^[^_.-;@ ][_.-;@ ]"
);
const
QRegExp
ContactsListProxyModel
::
m
SearchS
eparators
(
"^[^_.-;@ ][_.-;@ ]"
);
// -----------------------------------------------------------------------------
...
...
@@ -63,38 +63,38 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr
// -----------------------------------------------------------------------------
void
ContactsListProxyModel
::
setFilter
(
const
QString
&
pattern
)
{
m
_f
ilter
=
pattern
;
m
F
ilter
=
pattern
;
invalidate
();
}
// -----------------------------------------------------------------------------
bool
ContactsListProxyModel
::
filterAcceptsRow
(
int
source
_r
ow
,
const
QModelIndex
&
source
_p
arent
int
source
R
ow
,
const
QModelIndex
&
source
P
arent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source
_row
,
0
,
source_p
arent
);
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source
Row
,
0
,
sourceP
arent
);
const
ContactModel
*
contact
=
index
.
data
().
value
<
ContactModel
*>
();
m
_w
eights
[
contact
]
=
static_cast
<
unsigned
int
>
(
round
(
computeContactWeight
(
contact
)));
m
W
eights
[
contact
]
=
static_cast
<
unsigned
int
>
(
round
(
computeContactWeight
(
contact
)));
return
m
_w
eights
[
contact
]
>
0
&&
(
!
m
_use_connected_f
ilter
||
return
m
W
eights
[
contact
]
>
0
&&
(
!
m
UseConnectedF
ilter
||
contact
->
getPresenceLevel
()
!=
Presence
::
PresenceLevel
::
White
);
}
bool
ContactsListProxyModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
const
ContactModel
*
contact
_a
=
sourceModel
()
->
data
(
left
).
value
<
ContactModel
*>
();
const
ContactModel
*
contact
_b
=
sourceModel
()
->
data
(
right
).
value
<
ContactModel
*>
();
const
ContactModel
*
contact
A
=
sourceModel
()
->
data
(
left
).
value
<
ContactModel
*>
();
const
ContactModel
*
contact
B
=
sourceModel
()
->
data
(
right
).
value
<
ContactModel
*>
();
unsigned
int
weight
_a
=
m_weights
[
contact_a
];
unsigned
int
weight
_b
=
m_weights
[
contact_b
];
unsigned
int
weight
A
=
mWeights
[
contactA
];
unsigned
int
weight
B
=
mWeights
[
contactB
];
// Sort by weight and name.
return
weight
_a
>
weight_b
||
(
weight
_a
==
weight_b
&&
contact
_a
->
m_linphone_friend
->
getName
()
<=
contact_b
->
m_linphone_f
riend
->
getName
()
return
weight
A
>
weightB
||
(
weight
A
==
weightB
&&
contact
A
->
mLinphoneFriend
->
getName
()
<=
contactB
->
mLinphoneF
riend
->
getName
()
);
}
...
...
@@ -105,12 +105,12 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float
int
offset
=
-
1
;
// Search pattern.
while
((
index
=
string
.
indexOf
(
m
_f
ilter
,
index
+
1
,
Qt
::
CaseInsensitive
))
!=
-
1
)
{
while
((
index
=
string
.
indexOf
(
m
F
ilter
,
index
+
1
,
Qt
::
CaseInsensitive
))
!=
-
1
)
{
// Search n chars between one separator and index.
int
tmp
_offset
=
index
-
string
.
lastIndexOf
(
m_search_s
eparators
,
index
)
-
1
;
int
tmp
Offset
=
index
-
string
.
lastIndexOf
(
mSearchS
eparators
,
index
)
-
1
;
if
((
tmp
_offset
!=
-
1
&&
tmp_o
ffset
<
offset
)
||
offset
==
-
1
)
if
((
offset
=
tmp
_o
ffset
)
==
0
)
break
;
if
((
tmp
Offset
!=
-
1
&&
tmpO
ffset
<
offset
)
||
offset
==
-
1
)
if
((
offset
=
tmp
O
ffset
)
==
0
)
break
;
}
switch
(
offset
)
{
...
...
@@ -129,7 +129,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact)
float
weight
=
computeStringWeight
(
contact
->
getVcardModel
()
->
getUsername
(),
USERNAME_WEIGHT
);
// Get all contact's addresses.
const
list
<
shared_ptr
<
linphone
::
Address
>
>
addresses
=
contact
->
m
_linphone_f
riend
->
getAddresses
();
const
list
<
shared_ptr
<
linphone
::
Address
>
>
addresses
=
contact
->
m
LinphoneF
riend
->
getAddresses
();
float
size
=
static_cast
<
float
>
(
addresses
.
size
());
for
(
auto
it
=
addresses
.
cbegin
();
it
!=
addresses
.
cend
();
++
it
)
...
...
@@ -143,9 +143,9 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact)
// -----------------------------------------------------------------------------
void
ContactsListProxyModel
::
setConnectedFilter
(
bool
use
_connected_f
ilter
)
{
if
(
use
_connected_filter
!=
m_use_connected_f
ilter
)
{
m
_use_connected_filter
=
use_connected_f
ilter
;
void
ContactsListProxyModel
::
setConnectedFilter
(
bool
use
ConnectedF
ilter
)
{
if
(
use
ConnectedFilter
!=
mUseConnectedF
ilter
)
{
m
UseConnectedFilter
=
useConnectedF
ilter
;
invalidate
();
}
}
linphone-desktop/src/components/contacts/ContactsListProxyModel.hpp
View file @
d8ff1b14
...
...
@@ -46,7 +46,7 @@ public:
Q_INVOKABLE
void
setFilter
(
const
QString
&
pattern
);
protected:
bool
filterAcceptsRow
(
int
source
_row
,
const
QModelIndex
&
source_p
arent
)
const
override
;
bool
filterAcceptsRow
(
int
source
Row
,
const
QModelIndex
&
sourceP
arent
)
const
override
;
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
override
;
private:
...
...
@@ -54,19 +54,19 @@ private:
float
computeContactWeight
(
const
ContactModel
*
contact
)
const
;
bool
isConnectedFilterUsed
()
const
{
return
m
_use_connected_f
ilter
;
return
m
UseConnectedF
ilter
;
}
void
setConnectedFilter
(
bool
use
_connected_f
ilter
);
void
setConnectedFilter
(
bool
use
ConnectedF
ilter
);
QString
m
_f
ilter
;
bool
m
_use_connected_f
ilter
=
false
;
QString
m
F
ilter
;
bool
m
UseConnectedF
ilter
=
false
;
// It's just a cache to save values computed by `filterAcceptsRow`
// and reused by `lessThan`.
mutable
QHash
<
const
ContactModel
*
,
unsigned
int
>
m
_w
eights
;
mutable
QHash
<
const
ContactModel
*
,
unsigned
int
>
m
W
eights
;
static
const
QRegExp
m
_search_s
eparators
;
static
const
QRegExp
m
SearchS
eparators
;
};
#endif // CONTACTS_LIST_PROXY_MODEL_H_
linphone-desktop/src/components/core/CoreHandlers.cpp
View file @
d8ff1b14
...
...
@@ -34,10 +34,10 @@ using namespace std;
void
CoreHandlers
::
onAuthenticationRequested
(
const
shared_ptr
<
linphone
::
Core
>
&
,
const
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
_i
nfo
,
const
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
I
nfo
,
linphone
::
AuthMethod
)
{
emit
authenticationRequested
(
auth
_i
nfo
);
emit
authenticationRequested
(
auth
I
nfo
);
}
void
CoreHandlers
::
onCallStateChanged
(
...
...
@@ -57,9 +57,9 @@ void CoreHandlers::onMessageReceived (
const
shared_ptr
<
linphone
::
ChatRoom
>
&
,
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
const
string
content
_t
ype
=
message
->
getContentType
();
const
string
content
T
ype
=
message
->
getContentType
();
if
(
content
_type
==
"text/plain"
||
content_t
ype
==
"application/vnd.gsma.rcs-ft-http+xml"
)
{
if
(
content
Type
==
"text/plain"
||
contentT
ype
==
"application/vnd.gsma.rcs-ft-http+xml"
)
{
emit
messageReceived
(
message
);
const
App
*
app
=
App
::
getInstance
();
...
...
@@ -71,24 +71,24 @@ void CoreHandlers::onMessageReceived (
void
CoreHandlers
::
onNotifyPresenceReceivedForUriOrTel
(
const
shared_ptr
<
linphone
::
Core
>
&
,
const
shared_ptr
<
linphone
::
Friend
>
&
,
const
string
&
uri
_or_t
el
,
const
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence
_m
odel
const
string
&
uri
OrT
el
,
const
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence
M
odel
)
{
emit
presenceReceived
(
::
Utils
::
linphoneStringToQString
(
uri
_or_tel
),
presence_m
odel
);
emit
presenceReceived
(
::
Utils
::
linphoneStringToQString
(
uri
OrTel
),
presenceM
odel
);
}
void
CoreHandlers
::
onNotifyPresenceReceived
(
const
shared_ptr
<
linphone
::
Core
>
&
,
const
shared_ptr
<
linphone
::
Friend
>
&
linphone
_f
riend
const
shared_ptr
<
linphone
::
Friend
>
&
linphone
F
riend
)
{
linphone
_f
riend
->
getData
<
ContactModel
>
(
"contact-model"
).
refreshPresence
();
linphone
F
riend
->
getData
<
ContactModel
>
(
"contact-model"
).
refreshPresence
();
}
void
CoreHandlers
::
onRegistrationStateChanged
(
const
shared_ptr
<
linphone
::
Core
>
&
,
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
,
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
,
linphone
::
RegistrationState
state
,
const
string
&
)
{
emit
registrationStateChanged
(
proxy
_c
onfig
,
state
);
emit
registrationStateChanged
(
proxy
C
onfig
,
state
);
}
linphone-desktop/src/components/core/CoreHandlers.hpp
View file @
d8ff1b14
...
...
@@ -34,16 +34,16 @@ class CoreHandlers :
Q_OBJECT
;
signals:
void
authenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
_i
nfo
);
void
authenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
I
nfo
);
void
callStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
);
void
messageReceived
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
presenceReceived
(
const
QString
&
sip
_address
,
const
std
::
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence_m
odel
);
void
registrationStateChanged
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
,
linphone
::
RegistrationState
state
);
void
presenceReceived
(
const
QString
&
sip
Address
,
const
std
::
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presenceM
odel
);
void
registrationStateChanged
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
,
linphone
::
RegistrationState
state
);
private:
void
onAuthenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
_i
nfo
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
I
nfo
,
linphone
::
AuthMethod
method
)
override
;
...
...
@@ -62,19 +62,19 @@ private:
void
onNotifyPresenceReceivedForUriOrTel
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
Friend
>
&
linphone
_f
riend
,
const
std
::
string
&
uri
_or_t
el
,
const
std
::
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence
_m
odel
const
std
::
shared_ptr
<
linphone
::
Friend
>
&
linphone
F
riend
,
const
std
::
string
&
uri
OrT
el
,
const
std
::
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence
M
odel
)
override
;
void
onNotifyPresenceReceived
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
Friend
>
&
linphone
_f
riend
const
std
::
shared_ptr
<
linphone
::
Friend
>
&
linphone
F
riend
)
override
;
void
onRegistrationStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
,
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
,
linphone
::
RegistrationState
state
,
const
std
::
string
&
message
)
override
;
...
...
linphone-desktop/src/components/core/CoreManager.cpp
View file @
d8ff1b14
...
...
@@ -34,42 +34,42 @@ using namespace std;
// =============================================================================
CoreManager
*
CoreManager
::
m
_i
nstance
=
nullptr
;
CoreManager
*
CoreManager
::
m
I
nstance
=
nullptr
;
CoreManager
::
CoreManager
(
QObject
*
parent
,
const
QString
&
config
_path
)
:
QObject
(
parent
),
m_h
andlers
(
make_shared
<
CoreHandlers
>
())
{
m
_promise_build
=
QtConcurrent
::
run
(
this
,
&
CoreManager
::
createLinphoneCore
,
config_p
ath
);
CoreManager
::
CoreManager
(
QObject
*
parent
,
const
QString
&
config
Path
)
:
QObject
(
parent
),
mH
andlers
(
make_shared
<
CoreHandlers
>
())
{
m
PromiseBuild
=
QtConcurrent
::
run
(
this
,
&
CoreManager
::
createLinphoneCore
,
configP
ath
);
QObject
::
connect
(
&
m
_promise_w
atcher
,
&
QFutureWatcher
<
void
>::
finished
,
this
,
[]()
{
m
_instance
->
m_calls_list_model
=
new
CallsListModel
(
m_i
nstance
);
m
_instance
->
m_contacts_list_model
=
new
ContactsListModel
(
m_i
nstance
);
m
_instance
->
m_sip_addresses_model
=
new
SipAddressesModel
(
m_i
nstance
);
m
_instance
->
m_settings_model
=
new
SettingsModel
(
m_i
nstance
);
m
_instance
->
m_account_settings_model
=
new
AccountSettingsModel
(
m_i
nstance
);
emit
m
_i
nstance
->
linphoneCoreCreated
();
&
m
PromiseW
atcher
,
&
QFutureWatcher
<
void
>::
finished
,
this
,
[]()
{
m
Instance
->
mCallsListModel
=
new
CallsListModel
(
mI
nstance
);
m
Instance
->
mContactsListModel
=
new
ContactsListModel
(
mI
nstance
);
m
Instance
->
mSipAddressesModel
=
new
SipAddressesModel
(
mI
nstance
);
m
Instance
->
mSettingsModel
=
new
SettingsModel
(
mI
nstance
);
m
Instance
->
mAccountSettingsModel
=
new
AccountSettingsModel
(
mI
nstance
);
emit
m
I
nstance
->
linphoneCoreCreated
();
}
);
m
_promise_watcher
.
setFuture
(
m_promise_b
uild
);
m
PromiseWatcher
.
setFuture
(
mPromiseB
uild
);
}
void
CoreManager
::
enableHandlers
()
{
m
_cbs_t
imer
->
start
();
m
CbsT
imer
->
start
();
}
// -----------------------------------------------------------------------------
void
CoreManager
::
init
(
QObject
*
parent
,
const
QString
&
config
_p
ath
)
{
if
(
m
_i
nstance
)
void
CoreManager
::
init
(
QObject
*
parent
,
const
QString
&
config
P
ath
)
{
if
(
m
I
nstance
)
return
;
m
_instance
=
new
CoreManager
(
parent
,
config_p
ath
);
m
Instance
=
new
CoreManager
(
parent
,
configP
ath
);
QTimer
*
timer
=
m
_instance
->
m_cbs_timer
=
new
QTimer
(
m_i
nstance
);
QTimer
*
timer
=
m
Instance
->
mCbsTimer
=
new
QTimer
(
mI
nstance
);
timer
->
setInterval
(
20
);
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
m
_i
nstance
,
&
CoreManager
::
iterate
);
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
m
I
nstance
,
&
CoreManager
::
iterate
);
}
// -----------------------------------------------------------------------------
...
...
@@ -80,27 +80,27 @@ VcardModel *CoreManager::createDetachedVcardModel () {
void
CoreManager
::
forceRefreshRegisters
()
{
qInfo
()
<<
QStringLiteral
(
"Refresh registers."
);
m
_instance
->
m_c
ore
->
refreshRegisters
();
m
Instance
->
mC
ore
->
refreshRegisters
();
}
// -----------------------------------------------------------------------------
void
CoreManager
::
setDatabasesPaths
()
{
m
_c
ore
->
setFriendsDatabasePath
(
Paths
::
getFriendsListFilepath
());
m
_c
ore
->
setCallLogsDatabasePath
(
Paths
::
getCallHistoryFilepath
());
m
_c
ore
->
setChatDatabasePath
(
Paths
::
getMessageHistoryFilepath
());
m
C
ore
->
setFriendsDatabasePath
(
Paths
::
getFriendsListFilepath
());
m
C
ore
->
setCallLogsDatabasePath
(
Paths
::
getCallHistoryFilepath
());
m
C
ore
->
setChatDatabasePath
(
Paths
::
getMessageHistoryFilepath
());
}
void
CoreManager
::
setOtherPaths
()
{
m
_c
ore
->
setZrtpSecretsFile
(
Paths
::
getZrtpSecretsFilepath
());
m
C
ore
->
setZrtpSecretsFile
(
Paths
::
getZrtpSecretsFilepath
());
// This one is actually a database but it MUST be set after the zrtp secrets
// as it allows automatic migration from old version(secrets, xml) to new version (data, sqlite).
m
_c
ore
->
setZrtpCacheDatabasePath
(
Paths
::
getZrtpDataFilepath
());
m
C
ore
->
setZrtpCacheDatabasePath
(
Paths
::
getZrtpDataFilepath
());
m
_c
ore
->
setUserCertificatesPath
(
Paths
::
getUserCertificatesDirpath
());
m
C
ore
->
setUserCertificatesPath
(
Paths
::
getUserCertificatesDirpath
());
m
_c
ore
->
setRootCa
(
Paths
::
getRootCaFilepath
());
m
C
ore
->
setRootCa
(
Paths
::
getRootCaFilepath
());
}
void
CoreManager
::
setResourcesPaths
()
{
...
...
@@ -111,7 +111,7 @@ void CoreManager::setResourcesPaths () {
// -----------------------------------------------------------------------------
void
CoreManager
::
createLinphoneCore
(
const
QString
&
config
_p
ath
)
{
void
CoreManager
::
createLinphoneCore
(
const
QString
&
config
P
ath
)
{
qInfo
()
<<
QStringLiteral
(
"Launch async linphone core creation."
);
// TODO: activate migration when ready to switch to this new version
...
...
@@ -119,10 +119,10 @@ void CoreManager::createLinphoneCore (const QString &config_path) {
setResourcesPaths
();
m
_core
=
linphone
::
Factory
::
get
()
->
createCore
(
m_handlers
,
Paths
::
getConfigFilepath
(
config_p
ath
),
Paths
::
getFactoryConfigFilepath
());
m
Core
=
linphone
::
Factory
::
get
()
->
createCore
(
mHandlers
,
Paths
::
getConfigFilepath
(
configP
ath
),
Paths
::
getFactoryConfigFilepath
());
m
_c
ore
->
setVideoDisplayFilter
(
"MSOGL"
);
m
_c
ore
->
usePreviewWindow
(
true
);
m
C
ore
->
setVideoDisplayFilter
(
"MSOGL"
);
m
C
ore
->
usePreviewWindow
(
true
);
setDatabasesPaths
();
setOtherPaths
();
...
...
@@ -131,7 +131,7 @@ void CoreManager::createLinphoneCore (const QString &config_path) {
// -----------------------------------------------------------------------------
void
CoreManager
::
iterate
()
{
m
_i
nstance
->
lockVideoRender
();
m
_instance
->
m_c
ore
->
iterate
();
m
_i
nstance
->
unlockVideoRender
();
m
I
nstance
->
lockVideoRender
();
m
Instance
->
mC
ore
->
iterate
();
m
I
nstance
->
unlockVideoRender
();
}
linphone-desktop/src/components/core/CoreManager.hpp
View file @
d8ff1b14
...
...
@@ -48,11 +48,11 @@ public:
void
enableHandlers
();
std
::
shared_ptr
<
linphone
::
Core
>
getCore
()
{
return
m
_c
ore
;
return
m
C
ore
;
}
std
::
shared_ptr
<
CoreHandlers
>
getHandlers
()
{
return
m
_h
andlers
;
return
m
H
andlers
;
}
// ---------------------------------------------------------------------------
...
...
@@ -60,11 +60,11 @@ public:
// ---------------------------------------------------------------------------
void
lockVideoRender
()
{
m
_mutex_video_r
ender
.
lock
();
m
MutexVideoR
ender
.
lock
();
}
void
unlockVideoRender
()
{
m
_mutex_video_r
ender
.
unlock
();
m
MutexVideoR
ender
.
unlock
();
}
// ---------------------------------------------------------------------------
...
...
@@ -72,33 +72,33 @@ public:
// ---------------------------------------------------------------------------
CallsListModel
*
getCallsListModel
()
const
{
return
m
_calls_list_m
odel
;
return
m
CallsListM
odel
;
}
ContactsListModel
*
getContactsListModel
()
const
{
return
m
_contacts_list_m
odel
;
return
m
ContactsListM
odel
;
}
SipAddressesModel
*
getSipAddressesModel
()
const
{
return
m
_sip_addresses_m
odel
;
return
m
SipAddressesM
odel
;
}
SettingsModel
*
getSettingsModel
()
const
{
return
m
_settings_m
odel
;
return
m
SettingsM
odel
;
}
AccountSettingsModel
*
getAccountSettingsModel
()
const
{
return
m
_account_settings_m
odel
;
return
m
AccountSettingsM
odel
;
}
// ---------------------------------------------------------------------------
// Initialization.
// ---------------------------------------------------------------------------
static
void
init
(
QObject
*
parent
,
const
QString
&
config
_p
ath
);
static
void
init
(
QObject
*
parent
,
const
QString
&
config
P
ath
);
static
CoreManager
*
getInstance
()
{
return
m
_i
nstance
;
return
m
I
nstance
;
}
// ---------------------------------------------------------------------------
...
...
@@ -113,33 +113,33 @@ signals:
void
linphoneCoreCreated
();
private:
CoreManager
(
QObject
*
parent
,
const
QString
&
config
_p
ath
);
CoreManager
(
QObject
*
parent
,
const
QString
&
config
P
ath
);
void
setDatabasesPaths
();
void
setOtherPaths
();
void
setResourcesPaths
();
void
createLinphoneCore
(
const
QString
&
config
_p
ath
);
void
createLinphoneCore
(
const
QString
&
config
P
ath
);
void
iterate
();
std
::
shared_ptr
<
linphone
::
Core
>
m
_c
ore
;
std
::
shared_ptr
<
CoreHandlers
>
m
_h
andlers
;
std
::
shared_ptr
<
linphone
::
Core
>
m
C
ore
;
std
::
shared_ptr
<
CoreHandlers
>
m
H
andlers
;
CallsListModel
*
m
_calls_list_m
odel
;
ContactsListModel
*
m
_contacts_list_m
odel
;
SipAddressesModel
*
m
_sip_addresses_m
odel
;
SettingsModel
*
m
_settings_m
odel
;
AccountSettingsModel
*
m
_account_settings_m
odel
;
CallsListModel
*
m
CallsListM
odel
;
ContactsListModel
*
m
ContactsListM
odel
;
SipAddressesModel
*
m
SipAddressesM
odel
;
SettingsModel
*
m
SettingsM
odel
;
AccountSettingsModel
*
m
AccountSettingsM
odel
;
QTimer
*
m
_cbs_t
imer
;
QTimer
*
m
CbsT
imer
;
QFuture
<
void
>
m
_promise_b
uild
;
QFutureWatcher
<
void
>
m
_promise_w
atcher
;
QFuture
<
void
>
m
PromiseB
uild
;
QFutureWatcher
<
void
>
m
PromiseW
atcher
;
QMutex
m
_mutex_video_r
ender
;
QMutex
m
MutexVideoR
ender
;
static
CoreManager
*
m
_i
nstance
;
static
CoreManager
*
m
I
nstance
;
};
#endif // CORE_MANAGER_H_
linphone-desktop/src/components/notifier/Notifier.cpp
View file @
d8ff1b14
...
...
@@ -59,10 +59,10 @@ using namespace std;
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
property
)
{
QVariant
variant
=
object
.
property
(
property
);
bool
so
_far_so_g
ood
;
bool
so
FarSoG
ood
;
int
size
=
variant
.
toInt
(
&
so
_far_so_g
ood
);
if
(
!
so
_far_so_g
ood
||
size
<
0
)
{
int
size
=
variant
.
toInt
(
&
so
FarSoG
ood
);
if
(
!
so
FarSoG
ood
||
size
<
0
)
{
qWarning
()
<<
"Unable to get notification size."
;
return
-
1
;
}
...
...
@@ -89,13 +89,13 @@ Notifier::Notifier (QObject *parent) :
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
// Build components.
m
_c
omponents
[
Notifier
::
MessageReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH_RECEIVED_MESSAGE
));
m
_c
omponents
[
Notifier
::
FileMessageReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE
));
m
_c
omponents
[
Notifier
::
CallReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH_RECEIVED_CALL
));
m
C
omponents
[
Notifier
::
MessageReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH_RECEIVED_MESSAGE
));
m
C
omponents
[
Notifier
::
FileMessageReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE
));
m
C
omponents
[
Notifier
::
CallReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH_RECEIVED_CALL
));
// Check errors.
for
(
int
i
=
0
;
i
<
Notifier
::
MaxNbTypes
;
++
i
)
{
QQmlComponent
*
component
=
m
_c
omponents
[
i
];
QQmlComponent
*
component
=
m
C
omponents
[
i
];
if
(
component
->
isError
())
{
qWarning
()
<<
QStringLiteral
(
"Errors found in `Notification` component %1:"
).
arg
(
i
)
<<
component
->
errors
();
abort
();
...
...
@@ -105,37 +105,37 @@ Notifier::Notifier (QObject *parent) :
Notifier
::~
Notifier
()
{
for
(
int
i
=
0
;
i
<
Notifier
::
MaxNbTypes
;
++
i
)
delete
m
_c
omponents
[
i
];
delete
m
C
omponents
[
i
];
}
// -----------------------------------------------------------------------------
QObject
*
Notifier
::
createNotification
(
Notifier
::
NotificationType
type
)
{
m
_m
utex
.
lock
();
m
M
utex
.
lock
();
Q_ASSERT
(
m
_n_instances
<=
N_MAX_NOTIFICATIONS
);
Q_ASSERT
(
m
InstancesNumber
<=
N_MAX_NOTIFICATIONS
);
// Check existing instances.
if
(
m
_n_instances
==
N_MAX_NOTIFICATIONS
)
{
if
(
m
InstancesNumber
==
N_MAX_NOTIFICATIONS
)
{
qWarning
()
<<
"Unable to create another notification"
;
m
_m
utex
.
unlock
();
m
M
utex
.
unlock
();
return
nullptr
;
}
// Create instance and set attributes.
QObject
*
object
=
m
_c
omponents
[
type
]
->
create
();
QObject
*
object
=
m
C
omponents
[
type
]
->
create
();
int
offset
=
getNotificationSize
(
*
object
,
NOTIFICATION_PROPERTY_HEIGHT
);
if
(
offset
==
-
1
||
!::
setProperty
(
*
object
,
NOTIFICATION_PROPERTY_OFFSET
,
m
_o
ffset
))
{
if
(
offset
==
-
1
||
!::
setProperty
(
*
object
,
NOTIFICATION_PROPERTY_OFFSET
,
m
O
ffset
))
{
delete
object
;
m
_m
utex
.
unlock
();
m
M
utex
.
unlock
();
return
nullptr
;
}
m
_offset
=
(
offset
+
m_o
ffset
)
+
NOTIFICATION_SPACING
;
m
_n_instances
++
;
m
Offset
=
(
offset
+
mO
ffset
)
+
NOTIFICATION_SPACING
;
m
InstancesNumber
++
;
m
_m
utex
.
unlock
();
m
M
utex
.
unlock
();
return
object
;
}
...
...
@@ -166,13 +166,13 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// -----------------------------------------------------------------------------
void
Notifier
::
deleteNotification
(
QVariant
notification
)
{
m
_m
utex
.
lock
();
m
M
utex
.
lock
();
QObject
*
instance
=
notification
.
value
<
QObject
*>
();
// Notification marked destroyed.
if
(
instance
->
property
(
"__valid"
).
isValid
())
{
m
_m
utex
.
unlock
();
m
M
utex
.
unlock
();
return
;
}
...
...
@@ -181,13 +181,13 @@ void Notifier::deleteNotification (QVariant notification) {
instance
->
setProperty
(
"__valid"
,
true
);
instance
->
property
(
NOTIFICATION_PROPERTY_TIMER
).
value
<
QTimer
*>
()
->
stop
();
m
_n_instances
--
;
if
(
m
_n_instances
==
0
)
m
_o
ffset
=
0
;
m
InstancesNumber
--
;
if
(
m
InstancesNumber
==
0
)
m
O
ffset
=
0
;
Q_ASSERT
(
m
_n_instances
>=
0
);
Q_ASSERT
(
m
InstancesNumber
>=
0
);
m
_m
utex
.
unlock
();
m
M
utex
.
unlock
();
instance
->
deleteLater
();
}
...
...
linphone-desktop/src/components/notifier/Notifier.hpp
View file @
d8ff1b14
...
...
@@ -56,11 +56,11 @@ private:
QObject
*
createNotification
(
NotificationType
type
);
void
showNotification
(
QObject
*
notification
,
int
timeout
);
QQmlComponent
*
m
_c
omponents
[
MaxNbTypes
];
QQmlComponent
*
m
C
omponents
[
MaxNbTypes
];
int
m
_o
ffset
=
0
;
int
m
_n_instances
=
0
;
QMutex
m
_m
utex
;
int
m
O
ffset
=
0
;
int
m
InstancesNumber
=
0
;
QMutex
m
M
utex
;
};
#endif // NOTIFIER_H_
linphone-desktop/src/components/settings/AccountSettingsModel.cpp
View file @
d8ff1b14
...
...
@@ -59,21 +59,21 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
// -----------------------------------------------------------------------------
bool
AccountSettingsModel
::
addOrUpdateProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
)
{
Q_ASSERT
(
proxy
_c
onfig
!=
nullptr
);
bool
AccountSettingsModel
::
addOrUpdateProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
)
{
Q_ASSERT
(
proxy
C
onfig
!=
nullptr
);
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
list
<
shared_ptr
<
linphone
::
ProxyConfig
>
>
proxy
_c
onfigs
=
core
->
getProxyConfigList
();
if
(
find
(
proxy
_configs
.
cbegin
(),
proxy_configs
.
cend
(),
proxy_config
)
!=
proxy_c
onfigs
.
cend
())
{
if
(
proxy
_c
onfig
->
done
()
==
-
1
)
{
list
<
shared_ptr
<
linphone
::
ProxyConfig
>
>
proxy
C
onfigs
=
core
->
getProxyConfigList
();
if
(
find
(
proxy
Configs
.
cbegin
(),
proxyConfigs
.
cend
(),
proxyConfig
)
!=
proxyC
onfigs
.
cend
())
{
if
(
proxy
C
onfig
->
done
()
==
-
1
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to update proxy config: `%1`."
)
.
arg
(
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getIdentityAddress
()
->
asString
()));
.
arg
(
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getIdentityAddress
()
->
asString
()));
return
false
;
}
}
else
if
(
core
->
addProxyConfig
(
proxy
_c
onfig
)
==
-
1
)
{
}
else
if
(
core
->
addProxyConfig
(
proxy
C
onfig
)
==
-
1
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to add proxy config: `%1`."
)
.
arg
(
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getIdentityAddress
()
->
asString
()));
.
arg
(
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getIdentityAddress
()
->
asString
()));
return
false
;
}
...
...
@@ -82,51 +82,51 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::Pr
return
true
;
}
QVariantMap
AccountSettingsModel
::
getProxyConfigDescription
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
)
{
Q_ASSERT
(
proxy
_c
onfig
!=
nullptr
);
QVariantMap
AccountSettingsModel
::
getProxyConfigDescription
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
)
{
Q_ASSERT
(
proxy
C
onfig
!=
nullptr
);
QVariantMap
map
;
{
const
shared_ptr
<
const
linphone
::
Address
>
address
=
proxy
_c
onfig
->
getIdentityAddress
();
const
shared_ptr
<
const
linphone
::
Address
>
address
=
proxy
C
onfig
->
getIdentityAddress
();
map
[
"sipAddress"
]
=
address
?
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getIdentityAddress
()
->
asStringUriOnly
())
?
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getIdentityAddress
()
->
asStringUriOnly
())
:
""
;
}
map
[
"serverAddress"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getServerAddr
());
map
[
"registrationDuration"
]
=
proxy
_c
onfig
->
getPublishExpires
();
map
[
"transport"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getTransport
());
map
[
"route"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getRoute
());
map
[
"contactParams"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getContactParameters
());
map
[
"avpfInterval"
]
=
proxy
_c
onfig
->
getAvpfRrInterval
();
map
[
"registerEnabled"
]
=
proxy
_c
onfig
->
registerEnabled
();
map
[
"publishPresence"
]
=
proxy
_c
onfig
->
publishEnabled
();
map
[
"avpfEnabled"
]
=
proxy
_c
onfig
->
getAvpfMode
()
==
linphone
::
AVPFMode
::
AVPFModeEnabled
;
map
[
"registrationState"
]
=
mapLinphoneRegistrationStateToUi
(
proxy
_c
onfig
->
getState
());
map
[
"serverAddress"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getServerAddr
());
map
[
"registrationDuration"
]
=
proxy
C
onfig
->
getPublishExpires
();
map
[
"transport"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getTransport
());
map
[
"route"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getRoute
());
map
[
"contactParams"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getContactParameters
());
map
[
"avpfInterval"
]
=
proxy
C
onfig
->
getAvpfRrInterval
();
map
[
"registerEnabled"
]
=
proxy
C
onfig
->
registerEnabled
();
map
[
"publishPresence"
]
=
proxy
C
onfig
->
publishEnabled
();
map
[
"avpfEnabled"
]
=
proxy
C
onfig
->
getAvpfMode
()
==
linphone
::
AVPFMode
::
AVPFModeEnabled
;
map
[
"registrationState"
]
=
mapLinphoneRegistrationStateToUi
(
proxy
C
onfig
->
getState
());
return
map
;
}
void
AccountSettingsModel
::
setDefaultProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
)
{
Q_ASSERT
(
proxy
_c
onfig
!=
nullptr
);
void
AccountSettingsModel
::
setDefaultProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
)
{
Q_ASSERT
(
proxy
C
onfig
!=
nullptr
);
CoreManager
::
getInstance
()
->
getCore
()
->
setDefaultProxyConfig
(
proxy
_c
onfig
);
CoreManager
::
getInstance
()
->
getCore
()
->
setDefaultProxyConfig
(
proxy
C
onfig
);
emit
accountSettingsUpdated
();
}
void
AccountSettingsModel
::
removeProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
)
{
Q_ASSERT
(
proxy
_c
onfig
!=
nullptr
);
void
AccountSettingsModel
::
removeProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
)
{
Q_ASSERT
(
proxy
C
onfig
!=
nullptr
);
CoreManager
::
getInstance
()
->
getCore
()
->
removeProxyConfig
(
proxy
_c
onfig
);
CoreManager
::
getInstance
()
->
getCore
()
->
removeProxyConfig
(
proxy
C
onfig
);
emit
accountSettingsUpdated
();
}
bool
AccountSettingsModel
::
addOrUpdateProxyConfig
(
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
,
const
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
,
const
QVariantMap
&
data
)
{
Q_ASSERT
(
proxy
_c
onfig
!=
nullptr
);
Q_ASSERT
(
proxy
C
onfig
!=
nullptr
);
QString
literal
=
data
[
"sipAddress"
].
toString
();
...
...
@@ -140,31 +140,31 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
return
false
;
}
proxy
_c
onfig
->
setIdentityAddress
(
address
);
proxy
C
onfig
->
setIdentityAddress
(
address
);
}
// Server address.
{
QString
server
_a
ddress
=
data
[
"serverAddress"
].
toString
();
QString
server
A
ddress
=
data
[
"serverAddress"
].
toString
();
if
(
proxy
_config
->
setServerAddr
(
::
Utils
::
qStringToLinphoneString
(
server_a
ddress
)))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add server address: `%1`."
).
arg
(
server
_a
ddress
);
if
(
proxy
Config
->
setServerAddr
(
::
Utils
::
qStringToLinphoneString
(
serverA
ddress
)))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add server address: `%1`."
).
arg
(
server
A
ddress
);
return
false
;
}
}
proxy
_c
onfig
->
setPublishExpires
(
data
[
"registrationDuration"
].
toInt
());
proxy
_c
onfig
->
setRoute
(
::
Utils
::
qStringToLinphoneString
(
data
[
"route"
].
toString
()));
proxy
_c
onfig
->
setContactParameters
(
::
Utils
::
qStringToLinphoneString
(
data
[
"contactParams"
].
toString
()));
proxy
_c
onfig
->
setAvpfRrInterval
(
static_cast
<
uint8_t
>
(
data
[
"avpfInterval"
].
toInt
()));
proxy
_c
onfig
->
enableRegister
(
data
[
"registerEnabled"
].
toBool
());
proxy
_c
onfig
->
enablePublish
(
data
[
"publishEnabled"
].
toBool
());
proxy
_c
onfig
->
setAvpfMode
(
data
[
"avpfEnabled"
].
toBool
()
proxy
C
onfig
->
setPublishExpires
(
data
[
"registrationDuration"
].
toInt
());
proxy
C
onfig
->
setRoute
(
::
Utils
::
qStringToLinphoneString
(
data
[
"route"
].
toString
()));
proxy
C
onfig
->
setContactParameters
(
::
Utils
::
qStringToLinphoneString
(
data
[
"contactParams"
].
toString
()));
proxy
C
onfig
->
setAvpfRrInterval
(
static_cast
<
uint8_t
>
(
data
[
"avpfInterval"
].
toInt
()));
proxy
C
onfig
->
enableRegister
(
data
[
"registerEnabled"
].
toBool
());
proxy
C
onfig
->
enablePublish
(
data
[
"publishEnabled"
].
toBool
());
proxy
C
onfig
->
setAvpfMode
(
data
[
"avpfEnabled"
].
toBool
()
?
linphone
::
AVPFMode
::
AVPFModeEnabled
:
linphone
::
AVPFMode
::
AVPFModeDefault
);
return
addOrUpdateProxyConfig
(
proxy
_c
onfig
);
return
addOrUpdateProxyConfig
(
proxy
C
onfig
);
}
shared_ptr
<
linphone
::
ProxyConfig
>
AccountSettingsModel
::
createProxyConfig
()
{
...
...
@@ -172,14 +172,14 @@ shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
}
void
AccountSettingsModel
::
addAuthInfo
(
const
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
_i
nfo
,
const
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
I
nfo
,
const
QString
&
password
,
const
QString
&
user
_i
d
const
QString
&
user
I
d
)
{
auth
_i
nfo
->
setPasswd
(
::
Utils
::
qStringToLinphoneString
(
password
));
auth
_info
->
setUserid
(
::
Utils
::
qStringToLinphoneString
(
user_i
d
));
auth
I
nfo
->
setPasswd
(
::
Utils
::
qStringToLinphoneString
(
password
));
auth
Info
->
setUserid
(
::
Utils
::
qStringToLinphoneString
(
userI
d
));
CoreManager
::
getInstance
()
->
getCore
()
->
addAuthInfo
(
auth
_i
nfo
);
CoreManager
::
getInstance
()
->
getCore
()
->
addAuthInfo
(
auth
I
nfo
);
}
void
AccountSettingsModel
::
eraseAllPasswords
()
{
...
...
@@ -190,22 +190,22 @@ void AccountSettingsModel::eraseAllPasswords () {
QString
AccountSettingsModel
::
getUsername
()
const
{
shared_ptr
<
const
linphone
::
Address
>
address
=
getUsedSipAddress
();
const
string
&
display
_n
ame
=
address
->
getDisplayName
();
const
string
&
display
N
ame
=
address
->
getDisplayName
();
return
::
Utils
::
linphoneStringToQString
(
display
_name
.
empty
()
?
address
->
getUsername
()
:
display_n
ame
display
Name
.
empty
()
?
address
->
getUsername
()
:
displayN
ame
);
}
void
AccountSettingsModel
::
setUsername
(
const
QString
&
username
)
{
shared_ptr
<
const
linphone
::
Address
>
address
=
getUsedSipAddress
();
shared_ptr
<
linphone
::
Address
>
new
_a
ddress
=
address
->
clone
();
shared_ptr
<
linphone
::
Address
>
new
A
ddress
=
address
->
clone
();
if
(
new
_a
ddress
->
setDisplayName
(
::
Utils
::
qStringToLinphoneString
(
username
)))
{
if
(
new
A
ddress
->
setDisplayName
(
::
Utils
::
qStringToLinphoneString
(
username
)))
{
qWarning
()
<<
QStringLiteral
(
"Unable to set displayName on sip address: `%1`."
)
.
arg
(
::
Utils
::
linphoneStringToQString
(
new
_a
ddress
->
asStringUriOnly
()));
.
arg
(
::
Utils
::
linphoneStringToQString
(
new
A
ddress
->
asStringUriOnly
()));
}
else
{
setUsedSipAddress
(
new
_a
ddress
);
setUsedSipAddress
(
new
A
ddress
);
}
emit
accountSettingsUpdated
();
...
...
@@ -216,8 +216,8 @@ QString AccountSettingsModel::getSipAddress () const {
}
AccountSettingsModel
::
RegistrationState
AccountSettingsModel
::
getRegistrationState
()
const
{
shared_ptr
<
linphone
::
ProxyConfig
>
proxy
_c
onfig
=
CoreManager
::
getInstance
()
->
getCore
()
->
getDefaultProxyConfig
();
return
proxy
_config
?
mapLinphoneRegistrationStateToUi
(
proxy_c
onfig
->
getState
())
:
RegistrationStateNotRegistered
;
shared_ptr
<
linphone
::
ProxyConfig
>
proxy
C
onfig
=
CoreManager
::
getInstance
()
->
getCore
()
->
getDefaultProxyConfig
();
return
proxy
Config
?
mapLinphoneRegistrationStateToUi
(
proxyC
onfig
->
getState
())
:
RegistrationStateNotRegistered
;
}
// -----------------------------------------------------------------------------
...
...
@@ -274,10 +274,10 @@ QVariantList AccountSettingsModel::getAccounts () const {
accounts
<<
account
;
}
for
(
const
auto
&
proxy
_c
onfig
:
core
->
getProxyConfigList
())
{
for
(
const
auto
&
proxy
C
onfig
:
core
->
getProxyConfigList
())
{
QVariantMap
account
;
account
[
"sipAddress"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
_c
onfig
->
getIdentityAddress
()
->
asStringUriOnly
());
account
[
"proxyConfig"
].
setValue
(
proxy
_c
onfig
);
account
[
"sipAddress"
]
=
::
Utils
::
linphoneStringToQString
(
proxy
C
onfig
->
getIdentityAddress
()
->
asStringUriOnly
());
account
[
"proxyConfig"
].
setValue
(
proxy
C
onfig
);
accounts
<<
account
;
}
...
...
@@ -288,16 +288,16 @@ QVariantList AccountSettingsModel::getAccounts () const {
void
AccountSettingsModel
::
setUsedSipAddress
(
const
shared_ptr
<
const
linphone
::
Address
>
&
address
)
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
ProxyConfig
>
proxy
_c
onfig
=
core
->
getDefaultProxyConfig
();
shared_ptr
<
linphone
::
ProxyConfig
>
proxy
C
onfig
=
core
->
getDefaultProxyConfig
();
proxy
_config
?
proxy_c
onfig
->
setIdentityAddress
(
address
)
:
core
->
setPrimaryContact
(
address
->
asString
());
proxy
Config
?
proxyC
onfig
->
setIdentityAddress
(
address
)
:
core
->
setPrimaryContact
(
address
->
asString
());
}
shared_ptr
<
const
linphone
::
Address
>
AccountSettingsModel
::
getUsedSipAddress
()
const
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
ProxyConfig
>
proxy
_c
onfig
=
core
->
getDefaultProxyConfig
();
shared_ptr
<
linphone
::
ProxyConfig
>
proxy
C
onfig
=
core
->
getDefaultProxyConfig
();
return
proxy
_config
?
proxy_c
onfig
->
getIdentityAddress
()
:
core
->
getPrimaryContactParsed
();
return
proxy
Config
?
proxyC
onfig
->
getIdentityAddress
()
:
core
->
getPrimaryContactParsed
();
}
// -----------------------------------------------------------------------------
...
...
linphone-desktop/src/components/settings/AccountSettingsModel.hpp
View file @
d8ff1b14
...
...
@@ -55,21 +55,21 @@ public:
AccountSettingsModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
AccountSettingsModel
()
=
default
;
bool
addOrUpdateProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
);
bool
addOrUpdateProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
);
Q_INVOKABLE
QVariantMap
getProxyConfigDescription
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
);
Q_INVOKABLE
QVariantMap
getProxyConfigDescription
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
);
Q_INVOKABLE
void
setDefaultProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
);
Q_INVOKABLE
void
setDefaultProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
);
Q_INVOKABLE
bool
addOrUpdateProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
,
const
QVariantMap
&
data
);
Q_INVOKABLE
void
removeProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
);
Q_INVOKABLE
bool
addOrUpdateProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
,
const
QVariantMap
&
data
);
Q_INVOKABLE
void
removeProxyConfig
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
);
Q_INVOKABLE
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
createProxyConfig
();
Q_INVOKABLE
void
addAuthInfo
(
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
_i
nfo
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth
I
nfo
,
const
QString
&
password
,
const
QString
&
user
_i
d
const
QString
&
user
I
d
);
Q_INVOKABLE
void
eraseAllPasswords
();
...
...
@@ -105,7 +105,7 @@ private:
// ---------------------------------------------------------------------------
void
handleRegistrationStateChanged
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
_c
onfig
,
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxy
C
onfig
,
linphone
::
RegistrationState
state
);
};
...
...
linphone-desktop/src/components/settings/SettingsModel.cpp
View file @
d8ff1b14
...
...
@@ -35,7 +35,7 @@ using namespace std;
const
string
SettingsModel
::
UI_SECTION
(
"ui"
);
SettingsModel
::
SettingsModel
(
QObject
*
parent
)
:
QObject
(
parent
)
{
m
_c
onfig
=
CoreManager
::
getInstance
()
->
getCore
()
->
getConfig
();
m
C
onfig
=
CoreManager
::
getInstance
()
->
getCore
()
->
getConfig
();
}
// =============================================================================
...
...
@@ -103,13 +103,13 @@ QString SettingsModel::getRingPath () const {
}
void
SettingsModel
::
setRingPath
(
const
QString
&
path
)
{
QString
cleaned
_p
ath
=
QDir
::
cleanPath
(
path
);
QString
cleaned
P
ath
=
QDir
::
cleanPath
(
path
);
CoreManager
::
getInstance
()
->
getCore
()
->
setRing
(
::
Utils
::
qStringToLinphoneString
(
cleaned
_p
ath
)
::
Utils
::
qStringToLinphoneString
(
cleaned
P
ath
)
);
emit
ringPathChanged
(
cleaned
_p
ath
);
emit
ringPathChanged
(
cleaned
P
ath
);
}
// -----------------------------------------------------------------------------
...
...
@@ -182,22 +182,22 @@ void SettingsModel::setVideoFramerate (int framerate) {
// =============================================================================
int
SettingsModel
::
getAutoAnswerDelay
()
const
{
return
m
_c
onfig
->
getInt
(
UI_SECTION
,
"auto_answer_delay"
,
0
);
return
m
C
onfig
->
getInt
(
UI_SECTION
,
"auto_answer_delay"
,
0
);
}
void
SettingsModel
::
setAutoAnswerDelay
(
int
delay
)
{
m
_c
onfig
->
setInt
(
UI_SECTION
,
"auto_answer_delay"
,
delay
);
m
C
onfig
->
setInt
(
UI_SECTION
,
"auto_answer_delay"
,
delay
);
emit
autoAnswerDelayChanged
(
delay
);
}
// -----------------------------------------------------------------------------
bool
SettingsModel
::
getAutoAnswerStatus
()
const
{
return
!!
m
_c
onfig
->
getInt
(
UI_SECTION
,
"auto_answer"
,
0
);
return
!!
m
C
onfig
->
getInt
(
UI_SECTION
,
"auto_answer"
,
0
);
}
void
SettingsModel
::
setAutoAnswerStatus
(
bool
status
)
{
m
_c
onfig
->
setInt
(
UI_SECTION
,
"auto_answer"
,
status
);
m
C
onfig
->
setInt
(
UI_SECTION
,
"auto_answer"
,
status
);
emit
autoAnswerStatusChanged
(
status
);
}
...
...
@@ -429,10 +429,10 @@ bool SettingsModel::getIceEnabled () const {
}
void
SettingsModel
::
setIceEnabled
(
bool
status
)
{
shared_ptr
<
linphone
::
NatPolicy
>
nat
_p
olicy
=
CoreManager
::
getInstance
()
->
getCore
()
->
getNatPolicy
();
shared_ptr
<
linphone
::
NatPolicy
>
nat
P
olicy
=
CoreManager
::
getInstance
()
->
getCore
()
->
getNatPolicy
();
nat
_p
olicy
->
enableIce
(
status
);
nat
_p
olicy
->
enableStun
(
status
);
nat
P
olicy
->
enableIce
(
status
);
nat
P
olicy
->
enableStun
(
status
);
emit
iceEnabledChanged
(
status
);
}
...
...
@@ -456,9 +456,9 @@ QString SettingsModel::getStunServer () const {
);
}
void
SettingsModel
::
setStunServer
(
const
QString
&
stun
_s
erver
)
{
void
SettingsModel
::
setStunServer
(
const
QString
&
stun
S
erver
)
{
CoreManager
::
getInstance
()
->
getCore
()
->
getNatPolicy
()
->
setStunServer
(
::
Utils
::
qStringToLinphoneString
(
stun
_s
erver
)
::
Utils
::
qStringToLinphoneString
(
stun
S
erver
)
);
}
...
...
@@ -482,28 +482,28 @@ void SettingsModel::setTurnUser (const QString &user) {
QString
SettingsModel
::
getTurnPassword
()
const
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
NatPolicy
>
nat
_p
olicy
=
core
->
getNatPolicy
();
shared_ptr
<
const
linphone
::
AuthInfo
>
auth
_info
=
core
->
findAuthInfo
(
nat_p
olicy
->
getStunServerUsername
(),
""
,
""
);
shared_ptr
<
linphone
::
NatPolicy
>
nat
P
olicy
=
core
->
getNatPolicy
();
shared_ptr
<
const
linphone
::
AuthInfo
>
auth
Info
=
core
->
findAuthInfo
(
natP
olicy
->
getStunServerUsername
(),
""
,
""
);
return
auth
_info
?
::
Utils
::
linphoneStringToQString
(
auth_i
nfo
->
getPasswd
())
:
""
;
return
auth
Info
?
::
Utils
::
linphoneStringToQString
(
authI
nfo
->
getPasswd
())
:
""
;
}
void
SettingsModel
::
setTurnPassword
(
const
QString
&
password
)
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
NatPolicy
>
nat
_p
olicy
=
core
->
getNatPolicy
();
shared_ptr
<
linphone
::
NatPolicy
>
nat
P
olicy
=
core
->
getNatPolicy
();
const
string
&
username
=
nat
_p
olicy
->
getStunServerUsername
();
shared_ptr
<
const
linphone
::
AuthInfo
>
auth
_i
nfo
=
core
->
findAuthInfo
(
username
,
""
,
""
);
const
string
&
username
=
nat
P
olicy
->
getStunServerUsername
();
shared_ptr
<
const
linphone
::
AuthInfo
>
auth
I
nfo
=
core
->
findAuthInfo
(
username
,
""
,
""
);
if
(
auth
_i
nfo
)
{
shared_ptr
<
linphone
::
AuthInfo
>
auth_info_clone
=
auth_i
nfo
->
clone
();
auth_info_clone
->
setPasswd
(
::
Utils
::
qStringToLinphoneString
(
password
));
if
(
auth
I
nfo
)
{
shared_ptr
<
linphone
::
AuthInfo
>
clonedAuthInfo
=
authI
nfo
->
clone
();
clonedAuthInfo
->
setPasswd
(
::
Utils
::
qStringToLinphoneString
(
password
));
core
->
removeAuthInfo
(
auth
_i
nfo
);
core
->
addAuthInfo
(
auth_info_clone
);
core
->
removeAuthInfo
(
auth
I
nfo
);
core
->
addAuthInfo
(
clonedAuthInfo
);
}
else
{
auth
_i
nfo
=
linphone
::
Factory
::
get
()
->
createAuthInfo
(
username
,
username
,
::
Utils
::
qStringToLinphoneString
(
password
),
""
,
""
,
""
);
core
->
addAuthInfo
(
auth
_i
nfo
);
auth
I
nfo
=
linphone
::
Factory
::
get
()
->
createAuthInfo
(
username
,
username
,
::
Utils
::
qStringToLinphoneString
(
password
),
""
,
""
,
""
);
core
->
addAuthInfo
(
auth
I
nfo
);
}
emit
turnPasswordChanged
(
password
);
...
...
@@ -545,16 +545,16 @@ void SettingsModel::setDscpVideo (int dscp) {
QString
SettingsModel
::
getSavedScreenshotsFolder
()
const
{
return
QDir
::
cleanPath
(
::
Utils
::
linphoneStringToQString
(
m
_c
onfig
->
getString
(
UI_SECTION
,
"saved_screenshots_folder"
,
Paths
::
getCapturesDirpath
())
m
C
onfig
->
getString
(
UI_SECTION
,
"saved_screenshots_folder"
,
Paths
::
getCapturesDirpath
())
)
)
+
QDir
::
separator
();
}
void
SettingsModel
::
setSavedScreenshotsFolder
(
const
QString
&
folder
)
{
QString
cleaned
_f
older
=
QDir
::
cleanPath
(
folder
)
+
QDir
::
separator
();
QString
cleaned
F
older
=
QDir
::
cleanPath
(
folder
)
+
QDir
::
separator
();
m
_config
->
setString
(
UI_SECTION
,
"saved_screenshots_folder"
,
::
Utils
::
qStringToLinphoneString
(
cleaned_f
older
));
emit
savedScreenshotsFolderChanged
(
cleaned
_f
older
);
m
Config
->
setString
(
UI_SECTION
,
"saved_screenshots_folder"
,
::
Utils
::
qStringToLinphoneString
(
cleanedF
older
));
emit
savedScreenshotsFolderChanged
(
cleaned
F
older
);
}
// -----------------------------------------------------------------------------
...
...
@@ -562,7 +562,7 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
QString
SettingsModel
::
getSavedVideosFolder
()
const
{
return
QDir
::
cleanPath
(
::
Utils
::
linphoneStringToQString
(
m
_c
onfig
->
getString
(
UI_SECTION
,
"saved_videos_folder"
,
Paths
::
getCapturesDirpath
())
m
C
onfig
->
getString
(
UI_SECTION
,
"saved_videos_folder"
,
Paths
::
getCapturesDirpath
())
)
)
+
QDir
::
separator
();
}
...
...
@@ -570,6 +570,6 @@ QString SettingsModel::getSavedVideosFolder () const {
void
SettingsModel
::
setSavedVideosFolder
(
const
QString
&
folder
)
{
QString
_folder
=
QDir
::
cleanPath
(
folder
)
+
QDir
::
separator
();
m
_c
onfig
->
setString
(
UI_SECTION
,
"saved_videos_folder"
,
::
Utils
::
qStringToLinphoneString
(
_folder
));
m
C
onfig
->
setString
(
UI_SECTION
,
"saved_videos_folder"
,
::
Utils
::
qStringToLinphoneString
(
_folder
));
emit
savedVideosFolderChanged
(
_folder
);
}
linphone-desktop/src/components/settings/SettingsModel.hpp
View file @
d8ff1b14
...
...
@@ -220,7 +220,7 @@ public:
void
setTurnEnabled
(
bool
status
);
QString
getStunServer
()
const
;
void
setStunServer
(
const
QString
&
stun
_s
erver
);
void
setStunServer
(
const
QString
&
stun
S
erver
);
QString
getTurnUser
()
const
;
void
setTurnUser
(
const
QString
&
user
);
...
...
@@ -315,7 +315,7 @@ signals:
void
savedVideosFolderChanged
(
const
QString
&
folder
);
private:
std
::
shared_ptr
<
linphone
::
Config
>
m
_c
onfig
;
std
::
shared_ptr
<
linphone
::
Config
>
m
C
onfig
;
};
#endif // SETTINGS_MODEL_H_
linphone-desktop/src/components/sip-addresses/SipAddressObserver.cpp
View file @
d8ff1b14
...
...
@@ -24,30 +24,30 @@
// =============================================================================
SipAddressObserver
::
SipAddressObserver
(
const
QString
&
sip
_a
ddress
)
{
m
_sip_address
=
sip_a
ddress
;
SipAddressObserver
::
SipAddressObserver
(
const
QString
&
sip
A
ddress
)
{
m
SipAddress
=
sipA
ddress
;
}
void
SipAddressObserver
::
setContact
(
ContactModel
*
contact
)
{
if
(
contact
==
m
_c
ontact
)
if
(
contact
==
m
C
ontact
)
return
;
m
_c
ontact
=
contact
;
m
C
ontact
=
contact
;
emit
contactChanged
(
contact
);
}
void
SipAddressObserver
::
setPresenceStatus
(
const
Presence
::
PresenceStatus
&
presence
_s
tatus
)
{
if
(
presence
_status
==
m_presence_s
tatus
)
void
SipAddressObserver
::
setPresenceStatus
(
const
Presence
::
PresenceStatus
&
presence
S
tatus
)
{
if
(
presence
Status
==
mPresenceS
tatus
)
return
;
m
_presence_status
=
presence_s
tatus
;
emit
presenceStatusChanged
(
presence
_s
tatus
);
m
PresenceStatus
=
presenceS
tatus
;
emit
presenceStatusChanged
(
presence
S
tatus
);
}
void
SipAddressObserver
::
setUnreadMessagesCount
(
int
unread
_messages_c
ount
)
{
if
(
unread
_messages_count
==
m_unread_messages_c
ount
)
void
SipAddressObserver
::
setUnreadMessagesCount
(
int
unread
MessagesC
ount
)
{
if
(
unread
MessagesCount
==
mUnreadMessagesC
ount
)
return
;
m
_unread_messages_count
=
unread_messages_c
ount
;
emit
unreadMessagesCountChanged
(
unread
_messages_c
ount
);
m
UnreadMessagesCount
=
unreadMessagesC
ount
;
emit
unreadMessagesCountChanged
(
unread
MessagesC
ount
);
}
linphone-desktop/src/components/sip-addresses/SipAddressObserver.hpp
View file @
d8ff1b14
...
...
@@ -39,7 +39,7 @@ class SipAddressObserver : public QObject {
Q_PROPERTY
(
int
unreadMessagesCount
READ
getUnreadMessagesCount
NOTIFY
unreadMessagesCountChanged
);
public:
SipAddressObserver
(
const
QString
&
sip
_a
ddress
);
SipAddressObserver
(
const
QString
&
sip
A
ddress
);
~
SipAddressObserver
()
=
default
;
signals:
...
...
@@ -49,13 +49,13 @@ signals:
private:
QString
getSipAddress
()
const
{
return
m
_sip_a
ddress
;
return
m
SipA
ddress
;
}
// ---------------------------------------------------------------------------
ContactModel
*
getContact
()
const
{
return
m
_c
ontact
;
return
m
C
ontact
;
}
void
setContact
(
ContactModel
*
contact
);
...
...
@@ -63,24 +63,24 @@ private:
// ---------------------------------------------------------------------------
Presence
::
PresenceStatus
getPresenceStatus
()
const
{
return
m
_presence_s
tatus
;
return
m
PresenceS
tatus
;
}
void
setPresenceStatus
(
const
Presence
::
PresenceStatus
&
presence
_s
tatus
);
void
setPresenceStatus
(
const
Presence
::
PresenceStatus
&
presence
S
tatus
);
// ---------------------------------------------------------------------------
int
getUnreadMessagesCount
()
const
{
return
m
_unread_messages_c
ount
;
return
m
UnreadMessagesC
ount
;
}
void
setUnreadMessagesCount
(
int
unread
_messages_c
ount
);
void
setUnreadMessagesCount
(
int
unread
MessagesC
ount
);
QString
m
_sip_a
ddress
;
QString
m
SipA
ddress
;
ContactModel
*
m
_c
ontact
=
nullptr
;
Presence
::
PresenceStatus
m
_presence_s
tatus
=
Presence
::
PresenceStatus
::
Offline
;
int
m
_unread_messages_c
ount
=
0
;
ContactModel
*
m
C
ontact
=
nullptr
;
Presence
::
PresenceStatus
m
PresenceS
tatus
=
Presence
::
PresenceStatus
::
Offline
;
int
m
UnreadMessagesC
ount
=
0
;
};
Q_DECLARE_METATYPE
(
SipAddressObserver
*
);
...
...
linphone-desktop/src/components/sip-addresses/SipAddressesModel.cpp
View file @
d8ff1b14
...
...
@@ -37,7 +37,7 @@ using namespace std;
SipAddressesModel
::
SipAddressesModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
initSipAddresses
();
m
_core_h
andlers
=
CoreManager
::
getInstance
()
->
getHandlers
();
m
CoreH
andlers
=
CoreManager
::
getInstance
()
->
getHandlers
();
ContactsListModel
*
contacts
=
CoreManager
::
getInstance
()
->
getContactsListModel
();
...
...
@@ -47,15 +47,15 @@ SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(pare
QObject
::
connect
(
contacts
,
&
ContactsListModel
::
sipAddressAdded
,
this
,
&
SipAddressesModel
::
handleSipAddressAdded
);
QObject
::
connect
(
contacts
,
&
ContactsListModel
::
sipAddressRemoved
,
this
,
&
SipAddressesModel
::
handleSipAddressRemoved
);
QObject
::
connect
(
&
(
*
m
_core_h
andlers
),
&
CoreHandlers
::
messageReceived
,
this
,
&
SipAddressesModel
::
handleMessageReceived
);
QObject
::
connect
(
&
(
*
m
_core_h
andlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
&
SipAddressesModel
::
handleCallStateChanged
);
QObject
::
connect
(
&
(
*
m
_core_h
andlers
),
&
CoreHandlers
::
presenceReceived
,
this
,
&
SipAddressesModel
::
handlePresenceReceived
);
QObject
::
connect
(
&
(
*
m
CoreH
andlers
),
&
CoreHandlers
::
messageReceived
,
this
,
&
SipAddressesModel
::
handleMessageReceived
);
QObject
::
connect
(
&
(
*
m
CoreH
andlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
&
SipAddressesModel
::
handleCallStateChanged
);
QObject
::
connect
(
&
(
*
m
CoreH
andlers
),
&
CoreHandlers
::
presenceReceived
,
this
,
&
SipAddressesModel
::
handlePresenceReceived
);
}
// -----------------------------------------------------------------------------
int
SipAddressesModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m
_r
efs
.
count
();
return
m
R
efs
.
count
();
}
QHash
<
int
,
QByteArray
>
SipAddressesModel
::
roleNames
()
const
{
...
...
@@ -67,34 +67,34 @@ QHash<int, QByteArray> SipAddressesModel::roleNames () const {
QVariant
SipAddressesModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
_r
efs
.
count
())
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m
R
efs
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
QVariant
::
fromValue
(
*
m
_r
efs
[
row
]);
return
QVariant
::
fromValue
(
*
m
R
efs
[
row
]);
return
QVariant
();
}
// -----------------------------------------------------------------------------
void
SipAddressesModel
::
connectToChatModel
(
ChatModel
*
chat
_m
odel
)
{
QObject
::
connect
(
chat
_model
,
&
ChatModel
::
allEntriesRemoved
,
this
,
[
this
,
chat_m
odel
]
{
handleAllEntriesRemoved
(
chat
_m
odel
->
getSipAddress
());
void
SipAddressesModel
::
connectToChatModel
(
ChatModel
*
chat
M
odel
)
{
QObject
::
connect
(
chat
Model
,
&
ChatModel
::
allEntriesRemoved
,
this
,
[
this
,
chatM
odel
]
{
handleAllEntriesRemoved
(
chat
M
odel
->
getSipAddress
());
});
QObject
::
connect
(
chat
_m
odel
,
&
ChatModel
::
messageSent
,
this
,
&
SipAddressesModel
::
handleMessageSent
);
QObject
::
connect
(
chat
M
odel
,
&
ChatModel
::
messageSent
,
this
,
&
SipAddressesModel
::
handleMessageSent
);
QObject
::
connect
(
chat
_model
,
&
ChatModel
::
messagesCountReset
,
this
,
[
this
,
chat_m
odel
]
{
handleMessagesCountReset
(
chat
_m
odel
->
getSipAddress
());
QObject
::
connect
(
chat
Model
,
&
ChatModel
::
messagesCountReset
,
this
,
[
this
,
chatM
odel
]
{
handleMessagesCountReset
(
chat
M
odel
->
getSipAddress
());
});
}
// -----------------------------------------------------------------------------
ContactModel
*
SipAddressesModel
::
mapSipAddressToContact
(
const
QString
&
sip
_a
ddress
)
const
{
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
==
m
_sip_a
ddresses
.
end
())
ContactModel
*
SipAddressesModel
::
mapSipAddressToContact
(
const
QString
&
sip
A
ddress
)
const
{
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
==
m
SipA
ddresses
.
end
())
return
nullptr
;
return
it
->
value
(
"contact"
).
value
<
ContactModel
*>
();
...
...
@@ -102,12 +102,12 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_addr
// -----------------------------------------------------------------------------
SipAddressObserver
*
SipAddressesModel
::
getSipAddressObserver
(
const
QString
&
sip
_a
ddress
)
{
SipAddressObserver
*
model
=
new
SipAddressObserver
(
sip
_a
ddress
);
SipAddressObserver
*
SipAddressesModel
::
getSipAddressObserver
(
const
QString
&
sip
A
ddress
)
{
SipAddressObserver
*
model
=
new
SipAddressObserver
(
sip
A
ddress
);
{
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
!=
m
_sip_a
ddresses
.
end
())
{
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
!=
m
SipA
ddresses
.
end
())
{
model
->
setContact
(
it
->
value
(
"contact"
).
value
<
ContactModel
*>
());
model
->
setPresenceStatus
(
it
->
value
(
"presenceStatus"
,
Presence
::
PresenceStatus
::
Offline
).
value
<
Presence
::
PresenceStatus
>
()
...
...
@@ -118,12 +118,12 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
}
}
m
_observers
.
insert
(
sip_a
ddress
,
model
);
m
Observers
.
insert
(
sipA
ddress
,
model
);
QObject
::
connect
(
model
,
&
SipAddressObserver
::
destroyed
,
this
,
[
this
,
model
]()
{
const
QString
&
sip
_a
ddress
=
model
->
getSipAddress
();
if
(
m
_observers
.
remove
(
sip_a
ddress
,
model
)
==
0
)
qWarning
()
<<
QStringLiteral
(
"Unable to remove sip address `%1` from observers."
).
arg
(
sip
_a
ddress
);
const
QString
&
sip
A
ddress
=
model
->
getSipAddress
();
if
(
m
Observers
.
remove
(
sipA
ddress
,
model
)
==
0
)
qWarning
()
<<
QStringLiteral
(
"Unable to remove sip address `%1` from observers."
).
arg
(
sip
A
ddress
);
}
);
...
...
@@ -132,17 +132,17 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
// -----------------------------------------------------------------------------
QString
SipAddressesModel
::
interpretUrl
(
const
QString
&
sip
_a
ddress
)
const
{
shared_ptr
<
linphone
::
Address
>
l
_a
ddress
=
CoreManager
::
getInstance
()
->
getCore
()
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
_a
ddress
)
QString
SipAddressesModel
::
interpretUrl
(
const
QString
&
sip
A
ddress
)
const
{
shared_ptr
<
linphone
::
Address
>
l
A
ddress
=
CoreManager
::
getInstance
()
->
getCore
()
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sip
A
ddress
)
);
return
l
_address
?
::
Utils
::
linphoneStringToQString
(
l_a
ddress
->
asStringUriOnly
())
:
""
;
return
l
Address
?
::
Utils
::
linphoneStringToQString
(
lA
ddress
->
asStringUriOnly
())
:
""
;
}
QString
SipAddressesModel
::
getTransportFromSipAddress
(
const
QString
&
sip
_a
ddress
)
const
{
QString
SipAddressesModel
::
getTransportFromSipAddress
(
const
QString
&
sip
A
ddress
)
const
{
const
shared_ptr
<
const
linphone
::
Address
>
address
=
linphone
::
Factory
::
get
()
->
createAddress
(
::
Utils
::
qStringToLinphoneString
(
sip
_a
ddress
)
::
Utils
::
qStringToLinphoneString
(
sip
A
ddress
)
);
if
(
!
address
)
...
...
@@ -162,20 +162,20 @@ QString SipAddressesModel::getTransportFromSipAddress (const QString &sip_addres
return
QStringLiteral
(
""
);
}
QString
SipAddressesModel
::
addTransportToSipAddress
(
const
QString
&
sip
_a
ddress
,
const
QString
&
transport
)
const
{
QString
SipAddressesModel
::
addTransportToSipAddress
(
const
QString
&
sip
A
ddress
,
const
QString
&
transport
)
const
{
shared_ptr
<
linphone
::
Address
>
address
=
linphone
::
Factory
::
get
()
->
createAddress
(
::
Utils
::
qStringToLinphoneString
(
sip
_a
ddress
)
::
Utils
::
qStringToLinphoneString
(
sip
A
ddress
)
);
if
(
!
address
)
return
""
;
QString
_transport
=
transport
.
toUpper
();
if
(
_transport
==
"TCP"
)
QString
transportStr
=
transport
.
toUpper
();
if
(
transportStr
==
"TCP"
)
address
->
setTransport
(
linphone
::
TransportType
::
TransportTypeTcp
);
else
if
(
_transport
==
"UDP"
)
else
if
(
transportStr
==
"UDP"
)
address
->
setTransport
(
linphone
::
TransportType
::
TransportTypeUdp
);
else
if
(
_transport
==
"TLS"
)
else
if
(
transportStr
==
"TLS"
)
address
->
setTransport
(
linphone
::
TransportType
::
TransportTypeTls
);
else
address
->
setTransport
(
linphone
::
TransportType
::
TransportTypeDtls
);
...
...
@@ -183,9 +183,9 @@ QString SipAddressesModel::addTransportToSipAddress (const QString &sip_address,
return
::
Utils
::
linphoneStringToQString
(
address
->
asString
());
}
bool
SipAddressesModel
::
sipAddressIsValid
(
const
QString
&
sip
_a
ddress
)
const
{
bool
SipAddressesModel
::
sipAddressIsValid
(
const
QString
&
sip
A
ddress
)
const
{
shared_ptr
<
linphone
::
Address
>
address
=
linphone
::
Factory
::
get
()
->
createAddress
(
::
Utils
::
qStringToLinphoneString
(
sip
_a
ddress
)
::
Utils
::
qStringToLinphoneString
(
sip
A
ddress
)
);
return
!!
address
;
...
...
@@ -200,17 +200,17 @@ bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) {
bool
SipAddressesModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
{
int
limit
=
row
+
count
-
1
;
if
(
row
<
0
||
count
<
0
||
limit
>=
m
_sip_a
ddresses
.
count
())
if
(
row
<
0
||
count
<
0
||
limit
>=
m
SipA
ddresses
.
count
())
return
false
;
beginRemoveRows
(
parent
,
row
,
limit
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
const
QVariantMap
*
map
=
m
_r
efs
.
takeAt
(
row
);
QString
sip
_a
ddress
=
(
*
map
)[
"sipAddress"
].
toString
();
const
QVariantMap
*
map
=
m
R
efs
.
takeAt
(
row
);
QString
sip
A
ddress
=
(
*
map
)[
"sipAddress"
].
toString
();
qInfo
()
<<
QStringLiteral
(
"Remove sip address: `%1`."
).
arg
(
sip
_a
ddress
);
m
_sip_addresses
.
remove
(
sip_a
ddress
);
qInfo
()
<<
QStringLiteral
(
"Remove sip address: `%1`."
).
arg
(
sip
A
ddress
);
m
SipAddresses
.
remove
(
sipA
ddress
);
}
endRemoveRows
();
...
...
@@ -221,38 +221,38 @@ bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &paren
// -----------------------------------------------------------------------------
void
SipAddressesModel
::
handleContactAdded
(
ContactModel
*
contact
)
{
for
(
const
auto
&
sip
_a
ddress
:
contact
->
getVcardModel
()
->
getSipAddresses
())
addOrUpdateSipAddress
(
sip
_a
ddress
.
toString
(),
contact
);
for
(
const
auto
&
sip
A
ddress
:
contact
->
getVcardModel
()
->
getSipAddresses
())
addOrUpdateSipAddress
(
sip
A
ddress
.
toString
(),
contact
);
}
void
SipAddressesModel
::
handleContactRemoved
(
const
ContactModel
*
contact
)
{
for
(
const
auto
&
sip
_a
ddress
:
contact
->
getVcardModel
()
->
getSipAddresses
())
removeContactOfSipAddress
(
sip
_a
ddress
.
toString
());
for
(
const
auto
&
sip
A
ddress
:
contact
->
getVcardModel
()
->
getSipAddresses
())
removeContactOfSipAddress
(
sip
A
ddress
.
toString
());
}
void
SipAddressesModel
::
handleSipAddressAdded
(
ContactModel
*
contact
,
const
QString
&
sip
_a
ddress
)
{
ContactModel
*
mapped
_contact
=
mapSipAddressToContact
(
sip_a
ddress
);
if
(
mapped
_c
ontact
)
{
qWarning
()
<<
"Unable to map sip address"
<<
sip
_address
<<
"to"
<<
contact
<<
"- already used by"
<<
mapped_c
ontact
;
void
SipAddressesModel
::
handleSipAddressAdded
(
ContactModel
*
contact
,
const
QString
&
sip
A
ddress
)
{
ContactModel
*
mapped
Contact
=
mapSipAddressToContact
(
sipA
ddress
);
if
(
mapped
C
ontact
)
{
qWarning
()
<<
"Unable to map sip address"
<<
sip
Address
<<
"to"
<<
contact
<<
"- already used by"
<<
mappedC
ontact
;
return
;
}
addOrUpdateSipAddress
(
sip
_a
ddress
,
contact
);
addOrUpdateSipAddress
(
sip
A
ddress
,
contact
);
}
void
SipAddressesModel
::
handleSipAddressRemoved
(
ContactModel
*
contact
,
const
QString
&
sip
_a
ddress
)
{
ContactModel
*
mapped
_contact
=
mapSipAddressToContact
(
sip_a
ddress
);
if
(
contact
!=
mapped
_c
ontact
)
{
qWarning
()
<<
"Unable to remove sip address"
<<
sip
_address
<<
"of"
<<
contact
<<
"- already used by"
<<
mapped_c
ontact
;
void
SipAddressesModel
::
handleSipAddressRemoved
(
ContactModel
*
contact
,
const
QString
&
sip
A
ddress
)
{
ContactModel
*
mapped
Contact
=
mapSipAddressToContact
(
sipA
ddress
);
if
(
contact
!=
mapped
C
ontact
)
{
qWarning
()
<<
"Unable to remove sip address"
<<
sip
Address
<<
"of"
<<
contact
<<
"- already used by"
<<
mappedC
ontact
;
return
;
}
removeContactOfSipAddress
(
sip
_a
ddress
);
removeContactOfSipAddress
(
sip
A
ddress
);
}
void
SipAddressesModel
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
const
QString
&
sip
_a
ddress
=
::
Utils
::
linphoneStringToQString
(
message
->
getFromAddress
()
->
asStringUriOnly
());
addOrUpdateSipAddress
(
sip
_a
ddress
,
message
);
const
QString
&
sip
A
ddress
=
::
Utils
::
linphoneStringToQString
(
message
->
getFromAddress
()
->
asStringUriOnly
());
addOrUpdateSipAddress
(
sip
A
ddress
,
message
);
}
void
SipAddressesModel
::
handleCallStateChanged
(
...
...
@@ -270,12 +270,12 @@ void SipAddressesModel::handleCallStateChanged (
}
void
SipAddressesModel
::
handlePresenceReceived
(
const
QString
&
sip
_a
ddress
,
const
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence
_m
odel
const
QString
&
sip
A
ddress
,
const
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence
M
odel
)
{
Presence
::
PresenceStatus
status
;
switch
(
presence
_m
odel
->
getConsolidatedPresence
())
{
switch
(
presence
M
odel
->
getConsolidatedPresence
())
{
case
linphone
:
:
ConsolidatedPresenceOnline
:
status
=
Presence
::
PresenceStatus
::
Online
;
break
;
...
...
@@ -290,27 +290,27 @@ void SipAddressesModel::handlePresenceReceived (
break
;
}
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
!=
m
_sip_a
ddresses
.
end
())
{
qInfo
()
<<
QStringLiteral
(
"Update presence of `%1`: %2."
).
arg
(
sip
_a
ddress
).
arg
(
status
);
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
!=
m
SipA
ddresses
.
end
())
{
qInfo
()
<<
QStringLiteral
(
"Update presence of `%1`: %2."
).
arg
(
sip
A
ddress
).
arg
(
status
);
(
*
it
)[
"presenceStatus"
]
=
status
;
int
row
=
m
_r
efs
.
indexOf
(
&
(
*
it
));
int
row
=
m
R
efs
.
indexOf
(
&
(
*
it
));
Q_ASSERT
(
row
!=
-
1
);
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
0
));
}
updateObservers
(
sip
_a
ddress
,
status
);
updateObservers
(
sip
A
ddress
,
status
);
}
void
SipAddressesModel
::
handleAllEntriesRemoved
(
const
QString
&
sip
_a
ddress
)
{
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
==
m
_sip_a
ddresses
.
end
())
{
qWarning
()
<<
QStringLiteral
(
"Unable to found sip address: `%1`."
).
arg
(
sip
_a
ddress
);
void
SipAddressesModel
::
handleAllEntriesRemoved
(
const
QString
&
sip
A
ddress
)
{
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
==
m
SipA
ddresses
.
end
())
{
qWarning
()
<<
QStringLiteral
(
"Unable to found sip address: `%1`."
).
arg
(
sip
A
ddress
);
return
;
}
int
row
=
m
_r
efs
.
indexOf
(
&
(
*
it
));
int
row
=
m
R
efs
.
indexOf
(
&
(
*
it
));
Q_ASSERT
(
row
!=
-
1
);
// No history, no contact => Remove sip address from list.
...
...
@@ -331,17 +331,17 @@ void SipAddressesModel::handleMessageSent (const shared_ptr<linphone::ChatMessag
);
}
void
SipAddressesModel
::
handleMessagesCountReset
(
const
QString
&
sip
_a
ddress
)
{
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
!=
m
_sip_a
ddresses
.
end
())
{
void
SipAddressesModel
::
handleMessagesCountReset
(
const
QString
&
sip
A
ddress
)
{
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
!=
m
SipA
ddresses
.
end
())
{
(
*
it
)[
"unreadMessagesCount"
]
=
0
;
int
row
=
m
_r
efs
.
indexOf
(
&
(
*
it
));
int
row
=
m
R
efs
.
indexOf
(
&
(
*
it
));
Q_ASSERT
(
row
!=
-
1
);
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
0
));
}
updateObservers
(
sip
_a
ddress
,
0
);
updateObservers
(
sip
A
ddress
,
0
);
}
// -----------------------------------------------------------------------------
...
...
@@ -352,11 +352,11 @@ void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, ContactModel *c
}
void
SipAddressesModel
::
addOrUpdateSipAddress
(
QVariantMap
&
map
,
const
shared_ptr
<
linphone
::
Call
>
&
call
)
{
const
shared_ptr
<
linphone
::
CallLog
>
call
_l
og
=
call
->
getCallLog
();
const
shared_ptr
<
linphone
::
CallLog
>
call
L
og
=
call
->
getCallLog
();
map
[
"timestamp"
]
=
call
_l
og
->
getStatus
()
==
linphone
::
CallStatus
::
CallStatusSuccess
?
QDateTime
::
fromMSecsSinceEpoch
((
call
_log
->
getStartDate
()
+
call_l
og
->
getDuration
())
*
1000
)
:
QDateTime
::
fromMSecsSinceEpoch
(
call
_l
og
->
getStartDate
()
*
1000
);
map
[
"timestamp"
]
=
call
L
og
->
getStatus
()
==
linphone
::
CallStatus
::
CallStatusSuccess
?
QDateTime
::
fromMSecsSinceEpoch
((
call
Log
->
getStartDate
()
+
callL
og
->
getDuration
())
*
1000
)
:
QDateTime
::
fromMSecsSinceEpoch
(
call
L
og
->
getStartDate
()
*
1000
);
}
void
SipAddressesModel
::
addOrUpdateSipAddress
(
QVariantMap
&
map
,
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
...
...
@@ -369,12 +369,12 @@ void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_pt
}
template
<
typename
T
>
void
SipAddressesModel
::
addOrUpdateSipAddress
(
const
QString
&
sip
_a
ddress
,
T
data
)
{
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
!=
m
_sip_a
ddresses
.
end
())
{
void
SipAddressesModel
::
addOrUpdateSipAddress
(
const
QString
&
sip
A
ddress
,
T
data
)
{
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
!=
m
SipA
ddresses
.
end
())
{
addOrUpdateSipAddress
(
*
it
,
data
);
int
row
=
m
_r
efs
.
indexOf
(
&
(
*
it
));
int
row
=
m
R
efs
.
indexOf
(
&
(
*
it
));
Q_ASSERT
(
row
!=
-
1
);
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
0
));
...
...
@@ -382,36 +382,36 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sip_address, T dat
}
QVariantMap
map
;
map
[
"sipAddress"
]
=
sip
_a
ddress
;
map
[
"sipAddress"
]
=
sip
A
ddress
;
addOrUpdateSipAddress
(
map
,
data
);
int
row
=
m
_r
efs
.
count
();
int
row
=
m
R
efs
.
count
();
beginInsertRows
(
QModelIndex
(),
row
,
row
);
qInfo
()
<<
QStringLiteral
(
"Add sip address: `%1`."
).
arg
(
sip
_a
ddress
);
qInfo
()
<<
QStringLiteral
(
"Add sip address: `%1`."
).
arg
(
sip
A
ddress
);
m
_sip_addresses
[
sip_a
ddress
]
=
map
;
m
_refs
<<
&
m_sip_addresses
[
sip_a
ddress
];
m
SipAddresses
[
sipA
ddress
]
=
map
;
m
Refs
<<
&
mSipAddresses
[
sipA
ddress
];
endInsertRows
();
}
// -----------------------------------------------------------------------------
void
SipAddressesModel
::
removeContactOfSipAddress
(
const
QString
&
sip
_a
ddress
)
{
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
==
m
_sip_a
ddresses
.
end
())
{
qWarning
()
<<
QStringLiteral
(
"Unable to remove unavailable sip address: `%1`."
).
arg
(
sip
_a
ddress
);
void
SipAddressesModel
::
removeContactOfSipAddress
(
const
QString
&
sip
A
ddress
)
{
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
==
m
SipA
ddresses
.
end
())
{
qWarning
()
<<
QStringLiteral
(
"Unable to remove unavailable sip address: `%1`."
).
arg
(
sip
A
ddress
);
return
;
}
updateObservers
(
sip
_a
ddress
,
nullptr
);
updateObservers
(
sip
A
ddress
,
nullptr
);
if
(
it
->
remove
(
"contact"
)
==
0
)
qWarning
()
<<
QStringLiteral
(
"`contact` field is empty on sip address: `%1`."
).
arg
(
sip
_a
ddress
);
qWarning
()
<<
QStringLiteral
(
"`contact` field is empty on sip address: `%1`."
).
arg
(
sip
A
ddress
);
int
row
=
m
_r
efs
.
indexOf
(
&
(
*
it
));
int
row
=
m
R
efs
.
indexOf
(
&
(
*
it
));
Q_ASSERT
(
row
!=
-
1
);
// History exists, signal changes.
...
...
@@ -428,69 +428,69 @@ void SipAddressesModel::initSipAddresses () {
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
// Get sip addresses from chatrooms.
for
(
const
auto
&
chat
_r
oom
:
core
->
getChatRooms
())
{
list
<
shared_ptr
<
linphone
::
ChatMessage
>
>
history
=
chat
_r
oom
->
getHistory
(
0
);
for
(
const
auto
&
chat
R
oom
:
core
->
getChatRooms
())
{
list
<
shared_ptr
<
linphone
::
ChatMessage
>
>
history
=
chat
R
oom
->
getHistory
(
0
);
if
(
history
.
size
()
==
0
)
continue
;
QString
sip
_address
=
::
Utils
::
linphoneStringToQString
(
chat_r
oom
->
getPeerAddress
()
->
asStringUriOnly
());
QString
sip
Address
=
::
Utils
::
linphoneStringToQString
(
chatR
oom
->
getPeerAddress
()
->
asStringUriOnly
());
QVariantMap
map
;
map
[
"sipAddress"
]
=
sip
_a
ddress
;
map
[
"sipAddress"
]
=
sip
A
ddress
;
map
[
"timestamp"
]
=
QDateTime
::
fromMSecsSinceEpoch
(
history
.
back
()
->
getTime
()
*
1000
);
map
[
"unreadMessagesCount"
]
=
chat
_r
oom
->
getUnreadMessagesCount
();
map
[
"unreadMessagesCount"
]
=
chat
R
oom
->
getUnreadMessagesCount
();
m
_sip_addresses
[
sip_a
ddress
]
=
map
;
m
SipAddresses
[
sipA
ddress
]
=
map
;
}
// Get sip addresses from calls.
QSet
<
QString
>
address
_d
one
;
for
(
const
auto
&
call
_l
og
:
core
->
getCallLogs
())
{
const
QString
&
sip
_address
=
::
Utils
::
linphoneStringToQString
(
call_l
og
->
getRemoteAddress
()
->
asStringUriOnly
());
QSet
<
QString
>
address
D
one
;
for
(
const
auto
&
call
L
og
:
core
->
getCallLogs
())
{
const
QString
&
sip
Address
=
::
Utils
::
linphoneStringToQString
(
callL
og
->
getRemoteAddress
()
->
asStringUriOnly
());
if
(
address
_done
.
contains
(
sip_a
ddress
))
if
(
address
Done
.
contains
(
sipA
ddress
))
continue
;
// Already used.
if
(
call
_l
og
->
getStatus
()
==
linphone
::
CallStatusAborted
)
if
(
call
L
og
->
getStatus
()
==
linphone
::
CallStatusAborted
)
continue
;
// Ignore aborted calls.
address
_done
<<
sip_a
ddress
;
address
Done
<<
sipA
ddress
;
QVariantMap
map
;
map
[
"sipAddress"
]
=
sip
_a
ddress
;
map
[
"sipAddress"
]
=
sip
A
ddress
;
// The duration can be wrong if status is not success.
map
[
"timestamp"
]
=
call
_l
og
->
getStatus
()
==
linphone
::
CallStatus
::
CallStatusSuccess
?
QDateTime
::
fromMSecsSinceEpoch
((
call
_log
->
getStartDate
()
+
call_l
og
->
getDuration
())
*
1000
)
:
QDateTime
::
fromMSecsSinceEpoch
(
call
_l
og
->
getStartDate
()
*
1000
);
map
[
"timestamp"
]
=
call
L
og
->
getStatus
()
==
linphone
::
CallStatus
::
CallStatusSuccess
?
QDateTime
::
fromMSecsSinceEpoch
((
call
Log
->
getStartDate
()
+
callL
og
->
getDuration
())
*
1000
)
:
QDateTime
::
fromMSecsSinceEpoch
(
call
L
og
->
getStartDate
()
*
1000
);
auto
it
=
m
_sip_addresses
.
find
(
sip_a
ddress
);
if
(
it
==
m
_sip_a
ddresses
.
end
()
||
map
[
"timestamp"
]
>
(
*
it
)[
"timestamp"
])
m
_sip_addresses
[
sip_a
ddress
]
=
map
;
auto
it
=
m
SipAddresses
.
find
(
sipA
ddress
);
if
(
it
==
m
SipA
ddresses
.
end
()
||
map
[
"timestamp"
]
>
(
*
it
)[
"timestamp"
])
m
SipAddresses
[
sipA
ddress
]
=
map
;
}
for
(
const
auto
&
map
:
m
_sip_a
ddresses
)
m
_r
efs
<<
&
map
;
for
(
const
auto
&
map
:
m
SipA
ddresses
)
m
R
efs
<<
&
map
;
// Get sip addresses from contacts.
for
(
auto
&
contact
:
CoreManager
::
getInstance
()
->
getContactsListModel
()
->
m
_l
ist
)
for
(
auto
&
contact
:
CoreManager
::
getInstance
()
->
getContactsListModel
()
->
m
L
ist
)
handleContactAdded
(
contact
);
}
// -----------------------------------------------------------------------------
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip
_a
ddress
,
ContactModel
*
contact
)
{
for
(
auto
&
observer
:
m
_observers
.
values
(
sip_a
ddress
))
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip
A
ddress
,
ContactModel
*
contact
)
{
for
(
auto
&
observer
:
m
Observers
.
values
(
sipA
ddress
))
observer
->
setContact
(
contact
);
}
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip
_address
,
const
Presence
::
PresenceStatus
&
presence_s
tatus
)
{
for
(
auto
&
observer
:
m
_observers
.
values
(
sip_a
ddress
))
observer
->
setPresenceStatus
(
presence
_s
tatus
);
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip
Address
,
const
Presence
::
PresenceStatus
&
presenceS
tatus
)
{
for
(
auto
&
observer
:
m
Observers
.
values
(
sipA
ddress
))
observer
->
setPresenceStatus
(
presence
S
tatus
);
}
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip
_address
,
int
messages_c
ount
)
{
for
(
auto
&
observer
:
m
_observers
.
values
(
sip_a
ddress
))
observer
->
setUnreadMessagesCount
(
messages
_c
ount
);
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip
Address
,
int
messagesC
ount
)
{
for
(
auto
&
observer
:
m
Observers
.
values
(
sipA
ddress
))
observer
->
setUnreadMessagesCount
(
messages
C
ount
);
}
linphone-desktop/src/components/sip-addresses/SipAddressesModel.hpp
View file @
d8ff1b14
...
...
@@ -45,20 +45,20 @@ public:
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
void
connectToChatModel
(
ChatModel
*
chat
_m
odel
);
void
connectToChatModel
(
ChatModel
*
chat
M
odel
);
Q_INVOKABLE
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sip
_a
ddress
)
const
;
Q_INVOKABLE
SipAddressObserver
*
getSipAddressObserver
(
const
QString
&
sip
_a
ddress
);
Q_INVOKABLE
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sip
A
ddress
)
const
;
Q_INVOKABLE
SipAddressObserver
*
getSipAddressObserver
(
const
QString
&
sip
A
ddress
);
// ---------------------------------------------------------------------------
// Sip addresses helpers.
// ---------------------------------------------------------------------------
Q_INVOKABLE
QString
interpretUrl
(
const
QString
&
sip
_a
ddress
)
const
;
Q_INVOKABLE
QString
interpretUrl
(
const
QString
&
sip
A
ddress
)
const
;
Q_INVOKABLE
QString
getTransportFromSipAddress
(
const
QString
&
sip
_a
ddress
)
const
;
Q_INVOKABLE
QString
addTransportToSipAddress
(
const
QString
&
sip
_a
ddress
,
const
QString
&
transport
)
const
;
Q_INVOKABLE
bool
sipAddressIsValid
(
const
QString
&
sip
_a
ddress
)
const
;
Q_INVOKABLE
QString
getTransportFromSipAddress
(
const
QString
&
sip
A
ddress
)
const
;
Q_INVOKABLE
QString
addTransportToSipAddress
(
const
QString
&
sip
A
ddress
,
const
QString
&
transport
)
const
;
Q_INVOKABLE
bool
sipAddressIsValid
(
const
QString
&
sip
A
ddress
)
const
;
// ---------------------------------------------------------------------------
...
...
@@ -71,16 +71,16 @@ private:
void
handleContactAdded
(
ContactModel
*
contact
);
void
handleContactRemoved
(
const
ContactModel
*
contact
);
void
handleSipAddressAdded
(
ContactModel
*
contact
,
const
QString
&
sip
_a
ddress
);
void
handleSipAddressRemoved
(
ContactModel
*
contact
,
const
QString
&
sip
_a
ddress
);
void
handleSipAddressAdded
(
ContactModel
*
contact
,
const
QString
&
sip
A
ddress
);
void
handleSipAddressRemoved
(
ContactModel
*
contact
,
const
QString
&
sip
A
ddress
);
void
handleMessageReceived
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
handleCallStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
);
void
handlePresenceReceived
(
const
QString
&
sip
_address
,
const
std
::
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presence_m
odel
);
void
handlePresenceReceived
(
const
QString
&
sip
Address
,
const
std
::
shared_ptr
<
const
linphone
::
PresenceModel
>
&
presenceM
odel
);
void
handleAllEntriesRemoved
(
const
QString
&
sip
_a
ddress
);
void
handleAllEntriesRemoved
(
const
QString
&
sip
A
ddress
);
void
handleMessageSent
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
handleMessagesCountReset
(
const
QString
&
sip
_a
ddress
);
void
handleMessagesCountReset
(
const
QString
&
sip
A
ddress
);
// ---------------------------------------------------------------------------
...
...
@@ -91,24 +91,24 @@ private:
void
addOrUpdateSipAddress
(
QVariantMap
&
map
,
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
template
<
class
T
>
void
addOrUpdateSipAddress
(
const
QString
&
sip
_a
ddress
,
T
data
);
void
addOrUpdateSipAddress
(
const
QString
&
sip
A
ddress
,
T
data
);
// ---------------------------------------------------------------------------
void
removeContactOfSipAddress
(
const
QString
&
sip
_a
ddress
);
void
removeContactOfSipAddress
(
const
QString
&
sip
A
ddress
);
void
initSipAddresses
();
void
updateObservers
(
const
QString
&
sip
_a
ddress
,
ContactModel
*
contact
);
void
updateObservers
(
const
QString
&
sip
_address
,
const
Presence
::
PresenceStatus
&
presence_s
tatus
);
void
updateObservers
(
const
QString
&
sip
_address
,
int
messages_c
ount
);
void
updateObservers
(
const
QString
&
sip
A
ddress
,
ContactModel
*
contact
);
void
updateObservers
(
const
QString
&
sip
Address
,
const
Presence
::
PresenceStatus
&
presenceS
tatus
);
void
updateObservers
(
const
QString
&
sip
Address
,
int
messagesC
ount
);
QHash
<
QString
,
QVariantMap
>
m
_sip_a
ddresses
;
QList
<
const
QVariantMap
*>
m
_r
efs
;
QHash
<
QString
,
QVariantMap
>
m
SipA
ddresses
;
QList
<
const
QVariantMap
*>
m
R
efs
;
QMultiHash
<
QString
,
SipAddressObserver
*>
m
_o
bservers
;
QMultiHash
<
QString
,
SipAddressObserver
*>
m
O
bservers
;
std
::
shared_ptr
<
CoreHandlers
>
m
_core_h
andlers
;
std
::
shared_ptr
<
CoreHandlers
>
m
CoreH
andlers
;
};
#endif // SIP_ADDRESSES_MODEL_H_
linphone-desktop/src/components/smart-search-bar/SmartSearchBarModel.cpp
View file @
d8ff1b14
...
...
@@ -32,7 +32,7 @@
// =============================================================================
const
QRegExp
SmartSearchBarModel
::
m
_search_s
eparators
(
"^[^_.-;@ ][_.-;@ ]"
);
const
QRegExp
SmartSearchBarModel
::
m
SearchS
eparators
(
"^[^_.-;@ ][_.-;@ ]"
);
// -----------------------------------------------------------------------------
...
...
@@ -50,54 +50,54 @@ QHash<int, QByteArray> SmartSearchBarModel::roleNames () const {
// -----------------------------------------------------------------------------
void
SmartSearchBarModel
::
setFilter
(
const
QString
&
pattern
)
{
m
_f
ilter
=
pattern
;
m
F
ilter
=
pattern
;
invalidate
();
}
// -----------------------------------------------------------------------------
bool
SmartSearchBarModel
::
filterAcceptsRow
(
int
source
_row
,
const
QModelIndex
&
source_p
arent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source
_row
,
0
,
source_p
arent
);
bool
SmartSearchBarModel
::
filterAcceptsRow
(
int
source
Row
,
const
QModelIndex
&
sourceP
arent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source
Row
,
0
,
sourceP
arent
);
return
computeEntryWeight
(
index
.
data
().
toMap
())
>
0
;
}
bool
SmartSearchBarModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
const
QVariantMap
&
map
_a
=
sourceModel
()
->
data
(
left
).
toMap
();
const
QVariantMap
&
map
_b
=
sourceModel
()
->
data
(
right
).
toMap
();
const
QVariantMap
&
map
A
=
sourceModel
()
->
data
(
left
).
toMap
();
const
QVariantMap
&
map
B
=
sourceModel
()
->
data
(
right
).
toMap
();
const
QString
&
sip
_address_a
=
map_a
[
"sipAddress"
].
toString
();
const
QString
&
sip
_address_b
=
map_b
[
"sipAddress"
].
toString
();
const
QString
&
sip
AddressA
=
mapA
[
"sipAddress"
].
toString
();
const
QString
&
sip
AddressB
=
mapB
[
"sipAddress"
].
toString
();
// TODO: Use a cache, do not compute the same value as `filterAcceptsRow`.
int
weight
_a
=
computeEntryWeight
(
map_a
);
int
weight
_b
=
computeEntryWeight
(
map_b
);
int
weight
A
=
computeEntryWeight
(
mapA
);
int
weight
B
=
computeEntryWeight
(
mapB
);
// 1. Not the same weight.
if
(
weight
_a
!=
weight_b
)
return
weight
_a
>
weight_b
;
if
(
weight
A
!=
weightB
)
return
weight
A
>
weightB
;
const
ContactModel
*
contact
_a
=
map_a
.
value
(
"contact"
).
value
<
ContactModel
*>
();
const
ContactModel
*
contact
_b
=
map_b
.
value
(
"contact"
).
value
<
ContactModel
*>
();
const
ContactModel
*
contact
A
=
mapA
.
value
(
"contact"
).
value
<
ContactModel
*>
();
const
ContactModel
*
contact
B
=
mapB
.
value
(
"contact"
).
value
<
ContactModel
*>
();
// 2. No contacts.
if
(
!
contact
_a
&&
!
contact_b
)
return
sip
_address_a
<=
sip_address_b
;
if
(
!
contact
A
&&
!
contactB
)
return
sip
AddressA
<=
sipAddressB
;
// 3. No contact for a or b.
if
(
!
contact
_a
||
!
contact_b
)
return
!!
contact
_a
;
if
(
!
contact
A
||
!
contactB
)
return
!!
contact
A
;
// 4. Same contact (address).
if
(
contact
_a
==
contact_b
)
return
sip
_address_a
<=
sip_address_b
;
if
(
contact
A
==
contactB
)
return
sip
AddressA
<=
sipAddressB
;
// 5. Not the same contact name.
int
diff
=
contact
_a
->
m_linphone_friend
->
getName
().
compare
(
contact_b
->
m_linphone_f
riend
->
getName
());
int
diff
=
contact
A
->
mLinphoneFriend
->
getName
().
compare
(
contactB
->
mLinphoneF
riend
->
getName
());
if
(
diff
)
return
diff
<=
0
;
// 6. Same contact name, so compare sip addresses.
return
sip
_address_a
<=
sip_address_b
;
return
sip
AddressA
<=
sipAddressB
;
}
int
SmartSearchBarModel
::
computeEntryWeight
(
const
QVariantMap
&
entry
)
const
{
...
...
@@ -114,10 +114,10 @@ int SmartSearchBarModel::computeStringWeight (const QString &string) const {
int
index
=
-
1
;
int
offset
=
-
1
;
while
((
index
=
string
.
indexOf
(
m
_f
ilter
,
index
+
1
,
Qt
::
CaseInsensitive
))
!=
-
1
)
{
int
tmp
_offset
=
index
-
string
.
lastIndexOf
(
m_search_s
eparators
,
index
)
-
1
;
if
((
tmp
_offset
!=
-
1
&&
tmp_o
ffset
<
offset
)
||
offset
==
-
1
)
if
((
offset
=
tmp
_o
ffset
)
==
0
)
break
;
while
((
index
=
string
.
indexOf
(
m
F
ilter
,
index
+
1
,
Qt
::
CaseInsensitive
))
!=
-
1
)
{
int
tmp
Offset
=
index
-
string
.
lastIndexOf
(
mSearchS
eparators
,
index
)
-
1
;
if
((
tmp
Offset
!=
-
1
&&
tmpO
ffset
<
offset
)
||
offset
==
-
1
)
if
((
offset
=
tmp
O
ffset
)
==
0
)
break
;
}
switch
(
offset
)
{
...
...
linphone-desktop/src/components/smart-search-bar/SmartSearchBarModel.hpp
View file @
d8ff1b14
...
...
@@ -39,15 +39,15 @@ public:
Q_INVOKABLE
void
setFilter
(
const
QString
&
pattern
);
protected:
bool
filterAcceptsRow
(
int
source
_row
,
const
QModelIndex
&
source_p
arent
)
const
override
;
bool
filterAcceptsRow
(
int
source
Row
,
const
QModelIndex
&
sourceP
arent
)
const
override
;
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
override
;
private:
int
computeEntryWeight
(
const
QVariantMap
&
entry
)
const
;
int
computeStringWeight
(
const
QString
&
string
)
const
;
QString
m
_f
ilter
;
static
const
QRegExp
m
_search_s
eparators
;
QString
m
F
ilter
;
static
const
QRegExp
m
SearchS
eparators
;
};
#endif // SMART_SEARCH_BAR_MODEL_H_
linphone-desktop/src/components/timeline/TimelineModel.cpp
View file @
d8ff1b14
...
...
@@ -41,8 +41,8 @@ QHash<int, QByteArray> TimelineModel::roleNames () const {
// -----------------------------------------------------------------------------
bool
TimelineModel
::
filterAcceptsRow
(
int
source
_row
,
const
QModelIndex
&
source_p
arent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source
_row
,
0
,
source_p
arent
);
bool
TimelineModel
::
filterAcceptsRow
(
int
source
Row
,
const
QModelIndex
&
sourceP
arent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source
Row
,
0
,
sourceP
arent
);
return
index
.
data
().
toMap
().
contains
(
"timestamp"
);
}
...
...
linphone-desktop/src/components/timeline/TimelineModel.hpp
View file @
d8ff1b14
...
...
@@ -37,7 +37,7 @@ public:
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
protected:
bool
filterAcceptsRow
(
int
source
_row
,
const
QModelIndex
&
source_p
arent
)
const
override
;
bool
filterAcceptsRow
(
int
source
Row
,
const
QModelIndex
&
sourceP
arent
)
const
override
;
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
override
;
};
...
...
Write
Preview
Markdown
is supported
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