Subversion Repositories tpanel

Rev

Rev 260 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 260 Rev 264
Line 27... Line 27...
27
#include <unistd.h>
27
#include <unistd.h>
28
 
28
 
29
#include <QFile>
29
#include <QFile>
30
#include <QDir>
30
#include <QDir>
31
#ifdef Q_OS_ANDROID
31
#ifdef Q_OS_ANDROID
32
#ifdef QT5_LINUX
32
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33
#include <QtAndroidExtras/QtAndroid>
33
#include <QtAndroidExtras/QtAndroid>
34
#else
34
#else
35
#include <QtCore>
35
#include <QtCore>
36
#include <QFuture>
36
#include <QFuture>
37
#include <QtCore/private/qandroidextras_p.h>
37
#include <QtCore/private/qandroidextras_p.h>
Line 44... Line 44...
44
#include "terror.h"
44
#include "terror.h"
45
#include "tvalidatefile.h"
45
#include "tvalidatefile.h"
46
#include "tconfig.h"
46
#include "tconfig.h"
47
#include "tfsfreader.h"
47
#include "tfsfreader.h"
48
#include "tdirectory.h"
48
#include "tdirectory.h"
49
#include "tpagemanager.h"
-
 
50
#include "tresources.h"
49
#include "tresources.h"
-
 
50
#ifdef Q_OS_IOS
-
 
51
#include "ios/QASettings.h"
-
 
52
#endif
51
 
53
 
52
#if __cplusplus < 201402L
54
#if __cplusplus < 201402L
53
#   error "This module requires at least C++14 standard!"
55
#   error "This module requires at least C++14 standard!"
54
#else
56
#else
55
#   if __cplusplus < 201703L
57
#   if __cplusplus < 201703L
Line 2247... Line 2249...
2247
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2249
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2248
            "abcdefghijklmnopqrstuvwxyz";
2250
            "abcdefghijklmnopqrstuvwxyz";
2249
 
2251
 
2250
    size_t stringLength = alphanum.length() - 1;
2252
    size_t stringLength = alphanum.length() - 1;
2251
    std::string Str;
2253
    std::string Str;
-
 
2254
#ifdef Q_OS_IOS
-
 
2255
    Str = QASettings::getLibraryPath().toStdString();
-
 
2256
#else
2252
    char *tmp = getenv("TMP");
2257
    char *tmp = getenv("TMP");
2253
 
2258
 
2254
    if (!tmp)
2259
    if (!tmp)
2255
        tmp = getenv("TEMP");
2260
        tmp = getenv("TEMP");
2256
 
2261
 
Line 2258... Line 2263...
2258
        tmp = getenv("HOME");
2263
        tmp = getenv("HOME");
2259
    else
2264
    else
2260
        tmp = (char *)"/tmp";
2265
        tmp = (char *)"/tmp";
2261
 
2266
 
2262
    Str.assign(tmp);
2267
    Str.assign(tmp);
-
 
2268
#endif
2263
    Str.append("/");
2269
    Str.append("/");
2264
 
2270
 
2265
    for(size_t i = 0; i < MAX_TMP_LEN; ++i)
2271
    for(size_t i = 0; i < MAX_TMP_LEN; ++i)
2266
        Str += alphanum[rand() % stringLength];
2272
        Str += alphanum[rand() % stringLength];
2267
 
2273
 
Line 2304... Line 2310...
2304
{
2310
{
2305
    DECL_TRACER("TTPInit::loadSurfaceFromController(bool force)");
2311
    DECL_TRACER("TTPInit::loadSurfaceFromController(bool force)");
2306
 
2312
 
2307
    TFsfReader reader;
2313
    TFsfReader reader;
2308
    reader.regCallbackProgress(bind(&TTPInit::progressCallback, this, std::placeholders::_1));
2314
    reader.regCallbackProgress(bind(&TTPInit::progressCallback, this, std::placeholders::_1));
2309
/*    bool temp = TConfig::getTemporary();
-
 
2310
 
-
 
2311
    if (gPageManager && gPageManager->isSetupActive())
-
 
2312
        TConfig::setTemporary(true);
-
 
2313
    else
-
 
2314
        TConfig::setTemporary(false);
-
 
2315
*/
-
 
2316
    string surface = TConfig::getFtpSurface();
2315
    string surface = TConfig::getFtpSurface();
2317
//    TConfig::setTemporary(temp);
-
 
2318
    string target = mPath + "/" + surface;
2316
    string target = mPath + "/" + surface;
2319
    size_t pos = 0;
2317
    size_t pos = 0;
2320
 
2318
 
2321
    if ((pos = mPath.find_last_of("/")) != string::npos)
2319
    if ((pos = mPath.find_last_of("/")) != string::npos)
2322
        target = mPath.substr(0, pos) + "/" + surface;
2320
        target = mPath.substr(0, pos) + "/" + surface;
Line 2416... Line 2414...
2416
        return mDirList;
2414
        return mDirList;
2417
    }
2415
    }
2418
 
2416
 
2419
    string sUser = TConfig::getFtpUser();
2417
    string sUser = TConfig::getFtpUser();
2420
    string sPass = TConfig::getFtpPassword();
2418
    string sPass = TConfig::getFtpPassword();
2421
    MSG_DEBUG("Trying to login <" << sUser << ", " << sPass << ">");
2419
    MSG_DEBUG("Trying to login <" << sUser << ", ********>");
2422
 
2420
 
2423
    if (!ftp->Login(sUser.c_str(), sPass.c_str()))
2421
    if (!ftp->Login(sUser.c_str(), sPass.c_str()))
2424
    {
2422
    {
2425
        delete ftp;
2423
        delete ftp;
2426
        return mDirList;
2424
        return mDirList;
Line 2676... Line 2674...
2676
bool TTPInit::askPermissions()
2674
bool TTPInit::askPermissions()
2677
{
2675
{
2678
    DECL_TRACER("TTPInit::askPermissions()");
2676
    DECL_TRACER("TTPInit::askPermissions()");
2679
 
2677
 
2680
    QStringList permissions = { "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE" };
2678
    QStringList permissions = { "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE" };
2681
#ifdef QT5_LINUX
2679
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
2682
    QtAndroid::PermissionResultMap perms = QtAndroid::requestPermissionsSync(permissions);
2680
    QtAndroid::PermissionResultMap perms = QtAndroid::requestPermissionsSync(permissions);
2683
 
2681
 
2684
    for (auto iter = perms.begin(); iter != perms.end(); ++iter)
2682
    for (auto iter = perms.begin(); iter != perms.end(); ++iter)
2685
    {
2683
    {
2686
        if (iter.value() == QtAndroid::PermissionResult::Denied)
2684
        if (iter.value() == QtAndroid::PermissionResult::Denied)