QDailymotion
A Qt/C++ library and QML module to access the Dailymotion Data API.
 All Classes Functions Enumerations Properties Groups Pages
Public Slots | List of all members
QDailymotion::ResourcesRequest Class Reference

Handles requests for Dailymotion resources. More...

Inheritance diagram for QDailymotion::ResourcesRequest:
QDailymotion::Request

Public Slots

void list (const QString &resourcePath, const QVariantMap &filters=QVariantMap(), const QStringList &fields=QStringList())
 Requests a list of Dailymotion resources from resourcePath.
void get (const QString &resourcePath, const QVariantMap &filters=QVariantMap(), const QStringList &fields=QStringList())
 Retrieves the Dailymotion resource from resourcePath.
void insert (const QString &resourcePath)
 Inserts a Dailymotion resource into resourcePath using a POST request.
void insert (const QVariantMap &resource, const QString &resourcePath)
 Inserts a new Dailymotion resource.
void update (const QString &resourcePath, const QVariantMap &resource)
 Updates the Dailymotion resource at resourcePath.
void del (const QString &resourcePath)
 Deletes the Dailymotion resource at resourcePath.
- Public Slots inherited from QDailymotion::Request
void cancel ()
 Cancels the current HTTP request.

Additional Inherited Members

- Public Types inherited from QDailymotion::Request
enum  Operation
 The operation type of the last HTTP request. More...
enum  Status
 The status of the last HTTP request. More...
enum  Error
 The error resulting from the last HTTP request. More...
- Signals inherited from QDailymotion::Request
void clientIdChanged ()
 Emitted when the clientId changes.
void clientSecretChanged ()
 Emitted when the clientSecret changes.
void accessTokenChanged (const QString &token)
 Emitted when the accessToken changes.
void refreshTokenChanged (const QString &token)
 Emitted when the refreshToken changes.
void urlChanged ()
 Emitted when the url changes.
void dataChanged ()
 Emitted when the data changes.
void headersChanged ()
 Emitted when the headers change.
void operationChanged ()
 Emitted when the operation changes.
void statusChanged (Status s)
 Emitted when the status changes.
void finished ()
 Emitted when the request is completed.
- Public Member Functions inherited from QDailymotion::Request
void setNetworkAccessManager (QNetworkAccessManager *manager)
 Sets the QNetworkAccessManager instance to be used when making requests to the Dailymotion API.
- Protected Slots inherited from QDailymotion::Request
void head (bool authRequired=true)
 Performs a HTTP HEAD request.
void get (bool authRequired=true)
 Performs a HTTP GET request.
void post (bool authRequired=true)
 Performs a HTTP POST request.
void put (bool authRequired=true)
 Performs a HTTP PUT request.
void deleteResource (bool authRequired=true)
 Performs a HTTP DELETE request.
- Properties inherited from QDailymotion::Request
QString clientId
 The client id used when making requests to the Dailymotion Data API.
QString clientSecret
 The api key used when making requests to the Dailymotion Data API.
QString accessToken
 The access token used when making requests to the Dailymotion Data API.
QString refreshToken
 The refresh token used when making requests to the Dailymotion Data API.
QUrl url
 The url used when making requests to the Dailymotion Data API.
QVariantMap headers
 The headers used when making requests to the Dailymotion Data API.
QVariant data
 The data used when making HTTP PUT/POST requests to the Dailymotion Data API.
Operation operation
 The last HTTP operation type.
Status status
 The status of the last request.
QVariant result
 The result of the last HTTP request.
Error error
 The error resulting from the last HTTP request.
QString errorString
 A description of the error resulting from the last HTTP request.

Detailed Description

Handles requests for Dailymotion resources.

The ResourcesRequest class is used for making requests to the Dailymotion Data API that concern Dailymotion resources.

Example usage:

C++

using namespace QDailymotion;
...
ResourcesRequest request;
request.get("/video/VIDEO_ID");
connect(&request, SIGNAL(finished()), this, SLOT(onRequestFinished()));
...
void MyClass::onRequestFinished() {
if (request.status() == ResourcesRequest::Ready) {
QMapIterator<QString, QVariant> iterator(request.result().toMap());
while (iterator.hasNext()) {
iterator.next();
qDebug() << iterator.key() << "=" << iterator.value();
}
}
else {
qDebug() << request.errorString();
}
}

QML

import QtQuick 1.0
import QDailymotion 1.0
ResourcesRequest {
id: request
onFinished: {
if (status == ResourcesRequest.Ready) {
for (var k in result) {
console.log(att + " = " + result[k]);
}
}
else {
console.log(errorString);
}
}
Component.onCompleted: get("/video/VIDEO_ID")
}

For more details about Dailymotion resources, see the Dailymotion reference documentation here.

Member Function Documentation

void QDailymotion::ResourcesRequest::del ( const QString &  resourcePath)
slot

Deletes the Dailymotion resource at resourcePath.

For example, to remove a video from the authenticated user's favourites:

ResourcesRequest request;
request.del("/me/favorites/VIDEO_ID");
void QDailymotion::ResourcesRequest::get ( const QString &  resourcePath,
const QVariantMap &  filters = QVariantMap(),
const QStringList &  fields = QStringList() 
)
slot

Retrieves the Dailymotion resource from resourcePath.

For example, to retrieve a video:

ResourcesRequest request;
request.get("/videos/VIDEO_ID");
void QDailymotion::ResourcesRequest::insert ( const QString &  resourcePath)
slot

Inserts a Dailymotion resource into resourcePath using a POST request.

For example, to add a video to the authenticated user's favourites:

ResourcesRequest request;
request.insert("/me/favorites/VIDEO_ID");
void QDailymotion::ResourcesRequest::insert ( const QVariantMap &  resource,
const QString &  resourcePath 
)
slot

Inserts a new Dailymotion resource.

For example, to insert a new playlist on behalf of the authenticated user:

ResourcesRequest request;
QVariantMap playlist;
playlist["name"] = "My playlist";
playlist["description"] = "Playlist inserted using QDailymotion";
request.insert(playlist, "/me/playlists");
void QDailymotion::ResourcesRequest::list ( const QString &  resourcePath,
const QVariantMap &  filters = QVariantMap(),
const QStringList &  fields = QStringList() 
)
slot

Requests a list of Dailymotion resources from resourcePath.

For example, to search videos:

ResourcesRequest request;
QVariantMap filters;
filters["limit"] = 10;
filters["sort"] = "date";
filters["search"] = "Qt";
request.list("/videos", filters);
void QDailymotion::ResourcesRequest::update ( const QString &  resourcePath,
const QVariantMap &  resource 
)
slot

Updates the Dailymotion resource at resourcePath.

For example, to update an existing playlist on behalf of the authenticated user:

ResourcesRequest request;
QVariantMap playlist;
playlist["name"] = "My new playlist name";
playlist["description"] = "My new playlist description";
request.update("/me/playlists/PLAYLIST_ID", playlist);