QEverCloud  6.1.0
Unofficial Evernote Cloud API for Qt
Public Types | Public Member Functions | Friends | List of all members
qevercloud::Thumbnail Class Reference

The class is for downloading thumbnails for notes and resources from Evernote servers. More...

#include <Thumbnail.h>

Public Types

enum  ImageType { ImageType::PNG, ImageType::JPEG, ImageType::GIF, ImageType::BMP }
 

Public Member Functions

 Thumbnail ()
 Default constructor. More...
 
 Thumbnail (QString host, QString shardId, QString authenticationToken, int size=300, ImageType imageType=ImageType::PNG)
 Constructs Thumbnail. More...
 
virtual ~Thumbnail ()
 
ThumbnailsetHost (QString host)
 
ThumbnailsetShardId (QString shardId)
 
ThumbnailsetAuthenticationToken (QString authenticationToken)
 
ThumbnailsetSize (int size)
 
ThumbnailsetImageType (ImageType imageType)
 
QByteArray download (Guid guid, const bool isPublic=false, const bool isResourceGuid=false, const qint64 timeoutMsec=30000)
 Downloads the thumbnail for a resource or a note. More...
 
AsyncResultdownloadAsync (Guid guid, const bool isPublic=false, const bool isResourceGuid=false, const qint64 timeoutMsec=30000)
 
std::pair< QNetworkRequest, QByteArray > createPostRequest (qevercloud::Guid guid, bool isPublic=false, bool isResourceGuid=false)
 Prepares a POST request for a thumbnail download. More...
 

Friends

QEVERCLOUD_EXPORT QTextStream & operator<< (QTextStream &strm, const ImageType imageType)
 
QEVERCLOUD_EXPORT QDebug & operator<< (QDebug &dbg, const ImageType imageType)
 

Detailed Description

The class is for downloading thumbnails for notes and resources from Evernote servers.

These thumbnails are not available with general EDAM Thrift interface as explained in the documentation.

Usage:

Thumbnail thumb("www.evernote.com", sharId, authenticationToken);
QByteArray pngImage = thumb.download(noteGuid);

By default 300x300 PNG images are requested.

Member Enumeration Documentation

◆ ImageType

Specifies image type of the returned thumbnail.

Can be PNG, JPEG, GIF or BMP.

Enumerator
PNG 
JPEG 
GIF 
BMP 

Constructor & Destructor Documentation

◆ Thumbnail() [1/2]

qevercloud::Thumbnail::Thumbnail ( )

Default constructor.

host, shardId, authenticationToken have to be specified before calling download or createPostRequest

◆ Thumbnail() [2/2]

qevercloud::Thumbnail::Thumbnail ( QString  host,
QString  shardId,
QString  authenticationToken,
int  size = 300,
ImageType  imageType = ImageType::PNG 
)

Constructs Thumbnail.

Parameters
hostwww.evernote.com or sandbox.evernote.com
shardIdYou can get the value from UserStore service or as a result of an authentication.
authenticationTokenFor working private notes/resources you must supply a valid authentication token. For public resources the value specified is not used.
sizeThe size of the thumbnail. Evernote supports values from from 1 to 300. By default 300 is used.
imageTypeThumbnail image type. See ImageType. By default PNG is used.

◆ ~Thumbnail()

virtual qevercloud::Thumbnail::~Thumbnail ( )
virtual

Member Function Documentation

◆ createPostRequest()

std::pair<QNetworkRequest, QByteArray> qevercloud::Thumbnail::createPostRequest ( qevercloud::Guid  guid,
bool  isPublic = false,
bool  isResourceGuid = false 
)

Prepares a POST request for a thumbnail download.

Parameters
guidThe note or resource guid
isPublicSpecify true for public notes/resources. In this case authentication token is not sent to with the request as it shoud be according to the docs.
isResourceGuidtrue if guid denotes a resource and false if it denotes a note.
Returns
a pair of QNetworkRequest for the POST request and data that must be posted with the request.

◆ download()

QByteArray qevercloud::Thumbnail::download ( Guid  guid,
const bool  isPublic = false,
const bool  isResourceGuid = false,
const qint64  timeoutMsec = 30000 
)

Downloads the thumbnail for a resource or a note.

Parameters
guidThe note or resource guid
isPublicSpecify true for public notes/resources. In this case authentication token is not sent to with the request as it shoud be according to the docs.
isResourceGuidtrue if guid denotes a resource and false if it denotes a note.
timeoutMsecTimeout for download request in milliseconds
Returns
downloaded data.

◆ downloadAsync()

AsyncResult* qevercloud::Thumbnail::downloadAsync ( Guid  guid,
const bool  isPublic = false,
const bool  isResourceGuid = false,
const qint64  timeoutMsec = 30000 
)

Asynchronous version of download function

◆ setAuthenticationToken()

Thumbnail& qevercloud::Thumbnail::setAuthenticationToken ( QString  authenticationToken)
Parameters
authenticationTokenFor working private notes/resources you must supply a valid authentication token. For public resources the value specified is not used.

◆ setHost()

Thumbnail& qevercloud::Thumbnail::setHost ( QString  host)
Parameters
hostwww.evernote.com or sandbox.evernote.com

◆ setImageType()

Thumbnail& qevercloud::Thumbnail::setImageType ( ImageType  imageType)
Parameters
imageTypeThumbnail image type. See ImageType. By default PNG is used.

◆ setShardId()

Thumbnail& qevercloud::Thumbnail::setShardId ( QString  shardId)
Parameters
shardIdYou can get the value from UserStore service or as a result of an authentication.

◆ setSize()

Thumbnail& qevercloud::Thumbnail::setSize ( int  size)
Parameters
sizeThe size of the thumbnail. Evernote supports values from from 1 to 300. By default 300 is used.

Friends And Related Function Documentation

◆ operator<< [1/2]

QEVERCLOUD_EXPORT QDebug& operator<< ( QDebug &  dbg,
const ImageType  imageType 
)
friend

◆ operator<< [2/2]

QEVERCLOUD_EXPORT QTextStream& operator<< ( QTextStream &  strm,
const ImageType  imageType 
)
friend
qevercloud::Thumbnail::Thumbnail
Thumbnail()
Default constructor.