Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Israel Garcia
libcloudstorage
Commits
40c723e1
Commit
40c723e1
authored
Feb 10, 2018
by
Paweł Wegner
Browse files
cloudbrowser: moved thumbnail_path to GetThumbnailRequest.
parent
3651067e
Changes
5
Hide whitespace changes
Inline
Side-by-side
bin/cloudbrowser/src/AndroidUtility.cpp
View file @
40c723e1
...
...
@@ -10,6 +10,7 @@
#include
<QtAndroid>
#include
"CloudContext.h"
#include
"Request/GetThumbnail.h"
#include
"Utility/Utility.h"
const
int
RECEIVER_CODE
=
43
;
...
...
@@ -66,8 +67,8 @@ void AndroidUtility::defaultOrientation() {
void
AndroidUtility
::
showPlayerNotification
(
bool
playing
,
QString
filename
,
QString
title
)
{
auto
arg0
=
QAndroidJniObject
::
fromString
(
CloudContex
t
::
thumbnail_path
(
filename
));
auto
arg0
=
QAndroidJniObject
::
fromString
(
GetThumbnailReques
t
::
thumbnail_path
(
filename
));
auto
arg1
=
QAndroidJniObject
::
fromString
(
filename
);
auto
arg2
=
QAndroidJniObject
::
fromString
(
title
);
QAndroidJniObject
::
callStaticMethod
<
void
>
(
...
...
bin/cloudbrowser/src/CloudContext.cpp
View file @
40c723e1
...
...
@@ -21,21 +21,6 @@
using
namespace
cloudstorage
;
namespace
{
QString
sanitize
(
const
QString
&
name
)
{
const
QString
forbidden
=
"~
\"
#%&*:<>?/
\\
{|}"
;
QString
result
;
for
(
auto
&&
c
:
name
)
if
(
forbidden
.
indexOf
(
c
)
==
-
1
)
result
+=
c
;
else
result
+=
'_'
;
return
result
;
}
}
// namespace
int
ProviderListModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
provider_
.
size
();
}
...
...
@@ -368,11 +353,6 @@ void CloudContext::schedule(std::function<void()> f) {
thread_pool_
->
schedule
(
f
);
}
QString
CloudContext
::
thumbnail_path
(
const
QString
&
filename
)
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
CacheLocation
)
+
QDir
::
separator
()
+
sanitize
(
filename
)
+
"-thumbnail"
;
}
void
CloudContext
::
receivedCode
(
std
::
string
provider
,
std
::
string
code
)
{
auto
p
=
ICloudStorage
::
create
()
->
provider
(
provider
,
init_data
(
provider
));
auto
r
=
p
->
exchangeCodeAsync
(
code
,
[
=
](
EitherError
<
Token
>
e
)
{
...
...
bin/cloudbrowser/src/CloudContext.h
View file @
40c723e1
...
...
@@ -90,8 +90,6 @@ class CloudContext : public QObject {
ListDirectoryCacheKey
);
void
schedule
(
std
::
function
<
void
()
>
);
static
QString
thumbnail_path
(
const
QString
&
filename
);
signals:
void
receivedCode
(
QString
provider
);
void
errorOccurred
(
QString
operation
,
QVariantMap
provider
,
int
code
,
...
...
bin/cloudbrowser/src/Request/GetThumbnail.cpp
View file @
40c723e1
#include
"GetThumbnail.h"
#include
<QDir>
#include
<QFile>
#include
<QSaveFile>
#include
<QStandardPaths>
#include
<QUrl>
#include
"CloudContext.h"
#include
"GenerateThumbnail.h"
#include
"Utility/Utility.h"
...
...
@@ -11,6 +14,17 @@ using namespace cloudstorage;
namespace
{
QString
sanitize
(
const
QString
&
name
)
{
const
QString
forbidden
=
"~
\"
#%&*:<>?/
\\
{|}"
;
QString
result
;
for
(
auto
&&
c
:
name
)
if
(
forbidden
.
indexOf
(
c
)
==
-
1
)
result
+=
c
;
else
result
+=
'_'
;
return
result
;
}
class
DownloadToString
:
public
IDownloadFileCallback
{
public:
void
receivedData
(
const
char
*
data
,
uint32_t
length
)
override
{
...
...
@@ -73,7 +87,8 @@ class DownloadThumbnailCallback : public IDownloadFileCallback {
#ifdef WITH_THUMBNAILER
if
(
e
.
left
()
&&
(
item_
->
type
()
==
IItem
::
FileType
::
Image
||
item_
->
type
()
==
IItem
::
FileType
::
Video
))
{
auto
path
=
CloudContext
::
thumbnail_path
(
item_
->
filename
().
c_str
());
auto
path
=
GetThumbnailRequest
::
thumbnail_path
(
item_
->
filename
().
c_str
());
auto
provider
=
provider_
;
auto
item
=
item_
;
auto
notifier
=
notifier_
;
...
...
@@ -111,7 +126,8 @@ class DownloadThumbnailCallback : public IDownloadFileCallback {
emit
notifier_
->
finishedVariant
(
e
.
left
());
else
{
auto
notifier
=
notifier_
;
auto
path
=
CloudContext
::
thumbnail_path
(
item_
->
filename
().
c_str
());
auto
path
=
GetThumbnailRequest
::
thumbnail_path
(
item_
->
filename
().
c_str
());
auto
data
=
std
::
move
(
data_
);
context_
->
schedule
(
[
notifier
,
path
,
data
]
{
submit
(
notifier
,
path
,
std
::
move
(
data
));
});
...
...
@@ -131,7 +147,7 @@ class DownloadThumbnailCallback : public IDownloadFileCallback {
void
GetThumbnailRequest
::
update
(
CloudContext
*
context
,
CloudItem
*
item
)
{
if
(
item
->
type
()
==
"directory"
)
return
set_done
(
true
);
set_done
(
false
);
auto
path
=
CloudContext
::
thumbnail_path
(
item
->
filename
());
auto
path
=
thumbnail_path
(
item
->
filename
());
QFile
file
(
path
);
if
(
file
.
exists
()
&&
file
.
size
()
>
0
)
{
source_
=
QUrl
::
fromLocalFile
(
path
).
toString
();
...
...
@@ -165,3 +181,8 @@ void GetThumbnailRequest::update(CloudContext* context, CloudItem* item) {
context
->
add
(
p
,
std
::
move
(
r
));
}
}
QString
GetThumbnailRequest
::
thumbnail_path
(
const
QString
&
filename
)
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
CacheLocation
)
+
QDir
::
separator
()
+
sanitize
(
filename
)
+
"-thumbnail"
;
}
bin/cloudbrowser/src/Request/GetThumbnail.h
View file @
40c723e1
...
...
@@ -15,6 +15,7 @@ class GetThumbnailRequest : public Request {
QString
source
()
const
{
return
source_
;
}
Q_INVOKABLE
void
update
(
CloudContext
*
context
,
CloudItem
*
item
);
static
QString
thumbnail_path
(
const
QString
&
filename
);
signals:
void
sourceChanged
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment