blob: cf229c8e236414aec8578fb3b5c0297f99ba95cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef FOLDERMAN_H
#define FOLDERMAN_H
#include <QObject>
#include <QQueue>
#include "mirall/folder.h"
#include "mirall/folderwatcher.h"
class QSignalMapper;
namespace Mirall {
class SyncResult;
class OwncloudSetup;
class FolderMan : public QObject
{
Q_OBJECT
public:
explicit FolderMan(QObject *parent = 0);
~FolderMan();
int setupFolders();
void disableFoldersWithRestore();
void restoreEnabledFolders();
Mirall::Folder::Map map();
/**
* Add a folder definition to the config
* Params:
* QString backend
* QString alias
* QString sourceFolder on local machine
* QString targetPath on remote
* bool onlyThisLAN, currently unused.
*/
void addFolderDefinition( const QString&, const QString&, const QString&, const QString&, bool );
/**
* return the folder by alias or NULL if no folder with the alias exists.
*/
Folder *folder( const QString& );
/**
* return the last sync result by alias
*/
SyncResult syncResult( const QString& );
/**
* creates a folder for a specific configuration, identified by alias.
*/
Folder* setupFolderFromConfigFile(const QString & );
signals:
/**
* signal to indicate a folder named by alias has changed its sync state.
* Get the state via the Folder Map or the syncResult and syncState methods.
*/
void folderSyncStateChange( const QString & );
public slots:
void slotRemoveFolder( const QString& );
void slotEnableFolder( const QString&, bool );
void slotFolderSyncStarted();
void slotFolderSyncFinished( const SyncResult& );
void slotReparseConfiguration();
private slots:
// slot to add a folder to the syncing queue
void slotScheduleSync( const QString & );
// slot to take the next folder from queue and start syncing.
void slotScheduleFolderSync();
private:
// finds all folder configuration files
// and create the folders
int setupKnownFolders();
void removeFolder( const QString& );
FolderWatcher *_configFolderWatcher;
Folder::Map _folderMap;
QHash<QString, bool> _folderEnabledMap;
QString _folderConfigPath;
OwncloudSetup *_ownCloudSetup;
QSignalMapper *_folderChangeSignalMapper;
QString _currentSyncFolder;
QStringList _scheduleQueue;
bool _folderToDelete;
};
}
#endif // FOLDERMAN_H
|