diff -r b5d63d5fc252 -r a469c0e6e7fb smf/smfservermodule/smfclient/client/smfgallery_p.cpp --- a/smf/smfservermodule/smfclient/client/smfgallery_p.cpp Mon Jun 07 11:43:45 2010 +0100 +++ b/smf/smfservermodule/smfclient/client/smfgallery_p.cpp Wed Jun 23 19:51:49 2010 +0530 @@ -25,7 +25,7 @@ #ifdef Q_OS_SYMBIAN #include "smfclientsymbian.h" #else -#include "smfclientqt.h" +#include "SmfClientQt.h" #endif SmfGalleryPrivate::SmfGalleryPrivate(SmfGallery* gallery) @@ -46,89 +46,133 @@ } /** - * Get the picture listing asynchronously. - * The picturesAvailable() signal is emitted with SmfPictureList once the pictures have arrived. + * Get the album listing asynchronously. + * The albumsAvailable() signal is emitted with SmfPictureAlbumList once the albums have arrived. * When the list is big user can specify the page number and per page item data. * If not supplied by the user default values are used. + * @param names the subject or any keywords to be used to filter albums with that name + * @param user the user whose albums are requested * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE */ - void SmfGalleryPrivate::pictures(int pageNum,int perPage) +void SmfGalleryPrivate::albums(QStringList names, SmfContact* user, int pageNum, int perPage) { //We need to pass Opcode and SmfProvider serialized into bytearray - m_baseProvider = m_gallery->getProvider(); - //serialize start QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); write<<*(m_baseProvider); - //serialize end + m_pageInfoFlag = 1; + write<sendRequest(m_serializedDataToServer,intfName,SmfPictureGetPictures); + m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfPictureGetAlbums,maxalloc,m_xtraInfoSerialized); } /** - * Returns a user title/caption for the picture + * Get the picture listing asynchronously. + * The picturesAvailable() signal is emitted with SmfPictureList once the pictures have arrived. + * When the list is big user can specify the page number and per page item data. + * If not supplied by the user default values are used. + * @param albums album(s) whose pictures are being requested + * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. + * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE */ - QString SmfGalleryPrivate::description(SmfPicture& picture) +void SmfGalleryPrivate::pictures(SmfPictureAlbumList albums,int pageNum,int perPage) { - //We need to pass Opcode and SmfProvider+SmfPicture serialized into bytearray - + //We need to pass Opcode and SmfProvider serialized into bytearray m_baseProvider = m_gallery->getProvider(); - //serialize start QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); write<<*(m_baseProvider); - write<sendRequest(m_serializedDataToServer,intfName,SmfPictureDescription); - //TODO:-to be implemented - return QString(); + m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfPictureGetPictures,maxalloc,m_xtraInfoSerialized); } + /** * Upload an image.Implemented as slot to connect to UI controls more easily * uploadFinished() signal is emitted with the success value of the upload * @param image the image to be uploaded */ - void SmfGalleryPrivate::upload(SmfPicture* image) +void SmfGalleryPrivate::upload(SmfPicture* image, SmfPictureAlbum* album) { - //We need to pass Opcode and SmfProvider+SmfPicture serialized into bytearray - - m_baseProvider = m_gallery->getProvider(); - //serialize start - QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); - write<<*(m_baseProvider); - write<<*(image); - //serialize end - QString intfName(galleryInterface); - - //call private impl's send method - m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfPictureUpload); - } + //We need to pass Opcode and SmfProvider serialized into bytearray + m_baseProvider = m_gallery->getProvider(); + QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); + write<<*(m_baseProvider); + m_pageInfoFlag = 0; + write<sendRequest(m_serializedDataToServer,intfName,SmfPictureUpload,maxalloc,m_xtraInfoSerialized); + } /** * Upload an list image.Implemented as slot to connect to UI controls more easily * uploadFinished() signal is emitted with the success value of the upload * @param images the list image to be uploaded */ - void SmfGalleryPrivate::upload(SmfPictureList* images) - { - //We need to pass Opcode and SmfProvider+SmfPictureList serialized into bytearray - - m_baseProvider = m_gallery->getProvider(); - //serialize start - QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); - write<<*(m_baseProvider); - write<<*(images); - //serialize end - QString intfName(galleryInterface); - - //call private impl's send method - m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfPictureMultiUpload); - } +void SmfGalleryPrivate::upload(SmfPictureList* images, SmfPictureAlbum* album) + { + + //We need to pass Opcode and SmfProvider serialized into bytearray + m_baseProvider = m_gallery->getProvider(); + QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); + write<<*(m_baseProvider); + m_pageInfoFlag = 0; + write<sendRequest(m_serializedDataToServer,intfName,SmfPictureMultiUpload,maxalloc,m_xtraInfoSerialized); + + } /** * Posts a comment for an image. uploadFinished() signal is emitted @@ -138,65 +182,68 @@ */ void SmfGalleryPrivate::postComment(SmfPicture image, SmfComment comment) { - //We need to pass Opcode and SmfProvider+SmfPicture+SmfComment serialized into bytearray - + + //We need to pass Opcode and SmfProvider serialized into bytearray m_baseProvider = m_gallery->getProvider(); - //serialize start QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); write<<*(m_baseProvider); - write<sendRequest(m_serializedDataToServer,intfName,SmfPicturePostComment); + m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfPicturePostComment,maxalloc,m_xtraInfoSerialized); + } //from smfobserver void SmfGalleryPrivate::resultsAvailable(QByteArray result,SmfRequestTypeID opcode,SmfError error) { - writeLog("SmfPostProviderPrivate::resultsAvailable"); - - //note:- "result" is serialized and we need to de-serialize it as per opcode - //TODO:- order of serialization Error value followed by data - - QDataStream reader(&result,QIODevice::ReadOnly); - - //Now de-serialize it based on opcode - switch(opcode) - { - case SmfPictureGetPicturesComplete: + writeLog("SmfPostProviderPrivate::resultsAvailable"); + + //note:- "result" is serialized and we need to de-serialize it as per opcode + //Order of serialization Error value followed by data + + QDataStream reader(&result,QIODevice::ReadOnly); + + //Now de-serialize it based on opcode + switch(opcode) + { + case SmfPictureGetPicturesComplete: { if(m_picList) { delete m_picList; m_picList = NULL; } - + m_picList = new SmfPictureList; reader>>*(m_picList); writeLog("m_picList.count="); writeLog(QString::number(m_picList->count())); -// foreach(SmfPicture pic,*m_picList) -// { - -// } //not incorporating paging now SmfResultPage page; - + emit m_gallery->picturesAvailable(m_picList,error,page); } break; - case SmfPictureUploadComplete: - case SmfPicturePostCommentComplete: + case SmfPictureUpload: + case SmfPicturePostComment: { - bool success; - reader>>success; + + int errInt; + reader>>errInt; writeLog("success="); - if(success) - writeLog("true"); - QList successList; + QList successList; + SmfError success = (SmfError)errInt; successList.append(success); emit m_gallery->uploadFinished(successList); @@ -204,15 +251,20 @@ break; case SmfPictureMultiUpload: { - QList successList; - reader>>successList; + QList successListInt; + QList successList; + reader>>successListInt; + foreach(int success,successListInt) + { + successList.append((SmfError)success); + } emit m_gallery->uploadFinished(successList); - } + } break; - // default: - // //should panic? - // - } - } + default: + User::Panic(_L("Gallerprivate="),opcode); + + } +}