/
transferengine_p.h
149 lines (127 loc) · 4.3 KB
/
transferengine_p.h
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/****************************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
** Contact: Marko Mattila <marko.mattila@jollamobile.com>
** All rights reserved.
**
** This file is part of Nemo Transfer Engine package.
**
** You may use this file under the terms of the GNU Lesser General
** Public License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library 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
** Lesser General Public License for more details.
**
****************************************************************************************/
#ifndef TRANSFERENGINE_P_H
#define TRANSFERENGINE_P_H
#include <QObject>
#include <QMap>
#include <QSettings>
#include "mediatransferinterface.h"
#include "transfermethodinfo.h"
namespace Accounts {
class Manager;
}
class QFileSystemWatcher;
class QTimer;
class QUrl;
class TransferEngine;
class TransferPluginInfo;
class TransferEngineSignalHandler: public QObject
{
Q_OBJECT
public:
static TransferEngineSignalHandler * instance();
static void signalHandler(int signal);
Q_SIGNALS:
void exitSafely();
private:
TransferEngineSignalHandler();
};
class ClientActivityMonitor: public QObject
{
Q_OBJECT
public:
ClientActivityMonitor(QObject *parent = 0);
~ClientActivityMonitor();
void newActivity(int transferId);
void activityFinished(int transferId);
bool activeTransfers() const;
public Q_SLOTS:
void checkActivity();
Q_SIGNALS:
void transfersExpired(QList<int> transferIds);
private:
// Map for transferId, timestamps
QMap<int, quint32> m_activityMap;
QTimer *m_timer;
};
class TransferEnginePrivate: QObject
{
Q_OBJECT
public:
// CallbackElement enum is used as an accessor to DBus callback
// information from a list. Enums are used as an indeces.
enum CallbackElements {
Service = 0,
Path,
Interface
};
// CallbackMethodType enum is used as an accessor to the list where
// method names starts from the index 3.
enum CallbackMethodType {
CancelCallback = 3,
RestartCallback = 4
};
TransferEnginePrivate(TransferEngine *parent);
void recoveryCheck();
void sendNotification(TransferEngineData::TransferType type,
TransferEngineData::TransferStatus status,
const QString &fileName);
int uploadMediaItem(MediaItem *mediaItem,
MediaTransferInterface *muif,
const QVariantMap &userData);
inline TransferEngineData::TransferType transferType(int transferId);
void callbackCall(int transferId, CallbackMethodType method);
public Q_SLOTS:
void exitSafely();
void delayedExitSafely();
void enabledPluginsCheck();
void cleanupExpiredTransfers(const QList<int> &expiredIds);
void pluginDirChanged();
void uploadItemStatusChanged(MediaTransferInterface::TransferStatus status);
void updateProgress(qreal progress);
void pluginInfoReady();
void pluginInfoError(const QString &msg);
public:
QStringList pluginList() const;
QList <TransferMethodInfo> enabledPlugins() const;
MediaTransferInterface *loadPlugin(const QString &pluginId) const;
QString mediaFileOrResourceName(MediaItem *mediaItem) const;
private:
QMap <MediaTransferInterface*, int> m_plugins;
QMap <int, TransferEngineData::TransferType> m_keyTypeCache;
bool m_notificationsEnabled;
QList <TransferPluginInfo*> m_infoObjects;
QList <TransferMethodInfo> m_enabledPlugins;
Accounts::Manager *m_accountManager;
QFileSystemWatcher *m_fileWatcher;
QTimer *m_fileWatcherTimer;
QTimer *m_delayedExitTimer;
QSettings m_settings;
ClientActivityMonitor *m_activityMonitor;
TransferEngine *q_ptr;
Q_DECLARE_PUBLIC(TransferEngine)
};
#endif