2
Copyright (C) 2010 Kai Dombrowe <just89@gmx.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
#include "joschy_global.h"
25
#include "plugininfo.h"
29
#include <QtCore/QObject>
36
class AbstractProvider;
41
* @class Manager joschycore/manager.h
43
* @short Class to load/unload providers and to manage some settings.
49
QList<Joschy::PluginInfo> providerList = Joschy::Manager::self()->availableProvider();
50
QList<Joschy::PluginInfo> layerList = Joschy::Manager::self()->availableNetworkLayer();
52
if (providerList.isEmpty() || layerList.isEmpty()) {
56
Joschy::AbstractProvider *provider = Joschy::Manager::self()->createProvider(providerList.first(), layerList.first());
61
connect(provider, SIGNAL(authenticated(QString)), this, SLOT(authenticated(QString)));
62
connect(provider, SIGNAL(error(QString,Joschy::Plugin::ErrorType,QString)), this,
63
SLOT(error(QString,Joschy::Plugin::ErrorType,QString)));
64
connect(provider, SIGNAL(uploadFinished(QString,Joschy::Video)), this,
65
SLOT(uploadFinished(QString,Joschy::Video)));
66
connect(provider, SIGNAL(searchFinished(QString,QList<Joschy::Video>)), this,
67
SLOT(searchFinished(QString,QList<Joschy::Video>)));
68
connect(provider, SIGNAL(thumbnailUpdated(QString)), this,
69
SLOT(thumbnailUpdateFinished(QString)));
70
connect(provider, SIGNAL(uploadProgress(QString,qlonglong,qlonglong,qlonglong)), this,
71
SLOT(uploadProgress(QString,qlonglong,qlonglong,qlonglong)));
78
Joschy::ActionReply reply = provider->authenticate("login", "password");
80
qDebug() << "Error:" << reply.errorType() << reply.errorString();
82
qDebug() << "Auth started:" << reply.id();
91
video.setTitle("My Title");
92
video.setDescription("My description");
93
video.setCategory("Tech");
94
video.setKeywords(QStringList() << "KDE" << "Qt");
95
video.setUrl(QUrl("/home/joschy/my_video.ogv"));
97
Joschy::ActionReply reply = provider->upload("user", &video);
99
qDebug() << "Error:" << reply.errorType() << reply.errorString();
101
qDebug() << "Upload started:" << reply.id();
109
QHash<QString, QVariant> data;
110
data["Key"] = "kde4";
112
reply = provider->search(data);
114
qDebug() << "Error:" << reply.errorType() << reply.errorString();
116
qDebug() << "Search started:" << reply.id();
121
* Update a thumbnail:
124
QString thumbnailDir("/tmp/joschynails");
125
Joschy::ActionReply reply = provider->updateThumbnail(video, thumbnailDir);
126
if (!reply.error()) {
127
qDebug() << "thumbnail update started:" << reply.id();
129
qDebug() << reply.errorType() << reply.errorString();
135
class JOSCHY_EXPORT Manager: public QObject
138
friend class ManagerSingleton;
143
* @return Returns the current Scheduler mode
144
* @see setSchedulerMode
146
Joschy::Plugin::SchedulerMode schedulerMode() const;
148
* @return Returns all available provider
150
QList<Joschy::PluginInfo> availableProvider() const;
152
* @return Returns all available Network layer
154
QList<Joschy::PluginInfo> availableNetworkLayer() const;
158
static Manager *self();
160
* Creates an Provider instance with the given layer
161
* @note Do not delete the object. Use unloadProvider
162
* @return the Provider or 0 if the provider or the layer could not be loaded
163
* @see unloadProvider
165
Joschy::AbstractProvider *createProvider(const QString &provider, const QString &layer);
167
* @see createProvider
169
Joschy::AbstractProvider *createProvider(const Joschy::PluginInfo &providerInfo,
170
const Joschy::PluginInfo &layerInfo);
172
* Unloads a provider instance.
174
void unloadProvider(Joschy::AbstractProvider *provider);
176
* Sets the Scheduler mode.
177
* @param mode the new mode
178
* @param delay the delay of msecs to wait before the next job is started (only on SlowSchedulerMode)
181
void setSchedulerMode(const Joschy::Plugin::SchedulerMode &mode, const int &delay = 300);
188
explicit Manager(QObject *parent = 0);
198
Joschy::AbstractProvider *loadProvider(const QString &provider, const QString &layer);
202
Joschy::AbstractProvider *loadProvider(const Joschy::PluginInfo &provider,
203
const Joschy::PluginInfo &layer);
210
} // namespace Joschy