Subversion Repositories tpanel

Rev

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

Rev 119 Rev 120
Line 16... Line 16...
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
17
 */
18
 
18
 
19
#include <iostream>
19
#include <iostream>
20
#include <fstream>
20
#include <fstream>
-
 
21
#include <functional>
21
 
22
 
22
#include <stdio.h>
23
#include <stdio.h>
23
#include <sys/stat.h>
24
#include <sys/stat.h>
24
#include <fcntl.h>
25
#include <fcntl.h>
25
#include <errno.h>
26
#include <errno.h>
Line 40... Line 41...
40
#include "tdirectory.h"
41
#include "tdirectory.h"
41
 
42
 
42
using std::string;
43
using std::string;
43
using std::vector;
44
using std::vector;
44
using std::ostream;
45
using std::ostream;
-
 
46
using std::bind;
45
 
47
 
46
TTPInit::TTPInit()
48
TTPInit::TTPInit()
47
{
49
{
48
    DECL_TRACER("TTPInit::TTPInit()");
50
    DECL_TRACER("TTPInit::TTPInit()");
49
}
51
}
Line 331... Line 333...
331
bool TTPInit::loadSurfaceFromController(bool force)
333
bool TTPInit::loadSurfaceFromController(bool force)
332
{
334
{
333
    DECL_TRACER("TTPInit::loadSurfaceFromController(bool force)");
335
    DECL_TRACER("TTPInit::loadSurfaceFromController(bool force)");
334
 
336
 
335
    TFsfReader reader;
337
    TFsfReader reader;
-
 
338
    reader.regCallbackProgress(bind(&TTPInit::progressCallback, this, std::placeholders::_1));
336
    string target = mPath + "/" + TConfig::getFtpSurface();
339
    string target = mPath + "/" + TConfig::getFtpSurface();
337
    size_t pos = 0;
340
    size_t pos = 0;
338
 
341
 
339
    if ((pos = mPath.find_last_of("/")) != string::npos)
342
    if ((pos = mPath.find_last_of("/")) != string::npos)
340
        target = mPath.substr(0, pos) + "/" + TConfig::getFtpSurface();
343
        target = mPath.substr(0, pos) + "/" + TConfig::getFtpSurface();
Line 345... Line 348...
345
 
348
 
346
        if (pan.exists() || TConfig::getFtpDownloadTime() > 0)
349
        if (pan.exists() || TConfig::getFtpDownloadTime() > 0)
347
            return false;
350
            return false;
348
    }
351
    }
349
 
352
 
-
 
353
    if (_processEvents)
-
 
354
        _processEvents();
-
 
355
 
350
    // To be sure the target directory tree is empty, we delete all files but
356
    // To be sure the target directory tree is empty, we delete all files but
351
    // keep the system directories and their content, if they exist.
357
    // keep the system directories and their content, if they exist.
352
    dir::TDirectory dir;
358
    dir::TDirectory dir;
353
 
359
 
354
    if (dir.exists(mPath))
360
    if (dir.exists(mPath))
Line 360... Line 366...
360
    }
366
    }
361
 
367
 
362
    if (!reader.copyOverFTP(TConfig::getFtpSurface(), target))
368
    if (!reader.copyOverFTP(TConfig::getFtpSurface(), target))
363
        return false;
369
        return false;
364
 
370
 
-
 
371
    if (_processEvents)
-
 
372
        _processEvents();
-
 
373
 
365
    if (!reader.unpack(target, mPath))
374
    if (!reader.unpack(target, mPath))
366
    {
375
    {
367
        MSG_ERROR("Unpacking was not successfull.");
376
        MSG_ERROR("Unpacking was not successfull.");
368
        return false;
377
        return false;
369
    }
378
    }
Line 372... Line 381...
372
    {
381
    {
373
        createDirectoryStructure();
382
        createDirectoryStructure();
374
        createSystemConfigs();
383
        createSystemConfigs();
375
    }
384
    }
376
 
385
 
-
 
386
    if (_processEvents)
-
 
387
        _processEvents();
-
 
388
 
377
    dir.dropFile(target);       // We remove our traces
389
    dir.dropFile(target);       // We remove our traces
378
    TConfig::saveFtpDownloadTime(time(NULL));
390
    TConfig::saveFtpDownloadTime(time(NULL));
379
    TConfig::saveSettings();
391
    TConfig::saveSettings();
380
    return true;
392
    return true;
381
}
393
}
382
 
394
 
-
 
395
int TTPInit::progressCallback(off64_t xfer)
-
 
396
{
-
 
397
    DECL_TRACER("TTPInit::progressCallback(off64_t xfer)");
-
 
398
 
-
 
399
    if (_processEvents && xfer > 0)
-
 
400
        _processEvents();
-
 
401
 
-
 
402
    return 1;
-
 
403
}
-
 
404
 
383
#ifdef __ANDROID__
405
#ifdef __ANDROID__
384
bool TTPInit::askPermissions()
406
bool TTPInit::askPermissions()
385
{
407
{
386
    DECL_TRACER("TTPInit::askPermissions()");
408
    DECL_TRACER("TTPInit::askPermissions()");
387
 
409