~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/kipi-plugins/dlnaexport/extra/hupnp_av/src/mediabrowser/hmediabrowser.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-09-27 21:41:30 UTC
  • mfrom: (1.2.43)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: package-import@ubuntu.com-20120927214130-i8v3ufr21nesp29i
Tags: 4:3.0.0~beta1a-1
* New upstream release

* Fix "wrongly conflicts phonon-backend-vlc" dropped (Closes: #688142)
* debian/watch include download.kde.org

* digikam 3.0.0 uses features from unreleased kdegraphics >=4.10 & ships 
a private version of the kdegraphics libs - this is not the Debian way :-(
* Unsatisfactory Conflicts: libkipi8, libkexiv2-10, libkdcraw20, libksane0
* Suspend digikam-dbg >130Mb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
 
3
 *
 
4
 *  Author: Tuomo Penttinen <tp@herqq.org>
 
5
 *
 
6
 *  This file is part of Herqq UPnP Av (HUPnPAv) library.
 
7
 *
 
8
 *  Herqq UPnP Av is free software: you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU General Public License as published by
 
10
 *  the Free Software Foundation, either version 3 of the License, or
 
11
 *  (at your option) any later version.
 
12
 *
 
13
 *  Herqq UPnP Av is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#ifndef HMEDIABROWSER_H_
 
23
#define HMEDIABROWSER_H_
 
24
 
 
25
#include <HUpnpAv/HUpnpAv>
 
26
#include <HUpnpCore/HUpnp>
 
27
 
 
28
#include <QtCore/QSet>
 
29
#include <QtCore/QString>
 
30
#include <QtCore/QObject>
 
31
 
 
32
namespace Herqq
 
33
{
 
34
 
 
35
namespace Upnp
 
36
{
 
37
 
 
38
namespace Av
 
39
{
 
40
 
 
41
class HBrowseParamsPrivate;
 
42
 
 
43
/*!
 
44
 * \brief This class is used to configure a \e browse operation run by a HMediaBrowser.
 
45
 *
 
46
 * \headerfile hmediabrowser.h HBrowseParams
 
47
 *
 
48
 * \ingroup hupnp_av_cds_browsing
 
49
 *
 
50
 * \remarks This class is not thread-safe.
 
51
 *
 
52
 * \sa HMediaBrowser::browse()
 
53
 */
 
54
class H_UPNP_AV_EXPORT HBrowseParams
 
55
{
 
56
public:
 
57
 
 
58
    /*!
 
59
     * \brief This enumeration defines the different browse operations available.
 
60
     */
 
61
    enum BrowseType
 
62
    {
 
63
        /*!
 
64
         * The browse targets a single CDS object.
 
65
         */
 
66
        SingleItem,
 
67
 
 
68
        /*!
 
69
         * The browse targets the children of the CDS container.
 
70
         */
 
71
        DirectChildren,
 
72
 
 
73
        /*!
 
74
         * The browse targets a CDS container \b and its children. Contrast this
 
75
         * to \c DirectChildren, which targets \b only the children.
 
76
         */
 
77
        ObjectAndDirectChildren,
 
78
 
 
79
        /*!
 
80
         * The browse targets a CDS container \b and its children recursively.
 
81
         */
 
82
        ObjectAndChildrenRecursively
 
83
    };
 
84
 
 
85
private:
 
86
 
 
87
    HBrowseParamsPrivate* h_ptr;
 
88
 
 
89
public:
 
90
 
 
91
    /*!
 
92
     * Creates a new, invalid instance.
 
93
     *
 
94
     * \sa isValid()
 
95
     */
 
96
    HBrowseParams();
 
97
 
 
98
    /*!
 
99
     * \brief Creates a new instance.
 
100
     *
 
101
     * \param browseType specifies the type of the browse operation.
 
102
     *
 
103
     * \sa isValid()
 
104
     */
 
105
    HBrowseParams(BrowseType browseType);
 
106
 
 
107
    /*!
 
108
     * \brief Creates a new instance.
 
109
     *
 
110
     * \param objectId specifies the ID of the target object.
 
111
     *
 
112
     * \param browseType specifies the type of the browse operation.
 
113
     *
 
114
     * \sa isValid()
 
115
     */
 
116
    HBrowseParams(const QString& objectId, BrowseType loadType);
 
117
 
 
118
    /*!
 
119
     * \brief Destroys the instance.
 
120
     */
 
121
    ~HBrowseParams();
 
122
 
 
123
    /*!
 
124
     * \brief Copy constructor.
 
125
     *
 
126
     * Creates a copy of \c other.
 
127
     */
 
128
    HBrowseParams(const HBrowseParams&);
 
129
 
 
130
    /*!
 
131
     * \brief Assignment operator.
 
132
     *
 
133
     * Copies the contents of \c other to this.
 
134
     */
 
135
    HBrowseParams& operator=(const HBrowseParams&);
 
136
 
 
137
    /*!
 
138
     * \brief Specifies the ID of the target object.
 
139
     *
 
140
     * \param id specifies the ID of the target object. In case of a recursive
 
141
     * browse, this is the ID of the root object.
 
142
     *
 
143
     * \sa objectId()
 
144
     */
 
145
    void setObjectId(const QString& id);
 
146
 
 
147
    /*!
 
148
     * \brief Specifies the type of the browse operation.
 
149
     *
 
150
     * \param type specifies the type of the browse operation.
 
151
     *
 
152
     * \sa browseType()
 
153
     */
 
154
    void setBrowseType(BrowseType type);
 
155
 
 
156
    /*!
 
157
     * \brief Specifies the \e filter for the operation.
 
158
     *
 
159
     * A filter specifies the CDS metadata properties that should be returned
 
160
     * by the server. A special value of \c "*" means that every available
 
161
     * metadata property should be returned. For more information, see the
 
162
     * ContentDirectory:3 specification, section 2.3.15.
 
163
     *
 
164
     * \param filter specifies the CDS metadata properties that the server
 
165
     * should include in the response.
 
166
     *
 
167
     * \sa filter()
 
168
     */
 
169
    void setFilter(const QSet<QString>& filter);
 
170
 
 
171
    /*!
 
172
     * \brief Indicates the validity of the object.
 
173
     *
 
174
     * \return \e true in case the object is valid, i.e. at least objectId()
 
175
     * is defined.
 
176
     */
 
177
    bool isValid() const;
 
178
 
 
179
    /*!
 
180
     * \brief Returns the ID of the target object.
 
181
     *
 
182
     * \return The ID of the target object.
 
183
     *
 
184
     * \sa setObjectId()
 
185
     */
 
186
    QString objectId() const;
 
187
 
 
188
    /*!
 
189
     * \brief Returns the type of the browse operation.
 
190
     *
 
191
     * \return The type of the browse operation.
 
192
     *
 
193
     * \sa setBrowseType()
 
194
     */
 
195
    BrowseType browseType() const;
 
196
 
 
197
    /*!
 
198
     * \brief Returns the CDS metadata properties that the server
 
199
     * should include in the response.
 
200
     *
 
201
     * \return The the CDS metadata properties that the server
 
202
     * should include in the response.
 
203
     *
 
204
     * \sa setFilter()
 
205
     */
 
206
    QSet<QString> filter() const;
 
207
};
 
208
 
 
209
class HMediaBrowserPrivate;
 
210
 
 
211
/*!
 
212
 * \brief This class provides a simple API for browsing a ContentDirectory service and
 
213
 * caching the contents of it.
 
214
 *
 
215
 * \headerfile hmediabrowser.h HMediaBrowser
 
216
 *
 
217
 * \ingroup hupnp_av_cds_browsing
 
218
 *
 
219
 * \remarks This class is not thread-safe.
 
220
 */
 
221
class H_UPNP_AV_EXPORT HMediaBrowser :
 
222
    public QObject
 
223
{
 
224
Q_OBJECT
 
225
H_DISABLE_COPY(HMediaBrowser)
 
226
H_DECLARE_PRIVATE(HMediaBrowser)
 
227
 
 
228
private:
 
229
 
 
230
    HMediaBrowserPrivate* h_ptr;
 
231
 
 
232
public:
 
233
 
 
234
    /*!
 
235
     * \brief Creates a new instance.
 
236
     *
 
237
     * \param parent specifies parent \c QObject.
 
238
     *
 
239
     * \sa reset()
 
240
     */
 
241
    explicit HMediaBrowser(QObject* parent = 0);
 
242
 
 
243
    /*!
 
244
     * \brief Destroys the instance.
 
245
     */
 
246
    virtual ~HMediaBrowser();
 
247
 
 
248
    /*!
 
249
     * Resets the ContentDirectory service being browsed.
 
250
     *
 
251
     * \param cds specifies the ContentDirectory service object to be browsed.
 
252
     *
 
253
     * \return \e true if the CDS object was successfully set and it is ready
 
254
     * to be browsed.
 
255
     *
 
256
     * \sa isReady()
 
257
     */
 
258
    bool reset(HClientService* cds);
 
259
 
 
260
    /*!
 
261
     * Resets the ContentDirectory service being browsed.
 
262
     *
 
263
     * \param cds specifies the ContentDirectory service object to be browsed.
 
264
     *
 
265
     * \param takeOwnership specifies whether the \c %HMediaBrowser instance
 
266
     * takes the ownership of the specified ContentDirectory instance.
 
267
     *
 
268
     * \return \e true if the CDS object was successfully set and it is ready
 
269
     * to be browsed.
 
270
     *
 
271
     * \sa isReady()
 
272
     */
 
273
    bool reset(HContentDirectoryAdapter* cds, bool takeOwnership);
 
274
 
 
275
    /*!
 
276
     * Initiates a browse operation based on the provided parameters.
 
277
     *
 
278
     * \params specifies the parameters for the browse operation.
 
279
     *
 
280
     * \return \e true when the operation was successfully dispatched.
 
281
     *
 
282
     * \remarks
 
283
     * This is an asynchronous operation.
 
284
     *
 
285
     * \sa browseComplete(), objectsBrowsed(), cancel()
 
286
     */
 
287
    bool browse(const HBrowseParams& params);
 
288
 
 
289
    /*!
 
290
     * Attempts to browse everything the ContentDirectory service exposes.
 
291
     *
 
292
     * This is a convenience method.
 
293
     *
 
294
     * \return \e true when the operation was successfully dispatched.
 
295
     *
 
296
     * \remarks
 
297
     * This is an asynchronous operation.
 
298
     *
 
299
     * \sa browse(), browseComplete(), objectsBrowsed(), cancel()
 
300
     */
 
301
    bool browseAll();
 
302
 
 
303
    /*!
 
304
     * Attempts to browse the metadata of a root container and everything directly
 
305
     * underneath it.
 
306
     *
 
307
     * This is a convenience method.
 
308
     *
 
309
     * \return \e true when the operation was successfully dispatched.
 
310
     *
 
311
     * \remarks
 
312
     * This is an asynchronous operation.
 
313
     *
 
314
     * \sa browse(), browseComplete()
 
315
     */
 
316
    bool browseRoot();
 
317
 
 
318
    /*!
 
319
     * \brief Returns the data source that contains all the loaded data.
 
320
     *
 
321
     * \return The data source that contains all the loaded data. The returned
 
322
     * pointer is \b never null and the ownership of the data source is
 
323
     * \b never transferred to the caller.
 
324
     */
 
325
    HCdsDataSource* dataSource() const;
 
326
 
 
327
    /*!
 
328
     * \brief Returns the ContentDirectory that is the target of browsing.
 
329
     *
 
330
     * \return The ContentDirectory that is the target of browsing.
 
331
     * This is null when the ContentDirectory service has not been set.
 
332
     *
 
333
     * \sa reset()
 
334
     */
 
335
    HContentDirectoryAdapter* contentDirectory() const;
 
336
 
 
337
    /*!
 
338
     * \brief Indicates if the object is ready for browsing.
 
339
     *
 
340
     * \return \e true when the object is ready for browsing.
 
341
     *
 
342
     * \sa reset(), isActive()
 
343
     */
 
344
    bool isReady() const;
 
345
 
 
346
    /*!
 
347
     * \brief Indicates if an browse operation is currently ongoing.
 
348
     *
 
349
     * \return \e true  if an browse operation is currently active.
 
350
     */
 
351
    bool isActive() const;
 
352
 
 
353
    /*!
 
354
     * Returns the last error code that occurred.
 
355
     *
 
356
     * \return the last error code that occurred. This is set to zero if no
 
357
     * error has occurred.
 
358
     *
 
359
     * \sa lastErrorDescription()
 
360
     */
 
361
    qint32 lastErrorCode() const;
 
362
 
 
363
    /*!
 
364
     * Returns the last error description that occurred.
 
365
     *
 
366
     * \return the last error description that occurred. The returned string is
 
367
     * empty if no error has occurred.
 
368
     *
 
369
     * \sa lastErrorDescription()
 
370
     */
 
371
    QString lastErrorDescription() const;
 
372
 
 
373
    /*!
 
374
     * Cancels currently active browse operation.
 
375
     *
 
376
     * This function does nothing if there is no browse operation currently active.
 
377
     */
 
378
    void cancel();
 
379
 
 
380
    /*!
 
381
     * Indicates if the object should automatically process LastChange events and
 
382
     * attempt to update its data source.
 
383
     *
 
384
     * \return \e true if the object should automatically process LastChange events and
 
385
     * attempt to update its data source.
 
386
     *
 
387
     * \sa setAutoUpdate()
 
388
     */
 
389
    bool isAutoUpdateEnabled();
 
390
 
 
391
    /*!
 
392
     * Specifies whether the object should automatically process LastChange events and
 
393
     * attempt to update its data source.
 
394
     *
 
395
     * \param enable specifies whether the object should automatically process
 
396
     * LastChange events and attempt to update its data source.
 
397
     *
 
398
     * \sa isAutoUpdateEnabled()
 
399
     */
 
400
    void setAutoUpdate(bool enable);
 
401
 
 
402
Q_SIGNALS:
 
403
 
 
404
    /*!
 
405
     * \brief This signal is emitted when the previously started load operation failed
 
406
     * before completion.
 
407
     *
 
408
     * \param source specifies the source of the event.
 
409
     *
 
410
     * \sa browseComplete()
 
411
     */
 
412
    void browseFailed(Herqq::Upnp::Av::HMediaBrowser* source);
 
413
 
 
414
    /*!
 
415
     * \brief This signal is emitted when a previously started browse operation is
 
416
     * successfully completed.
 
417
     *
 
418
     * \param source specifies the source of the event.
 
419
     *
 
420
     * \sa browseFailed(), objectsBrowsed()
 
421
     */
 
422
    void browseComplete(Herqq::Upnp::Av::HMediaBrowser* source);
 
423
 
 
424
    /*!
 
425
     * \brief This signal is emitted when new objects have been browsed and cached
 
426
     * by the instance.
 
427
     *
 
428
     * \brief This signal is emitted whenever the contents of a single CDS container
 
429
     * have been browsed and cached. This signal is especially useful in situations
 
430
     * where the browse operation involves multiple CDS containers, as it enables
 
431
     * progressive processing of the results while the operation is running
 
432
     * (before the browseComplete() is emitted).
 
433
     *
 
434
     * \param source specifies the source of the event.
 
435
     *
 
436
     * \param ids specifies the IDs of the objects browsed. You can now retrieve
 
437
     * these objects from the dataSource().
 
438
     *
 
439
     * \sa browseComplete(), browseFailed()
 
440
     */
 
441
    void objectsBrowsed(Herqq::Upnp::Av::HMediaBrowser* source, const QSet<QString>& ids);
 
442
 
 
443
    /*!
 
444
     * This signal is emitted when the instance has received LastChange data
 
445
     * from the ContentDirectoryService.
 
446
     *
 
447
     * \param data specifies the received LastChange data.
 
448
     */
 
449
    void receivedLastChange(const Herqq::Upnp::Av::HCdsLastChangeInfos& data);
 
450
};
 
451
 
 
452
}
 
453
}
 
454
}
 
455
 
 
456
#endif /* HMEDIABROWSER_H_ */