Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-client-windows
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-client-windows
Commits
1cf20c77
Commit
1cf20c77
authored
6 years ago
by
Andreas Traczyk
Browse files
Options
Downloads
Patches
Plain Diff
smartlist/callview: handle priority interactions
Change-Id: Ib8bb67c38fc9cd0231acd50cf204983c3272c9fd
parent
d5424fdf
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
callwidget.cpp
+88
-58
88 additions, 58 deletions
callwidget.cpp
callwidget.h
+4
-2
4 additions, 2 deletions
callwidget.h
utils.cpp
+35
-7
35 additions, 7 deletions
utils.cpp
utils.h
+2
-0
2 additions, 0 deletions
utils.h
with
129 additions
and
67 deletions
callwidget.cpp
+
88
−
58
View file @
1cf20c77
...
...
@@ -302,12 +302,11 @@ CallWidget::onIncomingMessage(const std::string& convUid,
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
convModel
->
clearUnreadInteractions
(
convUid
);
auto
currentConversation
=
Utils
::
getConversationFromUid
(
convUid
,
*
convModel
);
if
(
currentConversation
==
convModel
->
allFilteredConversations
().
end
())
{
return
;
}
auto
convInfo
=
Utils
::
getSelectedConversation
();
if
(
!
convInfo
.
uid
.
empty
())
{
ui
->
messageView
->
printNewInteraction
(
*
convModel
,
interactionId
,
interaction
);
}
}
void
CallWidget
::
setupSmartListContextMenu
(
const
QPoint
&
pos
)
...
...
@@ -447,33 +446,35 @@ CallWidget::on_smartList_clicked(const QModelIndex& index)
void
CallWidget
::
on_acceptButton_clicked
()
{
auto
conv
Model
=
LRCInstance
::
getCurrent
Conversation
Model
();
auto
callModel
=
LRCInstance
::
getCurrentCallModel
();
auto
conversation
=
Utils
::
getConversationFromUid
(
LRCInstance
::
getSelectedConvUid
(),
*
convModel
);
callModel
->
accept
(
conversation
->
callId
);
auto
conv
Info
=
Utils
::
getSelected
Conversation
();
if
(
!
convInfo
.
uid
.
empty
())
{
LRCInstance
::
getCurrentCallModel
()
->
accept
(
convInfo
.
callId
);
}
}
void
CallWidget
::
on_refuseButton_clicked
()
{
auto
conv
Model
=
LRCInstance
::
getCurrent
Conversation
Model
();
auto
conversation
=
Utils
::
getConversationFromUid
(
LRCInstance
::
getSelectedConvUid
(),
*
convModel
);
LRCInstance
::
getCurrentCallModel
()
->
hangUp
(
conv
ersation
->
callId
);
auto
conv
Info
=
Utils
::
getSelected
Conversation
();
if
(
!
convInfo
.
uid
.
empty
())
{
LRCInstance
::
getCurrentCallModel
()
->
hangUp
(
conv
Info
.
callId
);
showConversationView
();
}
}
void
CallWidget
::
on_cancelButton_clicked
()
{
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
auto
conversation
=
Utils
::
getConversationFromUid
(
LRCInstance
::
getSelectedConvUid
(),
*
convModel
);
LRCInstance
::
getCurrentCallModel
()
->
hangUp
(
conversation
->
callId
);
showConversationView
();
on_refuseButton_clicked
();
}
void
CallWidget
::
showConversationView
()
{
if
(
LRCInstance
::
getSelectedConvUid
().
empty
())
{
backToWelcomePage
();
return
;
}
ui
->
stackedWidget
->
setCurrentWidget
(
ui
->
mainActivityWidget
);
ui
->
messageView
->
setFocus
();
if
(
ui
->
messagesWidget
->
isHidden
())
{
...
...
@@ -481,30 +482,31 @@ CallWidget::showConversationView()
}
}
void
bool
CallWidget
::
selectSmartlistItem
(
const
std
::
string
&
convUid
)
{
if
(
convUid
.
empty
()
||
!
ui
->
smartList
->
selectionModel
())
return
;
return
false
;
ui
->
smartList
->
selectionModel
()
->
setCurrentIndex
(
QModelIndex
(),
QItemSelectionModel
::
Deselect
);
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
auto
conversation
=
Utils
::
getConversationFromUid
(
convUid
,
*
convModel
);
if
(
conversation
==
convModel
->
allFilteredConversations
().
end
())
{
return
;
return
false
;
}
auto
contactURI
=
QString
::
fromStdString
((
*
conversation
).
participants
[
0
]);
if
(
contactURI
.
isEmpty
()
||
convModel
->
owner
.
contactModel
->
getContact
(
contactURI
.
toStdString
()).
profileInfo
.
type
==
lrc
::
api
::
profile
::
Type
::
TEMPORARY
)
{
return
;
return
false
;
}
for
(
int
row
=
0
;
row
<
smartListModel_
->
rowCount
();
row
++
)
{
QModelIndex
index
=
smartListModel_
->
index
(
row
);
auto
indexContactURI
=
index
.
data
(
SmartListModel
::
Role
::
URI
).
value
<
QString
>
();
if
(
indexContactURI
==
contactURI
)
{
ui
->
smartList
->
selectionModel
()
->
setCurrentIndex
(
index
,
QItemSelectionModel
::
ClearAndSelect
);
return
;
return
true
;
}
}
return
false
;
}
void
...
...
@@ -513,6 +515,8 @@ CallWidget::on_smartList_doubleClicked(const QModelIndex& index)
if
(
!
index
.
isValid
())
return
;
selectConversation
(
index
);
LRCInstance
::
getCurrentConversationModel
()
->
placeCall
(
LRCInstance
::
getSelectedConvUid
());
ui
->
callingPhoto
->
setPixmap
(
QPixmap
::
fromImage
(
imageForConv
(
LRCInstance
::
getSelectedConvUid
())));
...
...
@@ -673,6 +677,7 @@ void CallWidget::slotShowIncomingCallView(const std::string& accountId,
auto
call
=
callModel
->
getCall
(
convInfo
.
callId
);
auto
isCallSelected
=
LRCInstance
::
getSelectedConvUid
()
==
convInfo
.
uid
;
auto
itemInCurrentFilter
=
false
;
if
(
call
.
isOutgoing
)
{
if
(
isCallSelected
)
{
miniSpinner_
->
start
();
...
...
@@ -686,19 +691,23 @@ void CallWidget::slotShowIncomingCallView(const std::string& accountId,
Utils
::
showSystemNotification
(
this
,
QString
(
tr
(
"Call incoming from %1"
)).
arg
(
QString
::
fromStdString
(
formattedName
)));
}
selectSmartlistItem
(
convInfo
.
uid
);
auto
selectedAccountId
=
LRCInstance
::
getCurrentAccountInfo
().
id
;
auto
accountProperties
=
LRCInstance
::
accountModel
().
getAccountConfig
(
selectedAccountId
);
if
(
!
isCallSelected
)
itemInCurrentFilter
=
selectSmartlistItem
(
convInfo
.
uid
);
if
(
accountProperties
.
autoAnswer
)
{
ui
->
callStackWidget
->
setCurrentWidget
(
ui
->
videoPage
);
setCallPanelVisibility
(
true
);
}
else
if
(
isCallSelected
)
{
}
else
if
(
isCallSelected
||
!
itemInCurrentFilter
)
{
ui
->
callStackWidget
->
setCurrentWidget
(
ui
->
incomingCallPage
);
setCallPanelVisibility
(
true
);
}
setCallPanelVisibility
(
true
);
}
if
(
ui
->
messagesWidget
->
isHidden
())
{
if
(
!
itemInCurrentFilter
&&
!
isCallSelected
)
{
ui
->
smartList
->
selectionModel
()
->
clear
();
LRCInstance
::
setSelectedConvId
(
convInfo
.
uid
);
showChatView
(
accountId
,
convInfo
);
}
else
if
(
ui
->
messagesWidget
->
isHidden
())
{
ui
->
messagesWidget
->
show
();
}
...
...
@@ -746,11 +755,8 @@ CallWidget::slotToggleFullScreenClicked()
void
CallWidget
::
slotVideoViewDestroyed
(
const
std
::
string
&
callid
)
{
auto
convUid
=
LRCInstance
::
getSelectedConvUid
();
auto
currentConversationModel
=
LRCInstance
::
getCurrentConversationModel
();
auto
conversation
=
Utils
::
getConversationFromUid
(
convUid
,
*
currentConversationModel
);
if
(
conversation
!=
currentConversationModel
->
allFilteredConversations
().
end
()
&&
callid
!=
conversation
->
callId
)
{
auto
conversation
=
Utils
::
getSelectedConversation
();
if
(
callid
!=
conversation
.
uid
)
{
return
;
}
if
(
ui
->
mainActivityWidget
->
isFullScreen
())
{
...
...
@@ -816,11 +822,30 @@ void CallWidget::setConversationFilter(const QString & filter)
}
void
CallWidget
::
show
IMOutOfCall
(
const
QModelIndex
&
nodeIdx
)
CallWidget
::
show
ChatView
(
const
QModelIndex
&
nodeIdx
)
{
QString
displayName
=
nodeIdx
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
DisplayName
)).
toString
();
QString
displayId
=
nodeIdx
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
DisplayID
)).
toString
();
QString
contactURI
=
nodeIdx
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
URI
)).
toString
();
auto
convUid
=
nodeIdx
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
UID
)).
toString
().
toStdString
();
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
auto
convInfo
=
Utils
::
getConversationFromUid
(
convUid
,
*
convModel
);
if
(
convInfo
!=
convModel
->
allFilteredConversations
().
end
())
setupChatView
(
*
convInfo
);
}
void
CallWidget
::
showChatView
(
const
std
::
string
&
accountId
,
const
lrc
::
api
::
conversation
::
Info
&
convInfo
)
{
Q_UNUSED
(
accountId
);
setupChatView
(
convInfo
);
}
void
CallWidget
::
setupChatView
(
const
lrc
::
api
::
conversation
::
Info
&
convInfo
)
{
auto
&
accInfo
=
LRCInstance
::
getCurrentAccountInfo
();
auto
&
contact
=
accInfo
.
contactModel
->
getContact
(
convInfo
.
participants
.
at
(
0
));
QString
displayName
=
QString
::
fromStdString
(
Utils
::
bestNameForContact
(
contact
));
QString
displayId
=
QString
::
fromStdString
(
Utils
::
bestIdForContact
(
contact
));
QString
contactURI
=
QString
::
fromStdString
(
convInfo
.
participants
.
at
(
0
));
bool
isContact
=
false
;
auto
selectedAccountId
=
LRCInstance
::
getCurrAccId
();
...
...
@@ -829,8 +854,7 @@ CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
try
{
accountInfo
.
contactModel
->
getContact
(
contactURI
.
toStdString
());
isContact
=
true
;
}
catch
(...)
{}
}
catch
(...)
{}
ui
->
imNameLabel
->
setText
(
QString
(
tr
(
"%1"
,
"%1 is the contact username"
))
.
arg
(
displayName
));
...
...
@@ -848,22 +872,21 @@ CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
ui
->
messageView
->
setMessagesVisibility
(
false
);
ui
->
messageView
->
clear
();
ui
->
messageView
->
setInvitation
(
false
);
Utils
::
oneShotConnect
(
ui
->
messageView
,
&
MessageWebView
::
messagesCleared
,
[
this
]
{
[
this
,
convInfo
]
{
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
auto
currentConversation
=
Utils
::
getConversationFromUid
(
LRCInstance
::
getSelectedConvUid
(),
*
convModel
);
ui
->
messageView
->
printHistory
(
*
convModel
,
currentConversation
->
interactions
);
ui
->
messageView
->
printHistory
(
*
convModel
,
convInfo
.
interactions
);
Utils
::
oneShotConnect
(
ui
->
messageView
,
&
MessageWebView
::
messagesLoaded
,
[
this
]
{
ui
->
messageView
->
setMessagesVisibility
(
true
);
});
// Contact Avatars
auto
accInfo
=
&
LRCInstance
::
getCurrentAccountInfo
();
auto
contactUri
=
c
urrentConversation
->
participants
.
front
();
auto
contactUri
=
c
onvInfo
.
participants
.
front
();
try
{
auto
&
contact
=
accInfo
->
contactModel
->
getContact
(
contactUri
);
auto
bestName
=
Utils
::
bestNameForConversation
(
*
currentConversation
,
*
convModel
);
auto
bestName
=
Utils
::
bestNameForConversation
(
convInfo
,
*
convModel
);
ui
->
messageView
->
setInvitation
(
(
contact
.
profileInfo
.
type
==
lrc
::
api
::
profile
::
Type
::
PENDING
),
bestName
,
...
...
@@ -874,7 +897,7 @@ CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
accInfo
->
contactModel
->
getContactProfileId
(
contactUri
),
contact
.
profileInfo
.
avatar
);
}
else
{
auto
avatar
=
Utils
::
conversationPhoto
(
LRCInstance
::
getSelectedConvUid
()
,
*
accInfo
);
auto
avatar
=
Utils
::
conversationPhoto
(
convInfo
.
uid
,
*
accInfo
);
QByteArray
ba
;
QBuffer
bu
(
&
ba
);
avatar
.
save
(
&
bu
,
"PNG"
);
...
...
@@ -935,24 +958,31 @@ CallWidget::on_shareButton_clicked()
void
CallWidget
::
on_sendContactRequestButton_clicked
()
{
LRCInstance
::
getCurrentConversationModel
()
->
makePermanent
(
LRCInstance
::
getSelectedConvUid
());
auto
convInfo
=
Utils
::
getSelectedConversation
();
if
(
!
convInfo
.
uid
.
empty
())
{
LRCInstance
::
getCurrentConversationModel
()
->
makePermanent
(
convInfo
.
uid
);
ui
->
sendContactRequestButton
->
hide
();
}
}
void
CallWidget
::
on_btnAudioCall_clicked
()
{
auto
convUid
=
LRCInstance
::
getSelectedConvUid
();
LRCInstance
::
getCurrentConversationModel
()
->
placeAudioOnlyCall
(
convUid
);
ui
->
callingPhoto
->
setPixmap
(
QPixmap
::
fromImage
(
imageForConv
(
convUid
)));
auto
convInfo
=
Utils
::
getSelectedConversation
();
if
(
!
convInfo
.
uid
.
empty
())
{
LRCInstance
::
getCurrentConversationModel
()
->
placeAudioOnlyCall
(
convInfo
.
uid
);
ui
->
callingPhoto
->
setPixmap
(
QPixmap
::
fromImage
(
imageForConv
(
convInfo
.
uid
)));
}
}
void
CallWidget
::
on_btnVideoCall_clicked
()
{
auto
convUid
=
LRCInstance
::
getSelectedConvUid
();
LRCInstance
::
getCurrentConversationModel
()
->
placeCall
(
convUid
);
ui
->
callingPhoto
->
setPixmap
(
QPixmap
::
fromImage
(
imageForConv
(
convUid
)));
auto
convInfo
=
Utils
::
getSelectedConversation
();
if
(
!
convInfo
.
uid
.
empty
())
{
LRCInstance
::
getCurrentConversationModel
()
->
placeCall
(
convInfo
.
uid
);
ui
->
callingPhoto
->
setPixmap
(
QPixmap
::
fromImage
(
imageForConv
(
convInfo
.
uid
)));
}
}
bool
...
...
@@ -978,7 +1008,7 @@ CallWidget::connectConversationModel()
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
modelSorted
,
[
this
]()
{
updateConversationsFilterWidget
();
selectSmartlistItem
(
LRCInstance
::
getSelectedConv
Uid
()
);
selectSmartlistItem
(
Utils
::
getSelectedConv
ersation
().
uid
);
ui
->
smartList
->
update
();
}
);
...
...
@@ -1081,7 +1111,7 @@ CallWidget::selectConversation(const QModelIndex& index)
const
auto
item
=
currentConversationModel
->
filteredConversation
(
index
.
row
());
if
(
selectConversation
(
item
,
*
currentConversationModel
))
{
show
IMOutOfCall
(
index
);
show
ChatView
(
index
);
auto
convUid
=
LRCInstance
::
getSelectedConvUid
();
if
(
!
lastConvUid_
.
compare
(
convUid
))
{
return
;
...
...
@@ -1106,8 +1136,8 @@ CallWidget::selectConversation( const lrc::api::conversation::Info& item,
if
(
LRCInstance
::
getSelectedConvUid
()
==
item
.
uid
)
{
return
false
;
}
else
if
(
item
.
participants
.
size
()
>
0
)
{
convModel
.
selectConversation
(
item
.
uid
);
LRCInstance
::
setSelectedConvId
(
item
.
uid
);
convModel
.
selectConversation
(
item
.
uid
);
convModel
.
clearUnreadInteractions
(
item
.
uid
);
ui
->
conversationsFilterWidget
->
update
();
return
true
;
...
...
This diff is collapsed.
Click to expand it.
callwidget.h
+
4
−
2
View file @
1cf20c77
...
...
@@ -75,7 +75,9 @@ public slots:
public
slots
:
void
settingsButtonClicked
();
void
showIMOutOfCall
(
const
QModelIndex
&
nodeIdx
);
void
showChatView
(
const
QModelIndex
&
nodeIdx
);
void
showChatView
(
const
std
::
string
&
accountId
,
const
lrc
::
api
::
conversation
::
Info
&
convInfo
);
void
setupChatView
(
const
lrc
::
api
::
conversation
::
Info
&
convInfo
);
void
slotAcceptInviteClicked
(
const
QModelIndex
&
index
);
void
slotBlockInviteClicked
(
const
QModelIndex
&
index
);
void
slotIgnoreInviteClicked
(
const
QModelIndex
&
index
);
...
...
@@ -121,7 +123,7 @@ private:
bool
connectConversationModel
();
void
updateConversationView
(
const
std
::
string
&
convUid
);
void
showConversationView
();
void
selectSmartlistItem
(
const
std
::
string
&
convUid
);
bool
selectSmartlistItem
(
const
std
::
string
&
convUid
);
QImage
imageForConv
(
const
std
::
string
&
convUid
);
void
processContactLineEdit
();
void
hideMiniSpinner
();
...
...
This diff is collapsed.
Click to expand it.
utils.cpp
+
35
−
7
View file @
1cf20c77
...
...
@@ -395,14 +395,13 @@ Utils::isContactValid(const std::string& contactUid, const lrc::api::Conversatio
QImage
Utils
::
conversationPhoto
(
const
std
::
string
&
convUid
,
const
lrc
::
api
::
account
::
Info
&
accountInfo
)
{
auto
&
convModel
=
accountInfo
.
conversationModel
;
auto
conversation
=
Utils
::
getConversationFromUid
(
convUid
,
*
convModel
);
if
(
conversation
==
(
*
convModel
).
allFilteredConversations
().
end
())
{
return
QImage
();
auto
convInfo
=
getConversationFromUid
(
convUid
,
false
);
if
(
!
convInfo
.
uid
.
empty
())
{
return
GlobalInstances
::
pixmapManipulator
()
.
decorationRole
(
convInfo
,
accountInfo
)
.
value
<
QImage
>
();
}
QVariant
var
=
GlobalInstances
::
pixmapManipulator
().
decorationRole
(
*
conversation
,
accountInfo
);
return
var
.
value
<
QImage
>
();
return
QImage
();
}
QByteArray
...
...
@@ -444,3 +443,32 @@ Utils::getConversationFromCallId(const std::string& callId)
}
return
""
;
}
lrc
::
api
::
conversation
::
Info
Utils
::
getSelectedConversation
()
{
return
getConversationFromUid
(
LRCInstance
::
getSelectedConvUid
(),
false
);
}
lrc
::
api
::
conversation
::
Info
Utils
::
getConversationFromUid
(
const
std
::
string
&
convUid
,
bool
filtered
)
{
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
if
(
filtered
)
{
auto
conversation
=
getConversationFromUid
(
convUid
,
*
convModel
);
}
else
{
using
namespace
lrc
::
api
::
profile
;
for
(
int
i
=
toUnderlyingValue
(
Type
::
RING
);
i
<=
toUnderlyingValue
(
Type
::
TEMPORARY
);
++
i
)
{
auto
filter
=
toEnum
<
lrc
::
api
::
profile
::
Type
>
(
i
);
auto
conversations
=
convModel
->
getFilteredConversations
(
filter
);
auto
conv
=
std
::
find_if
(
conversations
.
begin
(),
conversations
.
end
(),
[
&
](
const
lrc
::
api
::
conversation
::
Info
&
conv
)
{
return
convUid
==
conv
.
uid
;
});
if
(
conv
!=
conversations
.
end
())
{
return
*
conv
;
}
}
}
return
lrc
::
api
::
conversation
::
Info
();
}
This diff is collapsed.
Click to expand it.
utils.h
+
2
−
0
View file @
1cf20c77
...
...
@@ -79,6 +79,8 @@ namespace Utils
QByteArray
QByteArrayFromFile
(
const
QString
&
filename
);
QPixmap
generateTintedPixmap
(
const
QString
&
filename
,
QColor
color
);
std
::
string
getConversationFromCallId
(
const
std
::
string
&
callId
);
lrc
::
api
::
conversation
::
Info
getSelectedConversation
();
lrc
::
api
::
conversation
::
Info
getConversationFromUid
(
const
std
::
string
&
convUid
,
bool
filtered
=
true
);
template
<
typename
Func1
,
typename
Func2
>
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment