~ubuntu-branches/ubuntu/raring/recorditnow/raring

« back to all changes in this revision

Viewing changes to joschy-snapshot-23-02-10/joschycore/joschycore/manager.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-09 14:54:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110109145401-gyckb4airz4fio50
Tags: 0.8.1-0ubuntu1
* New upstream release. (LP: #681270)
  - Update debian/copyright.
* Build-depend on recordmydesktop.
* Add a watch file.
* Drop 01_fix_ftbfs_kwarning_call.diff, fixed upstream.
* Add 01_joschy_install_to_usr_lib.diff.
* Add 02_fix_ftbfs_no-add-needed.diff.
* Add 03_dont_install_header_files.diff.
* Replace dependency on libpolkit-qt-1-0 with policykit-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2010  Kai Dombrowe <just89@gmx.de>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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
 
17
*/
 
18
 
 
19
#ifndef MANAGER_H
 
20
#define MANAGER_H
 
21
 
 
22
 
 
23
// own
 
24
#include "joschy_global.h"
 
25
#include "plugininfo.h"
 
26
#include "plugin.h"
 
27
 
 
28
// Qt
 
29
#include <QtCore/QObject>
 
30
 
 
31
 
 
32
namespace Joschy {
 
33
 
 
34
 
 
35
class ManagerPrivate;
 
36
class AbstractProvider;
 
37
class PluginManager;
 
38
 
 
39
 
 
40
/**
 
41
 * @class Manager joschycore/manager.h
 
42
 *
 
43
 * @short Class to load/unload providers and to manage some settings.
 
44
 *
 
45
 *
 
46
 * Load an provider:
 
47
 *
 
48
 * @verbatim
 
49
    QList<Joschy::PluginInfo> providerList = Joschy::Manager::self()->availableProvider();
 
50
    QList<Joschy::PluginInfo> layerList =  Joschy::Manager::self()->availableNetworkLayer();
 
51
 
 
52
    if (providerList.isEmpty() || layerList.isEmpty()) {
 
53
         return;
 
54
    }
 
55
 
 
56
    Joschy::AbstractProvider *provider = Joschy::Manager::self()->createProvider(providerList.first(), layerList.first());
 
57
    if (!provider) {
 
58
        return;
 
59
    }
 
60
 
 
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)));
 
72
   @endverbatim
 
73
 *
 
74
 *
 
75
 * Auth:
 
76
 *
 
77
 * @verbatim
 
78
    Joschy::ActionReply reply = provider->authenticate("login", "password");
 
79
    if (reply.error()) {
 
80
        qDebug() << "Error:" << reply.errorType() << reply.errorString();
 
81
    } else {
 
82
        qDebug() << "Auth started:" << reply.id();
 
83
    }
 
84
   @endverbatim
 
85
 *
 
86
 *
 
87
 * Upload:
 
88
 *
 
89
 * @verbatim
 
90
    Joschy::Video video;
 
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"));
 
96
 
 
97
    Joschy::ActionReply reply = provider->upload("user", &video);
 
98
    if (reply.error()) {
 
99
        qDebug() << "Error:" << reply.errorType() << reply.errorString();
 
100
    } else {
 
101
        qDebug() << "Upload started:" << reply.id();
 
102
    }
 
103
   @endverbatim
 
104
 *
 
105
 *
 
106
 * Search:
 
107
 *
 
108
 * @verbatim
 
109
    QHash<QString, QVariant> data;
 
110
    data["Key"] = "kde4";
 
111
    data["Max"] = 30;
 
112
    reply = provider->search(data);
 
113
    if (reply.error()) {
 
114
        qDebug() << "Error:" << reply.errorType() << reply.errorString();
 
115
    } else {
 
116
        qDebug() << "Search started:" << reply.id();
 
117
    }
 
118
    @endverbatim
 
119
 *
 
120
 *
 
121
 * Update a thumbnail:
 
122
 *
 
123
 * @verbatim
 
124
    QString thumbnailDir("/tmp/joschynails");
 
125
    Joschy::ActionReply reply = provider->updateThumbnail(video, thumbnailDir);
 
126
    if (!reply.error()) {
 
127
       qDebug() << "thumbnail update started:" << reply.id();
 
128
    } else {
 
129
       qDebug() << reply.errorType() << reply.errorString();
 
130
    }
 
131
   @endverbatim
 
132
 *
 
133
 *
 
134
**/
 
135
class JOSCHY_EXPORT Manager: public QObject
 
136
{
 
137
    Q_OBJECT
 
138
    friend class ManagerSingleton;
 
139
 
 
140
 
 
141
public:
 
142
    /**
 
143
     * @return Returns the current Scheduler mode
 
144
     * @see setSchedulerMode
 
145
    **/
 
146
    Joschy::Plugin::SchedulerMode schedulerMode() const;
 
147
    /**
 
148
     * @return Returns all available provider
 
149
    **/
 
150
    QList<Joschy::PluginInfo> availableProvider() const;
 
151
    /**
 
152
     * @return Returns all available Network layer
 
153
    **/
 
154
    QList<Joschy::PluginInfo> availableNetworkLayer() const;
 
155
    /**
 
156
     * Singleton accessor
 
157
     **/
 
158
    static Manager *self();
 
159
    /**
 
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
 
164
     **/
 
165
    Joschy::AbstractProvider *createProvider(const QString &provider, const QString &layer);
 
166
    /**
 
167
     * @see createProvider
 
168
     **/
 
169
    Joschy::AbstractProvider *createProvider(const Joschy::PluginInfo &providerInfo,
 
170
                                             const Joschy::PluginInfo &layerInfo);
 
171
    /**
 
172
     * Unloads a provider instance.
 
173
     **/
 
174
    void unloadProvider(Joschy::AbstractProvider *provider);
 
175
    /**
 
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)
 
179
     * @see schedulerMode
 
180
    **/
 
181
    void setSchedulerMode(const Joschy::Plugin::SchedulerMode &mode, const int &delay = 300);
 
182
 
 
183
 
 
184
private:
 
185
    /**
 
186
     * @internal
 
187
     **/
 
188
    explicit Manager(QObject *parent = 0);
 
189
    ~Manager();
 
190
 
 
191
    ManagerPrivate *d;
 
192
 
 
193
 
 
194
protected:
 
195
    /**
 
196
     * @internal
 
197
     **/
 
198
    Joschy::AbstractProvider *loadProvider(const QString &provider, const QString &layer);
 
199
    /**
 
200
     * @internal
 
201
     **/
 
202
    Joschy::AbstractProvider *loadProvider(const Joschy::PluginInfo &provider,
 
203
                                           const Joschy::PluginInfo &layer);
 
204
 
 
205
 
 
206
 
 
207
};
 
208
 
 
209
 
 
210
} // namespace Joschy
 
211
 
 
212
 
 
213
#endif // MANAGER_H