-
Notifications
You must be signed in to change notification settings - Fork 2
/
transferengine_p.h
138 lines (117 loc) · 3.98 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
/*
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2019 - 2021 Open Mobile Platform LLC.
*
* All rights reserved.
*
* This file is part of Sailfish 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 <QVariantList>
#include "mediatransferinterface.h"
class QFileSystemWatcher;
class QTimer;
class QUrl;
class TransferEngine;
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;
bool isActiveTransfer(int transferId) const;
public Q_SLOTS:
void checkActivity();
Q_SIGNALS:
void transfersExpired(const QList<int> &transferIds);
private:
// Map for transferId, timestamps
QMap<int, quint32> m_activityMap;
QTimer *m_timer = nullptr;
};
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,
qreal progress,
const QString &fileName,
int transferId,
bool canCancel,
const QUrl &localFileUrl = QUrl());
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 cleanupExpiredTransfers(const QList<int> &expiredIds);
void uploadItemStatusChanged(MediaTransferInterface::TransferStatus status);
void updateProgress(qreal progress);
public:
QStringList pluginList() 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 = false;
QTimer *m_delayedExitTimer = nullptr;
ClientActivityMonitor *m_activityMonitor = nullptr;
TransferEngine *q_ptr = nullptr;
QVariantList m_defaultActions;
QVariant m_showTransfersAction;
Q_DECLARE_PUBLIC(TransferEngine)
};
#endif