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
519e8515
Commit
519e8515
authored
Jun 08, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): download directly file chat message (without dialogs)
parent
64f0ab73
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
120 additions
and
57 deletions
+120
-57
en.ts
linphone-desktop/assets/languages/en.ts
+4
-7
fr.ts
linphone-desktop/assets/languages/fr.ts
+4
-7
Paths.cpp
linphone-desktop/src/app/paths/Paths.cpp
+6
-1
Paths.hpp
linphone-desktop/src/app/paths/Paths.hpp
+1
-0
ChatModel.cpp
linphone-desktop/src/components/chat/ChatModel.cpp
+21
-15
ChatModel.hpp
linphone-desktop/src/components/chat/ChatModel.hpp
+1
-1
ChatProxyModel.cpp
linphone-desktop/src/components/chat/ChatProxyModel.cpp
+6
-10
ChatProxyModel.hpp
linphone-desktop/src/components/chat/ChatProxyModel.hpp
+1
-1
SettingsModel.cpp
linphone-desktop/src/components/settings/SettingsModel.cpp
+20
-3
SettingsModel.hpp
linphone-desktop/src/components/settings/SettingsModel.hpp
+5
-0
Utils.cpp
linphone-desktop/src/utils/Utils.cpp
+31
-0
Utils.hpp
linphone-desktop/src/utils/Utils.hpp
+4
-0
FileMessage.qml
linphone-desktop/ui/modules/Linphone/Chat/FileMessage.qml
+1
-12
SettingsUi.qml
linphone-desktop/ui/views/App/Settings/SettingsUi.qml
+15
-0
No files found.
linphone-desktop/assets/languages/en.ts
View file @
519e8515
...
...
@@ -760,13 +760,6 @@ Server url not configured.</translation>
<
translation
>
It
&
apos
;
s
necessary
to
restart
the
application
.
Do
you
want
to
restart
now
?
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
FileMessage
<
/name
>
<
message
>
<
source
>
downloadFileTitle
<
/source
>
<
translation
>
Download
file
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
Home
<
/name
>
<
message
>
...
...
@@ -1292,6 +1285,10 @@ your friend's SIP address or username.</translation>
<
source
>
cleanAvatarsDescription
<
/source
>
<
translation
>
Are
you
sure
you
want
to
clean
all
avatars
?
<
/translation
>
<
/message
>
<
message
>
<
source
>
downloadLabel
<
/source
>
<
translation
>
Download
folder
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
SettingsVideo
<
/name
>
...
...
linphone-desktop/assets/languages/fr.ts
View file @
519e8515
...
...
@@ -760,13 +760,6 @@ Url du serveur non configurée.</translation>
<
translation
>
Voulez
-
vous
red
é
marrer
maintenant
pour
prendre
en
compte
ces
modifications
?
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
FileMessage
<
/name
>
<
message
>
<
source
>
downloadFileTitle
<
/source
>
<
translation
>
T
é
l
é
charger
le
fichier
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
Home
<
/name
>
<
message
>
...
...
@@ -1291,6 +1284,10 @@ un chat ou ajouter un contact.</translation>
<
source
>
cleanAvatarsDescription
<
/source
>
<
translation
>
Voulez
-
vous
vraiment
supprimer
tous
les
avatars
?
<
/translation
>
<
/message
>
<
message
>
<
source
>
downloadLabel
<
/source
>
<
translation
>
Dossier
des
t
é
l
é
chargements
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
SettingsVideo
<
/name
>
...
...
linphone-desktop/src/app/paths/Paths.cpp
View file @
519e8515
...
...
@@ -28,6 +28,7 @@
#include <QtDebug>
#include "../../utils/Utils.hpp"
#include "config.h"
#include "Paths.hpp"
...
...
@@ -167,7 +168,7 @@ string Paths::getAvatarsDirPath () {
}
string
Paths
::
getCallHistoryFilePath
()
{
return
getWritableFilePath
(
getAppCallHistoryFilePath
()
);
return
getWritableFilePath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_AVATARS
);
}
string
Paths
::
getCapturesDirPath
()
{
...
...
@@ -189,6 +190,10 @@ string Paths::getFriendsListFilePath () {
return
getWritableFilePath
(
getAppFriendsFilePath
());
}
std
::
string
Paths
::
getDownloadDirPath
()
{
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DownloadLocation
));
}
string
Paths
::
getLogsDirPath
()
{
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_LOGS
);
}
...
...
linphone-desktop/src/app/paths/Paths.hpp
View file @
519e8515
...
...
@@ -39,6 +39,7 @@ namespace Paths {
std
::
string
getConfigFilePath
(
const
QString
&
configPath
=
QString
());
std
::
string
getFactoryConfigFilePath
();
std
::
string
getFriendsListFilePath
();
std
::
string
getDownloadDirPath
();
std
::
string
getLogsDirPath
();
std
::
string
getMessageHistoryFilePath
();
std
::
string
getPackageDataDirPath
();
...
...
linphone-desktop/src/components/chat/ChatModel.cpp
View file @
519e8515
...
...
@@ -106,11 +106,9 @@ public:
private:
QList
<
ChatEntryData
>::
iterator
findMessageEntry
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
return
find_if
(
mChatModel
->
mEntries
.
begin
(),
mChatModel
->
mEntries
.
end
(),
[
&
message
](
const
ChatEntryData
&
pair
)
{
return
find_if
(
mChatModel
->
mEntries
.
begin
(),
mChatModel
->
mEntries
.
end
(),
[
&
message
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
message
;
}
);
});
}
void
signalDataChanged
(
const
QList
<
ChatEntryData
>::
iterator
&
it
)
{
...
...
@@ -390,7 +388,7 @@ void ChatModel::sendFileMessage (const QString &path) {
emit
messageSent
(
message
);
}
void
ChatModel
::
downloadFile
(
int
id
,
const
QString
&
downloadPath
)
{
void
ChatModel
::
downloadFile
(
int
id
)
{
if
(
!
mChatRoom
)
return
;
...
...
@@ -423,7 +421,20 @@ void ChatModel::downloadFile (int id, const QString &downloadPath) {
return
;
}
message
->
setFileTransferFilepath
(
::
Utils
::
appStringToCoreString
(
downloadPath
));
bool
soFarSoGood
;
const
QString
&
safeFilePath
=
::
Utils
::
getSafeFilePath
(
QStringLiteral
(
"%1%2"
)
.
arg
(
CoreManager
::
getInstance
()
->
getSettingsModel
()
->
getDownloadFolder
())
.
arg
(
entry
.
first
[
"fileName"
].
toString
()),
&
soFarSoGood
);
if
(
!
soFarSoGood
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to create safe file path for: %1."
).
arg
(
id
);
return
;
}
message
->
setFileTransferFilepath
(
::
Utils
::
appStringToCoreString
(
safeFilePath
));
message
->
setListener
(
mMessageHandlers
);
if
(
message
->
downloadFile
()
<
0
)
...
...
@@ -486,16 +497,14 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
// We are between `beginRemoveRows` and `endRemoveRows`.
// A solution is to schedule a `removeEntry` call in the Qt main loop.
shared_ptr
<
void
>
linphonePtr
=
pair
.
second
;
QTimer
::
singleShot
(
0
,
this
,
[
this
,
linphonePtr
]()
{
QTimer
::
singleShot
(
0
,
this
,
[
this
,
linphonePtr
]()
{
auto
it
=
find_if
(
mEntries
.
begin
(),
mEntries
.
end
(),
[
linphonePtr
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
linphonePtr
;
});
if
(
it
!=
mEntries
.
end
())
removeEntry
(
static_cast
<
int
>
(
distance
(
mEntries
.
begin
(),
it
)));
}
);
});
}
CoreManager
::
getInstance
()
->
getCore
()
->
removeCallLog
(
static_pointer_cast
<
linphone
::
CallLog
>
(
pair
.
second
));
...
...
@@ -525,12 +534,9 @@ void ChatModel::insertCall (const shared_ptr<linphone::CallLog> &callLog) {
const
ChatEntryData
&
pair
,
const
QList
<
ChatEntryData
>::
iterator
*
start
=
NULL
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
mEntries
.
begin
(),
mEntries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
mEntries
.
begin
(),
mEntries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
return
a
.
first
[
"timestamp"
]
<
b
.
first
[
"timestamp"
];
}
);
});
int
row
=
static_cast
<
int
>
(
distance
(
mEntries
.
begin
(),
it
));
...
...
linphone-desktop/src/components/chat/ChatModel.hpp
View file @
519e8515
...
...
@@ -97,7 +97,7 @@ public:
void
sendFileMessage
(
const
QString
&
path
);
void
downloadFile
(
int
id
,
const
QString
&
downloadPath
);
void
downloadFile
(
int
id
);
signals:
void
sipAddressChanged
(
const
QString
&
sipAddress
);
...
...
linphone-desktop/src/components/chat/ChatProxyModel.cpp
View file @
519e8515
...
...
@@ -69,17 +69,13 @@ ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent)
ChatModel
*
chat
=
static_cast
<
ChatModel
*>
(
mChatModelFilter
->
sourceModel
());
QObject
::
connect
(
chat
,
&
ChatModel
::
messageReceived
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
QObject
::
connect
(
chat
,
&
ChatModel
::
messageReceived
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
mMaxDisplayedEntries
++
;
}
);
});
QObject
::
connect
(
chat
,
&
ChatModel
::
messageSent
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
QObject
::
connect
(
chat
,
&
ChatModel
::
messageSent
,
this
,
[
this
](
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
mMaxDisplayedEntries
++
;
}
);
});
}
void
ChatProxyModel
::
loadMoreEntries
()
{
...
...
@@ -133,10 +129,10 @@ void ChatProxyModel::sendFileMessage (const QString &path) {
static_cast
<
ChatModel
*>
(
mChatModelFilter
->
sourceModel
())
->
sendFileMessage
(
path
);
}
void
ChatProxyModel
::
downloadFile
(
int
id
,
const
QString
&
downloadPath
)
{
void
ChatProxyModel
::
downloadFile
(
int
id
)
{
QModelIndex
sourceIndex
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
mChatModelFilter
->
sourceModel
())
->
downloadFile
(
mChatModelFilter
->
mapToSource
(
sourceIndex
).
row
()
,
downloadPath
mChatModelFilter
->
mapToSource
(
sourceIndex
).
row
()
);
}
...
...
linphone-desktop/src/components/chat/ChatProxyModel.hpp
View file @
519e8515
...
...
@@ -50,7 +50,7 @@ public:
Q_INVOKABLE
void
sendFileMessage
(
const
QString
&
path
);
Q_INVOKABLE
void
downloadFile
(
int
id
,
const
QString
&
downloadPath
);
Q_INVOKABLE
void
downloadFile
(
int
id
);
signals:
void
sipAddressChanged
(
const
QString
&
sipAddress
);
...
...
linphone-desktop/src/components/settings/SettingsModel.cpp
View file @
519e8515
...
...
@@ -640,10 +640,27 @@ QString SettingsModel::getSavedVideosFolder () const {
}
void
SettingsModel
::
setSavedVideosFolder
(
const
QString
&
folder
)
{
QString
_folder
=
QDir
::
cleanPath
(
folder
)
+
QDir
::
separator
();
QString
cleanedFolder
=
QDir
::
cleanPath
(
folder
)
+
QDir
::
separator
();
mConfig
->
setString
(
UI_SECTION
,
"saved_videos_folder"
,
::
Utils
::
appStringToCoreString
(
cleanedFolder
));
emit
savedVideosFolderChanged
(
cleanedFolder
);
}
// -----------------------------------------------------------------------------
QString
SettingsModel
::
getDownloadFolder
()
const
{
return
QDir
::
cleanPath
(
::
Utils
::
coreStringToAppString
(
mConfig
->
getString
(
UI_SECTION
,
"download_folder"
,
Paths
::
getDownloadDirPath
())
)
)
+
QDir
::
separator
();
}
void
SettingsModel
::
setDownloadFolder
(
const
QString
&
folder
)
{
QString
cleanedFolder
=
QDir
::
cleanPath
(
folder
)
+
QDir
::
separator
();
mConfig
->
setString
(
UI_SECTION
,
"
saved_videos_folder"
,
::
Utils
::
appStringToCoreString
(
_f
older
));
emit
savedVideosFolderChanged
(
_f
older
);
mConfig
->
setString
(
UI_SECTION
,
"
download_folder"
,
::
Utils
::
appStringToCoreString
(
cleanedF
older
));
emit
downloadFolderChanged
(
cleanedF
older
);
}
// -----------------------------------------------------------------------------
...
...
linphone-desktop/src/components/settings/SettingsModel.hpp
View file @
519e8515
...
...
@@ -115,6 +115,7 @@ class SettingsModel : public QObject {
Q_PROPERTY
(
QString
savedScreenshotsFolder
READ
getSavedScreenshotsFolder
WRITE
setSavedScreenshotsFolder
NOTIFY
savedScreenshotsFolderChanged
);
Q_PROPERTY
(
QString
savedVideosFolder
READ
getSavedVideosFolder
WRITE
setSavedVideosFolder
NOTIFY
savedVideosFolderChanged
);
Q_PROPERTY
(
QString
downloadFolder
READ
getDownloadFolder
WRITE
setDownloadFolder
NOTIFY
downloadFolderChanged
);
public:
enum
MediaEncryption
{
...
...
@@ -264,6 +265,9 @@ public:
QString
getSavedVideosFolder
()
const
;
void
setSavedVideosFolder
(
const
QString
&
folder
);
QString
getDownloadFolder
()
const
;
void
setDownloadFolder
(
const
QString
&
folder
);
QString
getRemoteProvisioning
()
const
;
void
setRemoteProvisioning
(
const
QString
&
remoteProvisioning
);
...
...
@@ -339,6 +343,7 @@ signals:
void
savedScreenshotsFolderChanged
(
const
QString
&
folder
);
void
savedVideosFolderChanged
(
const
QString
&
folder
);
void
downloadFolderChanged
(
const
QString
&
folder
);
void
remoteProvisioningChanged
(
const
QString
&
remoteProvisioning
);
void
remoteProvisioningNotChanged
(
const
QString
&
remoteProvisioning
);
...
...
linphone-desktop/src/utils/Utils.cpp
View file @
519e8515
...
...
@@ -20,6 +20,8 @@
* Author: Ronan Abhamon
*/
#include <QFileInfo>
#include "Utils.hpp"
// =============================================================================
...
...
@@ -38,3 +40,32 @@ char *Utils::rstrstr (const char *a, const char *b) {
return
nullptr
;
}
// -----------------------------------------------------------------------------
#define SAFE_FILE_PATH_LIMIT 100
QString
Utils
::
getSafeFilePath
(
const
QString
&
filePath
,
bool
*
soFarSoGood
)
{
if
(
soFarSoGood
)
*
soFarSoGood
=
true
;
QFileInfo
info
(
filePath
);
if
(
!
info
.
exists
())
return
filePath
;
const
QString
&
prefix
=
QStringLiteral
(
"%1/%2"
).
arg
(
info
.
absolutePath
()).
arg
(
info
.
baseName
());
const
QString
&
ext
=
info
.
completeSuffix
();
for
(
int
i
=
1
;
i
<
SAFE_FILE_PATH_LIMIT
;
++
i
)
{
QString
safePath
=
QStringLiteral
(
"%1 (%3).%4"
).
arg
(
prefix
).
arg
(
i
).
arg
(
ext
);
if
(
!
QFileInfo
::
exists
(
safePath
))
return
safePath
;
}
if
(
soFarSoGood
)
*
soFarSoGood
=
false
;
return
QStringLiteral
(
""
);
}
#undef SAFE_FILE_PATH_LIMIT
linphone-desktop/src/utils/Utils.hpp
View file @
519e8515
...
...
@@ -50,6 +50,10 @@ namespace Utils {
// Reverse function of strstr.
char
*
rstrstr
(
const
char
*
a
,
const
char
*
b
);
// Returns the same path given in parameter if `filePath` exists.
// Otherwise returns a safe path with a unique number before the extension.
QString
getSafeFilePath
(
const
QString
&
filePath
,
bool
*
soFarSoGood
=
nullptr
);
}
#endif // UTILS_H_
linphone-desktop/ui/modules/Linphone/Chat/FileMessage.qml
View file @
519e8515
import
QtQuick
2.7
import
QtQuick
.
Controls
2.1
import
QtQuick
.
Dialogs
1.2
import
QtQuick
.
Layouts
1.3
import
Common
1.0
...
...
@@ -179,23 +178,13 @@ Row {
}
MouseArea
{
FileDialog
{
id
:
fileDialog
folder
:
shortcuts
.
home
selectExisting
:
false
title
:
qsTr
(
'
downloadFileTitle
'
)
onAccepted
:
proxyModel
.
downloadFile
(
index
,
App
.
convertUrlToLocalPath
(
fileUrl
))
}
anchors.fill
:
parent
cursorShape
:
containsMouse
?
Qt
.
PointingHandCursor
:
Qt
.
ArrowCursor
hoverEnabled
:
true
onClicked
:
fileDialog
.
open
(
)
onClicked
:
proxyModel
.
downloadFile
(
index
)
visible
:
!
rectangle
.
isNotDelivered
&&
!
$chatEntry
.
isOutgoing
}
}
...
...
linphone-desktop/ui/views/App/Settings/SettingsUi.qml
View file @
519e8515
...
...
@@ -96,7 +96,9 @@ TabContainer {
onAccepted
:
SettingsModel
.
savedScreenshotsFolder
=
selectedFile
}
}
}
FormLine
{
FormGroup
{
label
:
qsTr
(
'
savedVideosLabel
'
)
...
...
@@ -109,6 +111,19 @@ TabContainer {
}
}
FormLine
{
FormGroup
{
label
:
qsTr
(
'
downloadLabel
'
)
FileChooserButton
{
selectedFile
:
SettingsModel
.
downloadFolder
selectFolder
:
true
onAccepted
:
SettingsModel
.
downloadFolder
=
selectedFile
}
}
}
FormEmptyLine
{}
}
...
...
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