# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1274955072 -10800 # Node ID 397d00875918855b39ad2fd04afbedd3128c0e97 # Parent 4bc7b118b3dfea6f4da98b9f1dbdcd979d7adfda Revision: 201019 Kit: 2010121 diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/inc/hsactivitydbasyncrequestobserver.h --- a/activityfw/activitydatabase/hsactivitydbclient/inc/hsactivitydbasyncrequestobserver.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/inc/hsactivitydbasyncrequestobserver.h Thu May 27 13:11:12 2010 +0300 @@ -43,5 +43,13 @@ int requestType, const QPixmap& pixmap, void* userData)=0; + + /** + * Function inform observer about asynchronous request results + * @param result - request result + * @param requestType - request type + */ + virtual void asyncRequestCompleated(int result, + int requestType)=0; }; #endif // HSACTIVITYDBASYNCREQUESTOBSERVER_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/inc/hsactivitydbclient.h --- a/activityfw/activitydatabase/hsactivitydbclient/inc/hsactivitydbclient.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/inc/hsactivitydbclient.h Thu May 27 13:11:12 2010 +0300 @@ -65,6 +65,14 @@ * @see int HsActivityDbAsyncRequestObserver::asyncRequestCompleated(int, int, QPixmap&) */ void asyncRequestCompleated(int, int, const QPixmap&, void*); + + + /** + * Interface implementation. + * @see int HsActivityDbAsyncRequestObserver::asyncRequestCompleated(int, int) + */ + void asyncRequestCompleated(int result, + int requestType); /** * Interface implementation. @@ -107,8 +115,8 @@ * Interface implementation. * @see int HsActivityDbClientInterface::waitActivity(const QVariantHash &) */ - int waitActivity(const QVariantHash &); - + int waitActivity(const QVariantHash &activity); + /** * Interface implementation. * @see int HsActivityDbClientInterface::launchActivity(const QVariantHash &) @@ -119,6 +127,8 @@ */ //getThumbnail(resolution, thumbnailPath, "image/png", data) int getThumbnail(QSize size, QString imagePath, QString mimeType, void* userDdata); + + int notifyDataChange(); signals: /** @@ -133,6 +143,8 @@ */ void thumbnailRequested(QPixmap thumbnailPixmap, void *userData); + void dataChanged(); + private: /** * Private client implementation. diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbasyncrequest_p.h --- a/activityfw/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbasyncrequest_p.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbasyncrequest_p.h Thu May 27 13:11:12 2010 +0300 @@ -34,32 +34,32 @@ enum TAsyncRequest{ EWaitActivity = WaitActivity, - EWaitGetThumbnail = GetThumbnail + EWaitGetThumbnail = GetThumbnail, + ENotifyDataChange = NotifyChange }; private: - /** - * First step constructor - */ static HsActivityDbAsyncRequestPrivate* - NewL(HsActivityDbAsyncRequestObserver &, - HsActivityDbClientPrivate &, - TAsyncRequest, - void* userData = 0); + NewLC(HsActivityDbAsyncRequestObserver &, + HsActivityDbClientPrivate &, + TAsyncRequest, + void* userData = 0); public: - static HsActivityDbAsyncRequestPrivate* - newWaitActivityL(HsActivityDbAsyncRequestObserver &, - HsActivityDbClientPrivate &); + static void waitActivityLD(HsActivityDbAsyncRequestObserver &, + HsActivityDbClientPrivate &, + const QVariantHash &); + + static void notifyDataChangeLD(HsActivityDbAsyncRequestObserver &, + HsActivityDbClientPrivate &); - static void - getThumbnailLD(HsActivityDbAsyncRequestObserver &observer, - HsActivityDbClientPrivate &session, - QSize size, - QString imagePath, - QString mimeType, - void *userDdata); + static void getThumbnailLD(HsActivityDbAsyncRequestObserver &, + HsActivityDbClientPrivate &, + QSize, + const QString&, + const QString&, + void *); /** @@ -67,20 +67,18 @@ */ ~HsActivityDbAsyncRequestPrivate(); +private: /** * Function create subscription to current ativity changes * @param condition - activity filetering rules */ void waitActivity(const QVariantHash &condition); -private: + /** */ void getThumbnail(QSize size, QString imagePath, QString mimeType); - - /** - */ - QPixmap copyPixmap(CFbsBitmap* bitmap); + void notifyDataChange(); protected: /** * Interface implementation. diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbclient_p.h --- a/activityfw/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbclient_p.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbclient_p.h Thu May 27 13:11:12 2010 +0300 @@ -89,6 +89,8 @@ int waitActivity(const QVariantHash &activity); int getThumbnail(QSize size, QString imagePath, QString mimeType, void *userDdata); + + int notifyDataChange(); /** * Interface implementation. @@ -102,6 +104,8 @@ */ int cancelWaitActivity(); + int cancelNotifyDataChange(); + public: /** * Function get cached data from server @@ -174,11 +178,6 @@ void getThumbnailL(QSize size, QString imagePath, QString mimeType, void *userDdata); private: - /** - * Async request handler - * Own - */ - HsActivityDbAsyncRequestPrivate *mAsyncDataHandler; RPointerArray mAsyncTasks; HsActivityDbAsyncRequestObserver& mObserver; }; diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbasyncrequest_p.cpp --- a/activityfw/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbasyncrequest_p.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbasyncrequest_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -19,7 +19,7 @@ #include "hsactivitydbclient_p.h" #include "hsactivitydbclient.h" #include -#include +#include // ----------------------------------------------------------------------------- @@ -27,7 +27,7 @@ // ----------------------------------------------------------------------------- // HsActivityDbAsyncRequestPrivate* -HsActivityDbAsyncRequestPrivate::NewL(HsActivityDbAsyncRequestObserver &observer, +HsActivityDbAsyncRequestPrivate::NewLC(HsActivityDbAsyncRequestObserver &observer, HsActivityDbClientPrivate &session, TAsyncRequest requestType, void* userData) @@ -36,7 +36,6 @@ new(ELeave)HsActivityDbAsyncRequestPrivate(observer, session, requestType, userData); CleanupStack::PushL(self); self->mDataBuf.CreateL(64); - CleanupStack::Pop(self); return self; } @@ -44,12 +43,36 @@ // // ----------------------------------------------------------------------------- // -HsActivityDbAsyncRequestPrivate* -HsActivityDbAsyncRequestPrivate::newWaitActivityL(HsActivityDbAsyncRequestObserver & observer, - HsActivityDbClientPrivate & session) - { - return HsActivityDbAsyncRequestPrivate::NewL(observer, session, EWaitActivity); - } +void HsActivityDbAsyncRequestPrivate::waitActivityLD( + HsActivityDbAsyncRequestObserver & observer, + HsActivityDbClientPrivate & session, + const QVariantHash &activity) +{ + HsActivityDbAsyncRequestPrivate *self = + HsActivityDbAsyncRequestPrivate::NewLC(observer, + session, + EWaitActivity); + self->mSession.PushL(self); + CleanupStack::Pop(self); + self->waitActivity(activity); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void HsActivityDbAsyncRequestPrivate::notifyDataChangeLD( + HsActivityDbAsyncRequestObserver &observer, + HsActivityDbClientPrivate &session) +{ + HsActivityDbAsyncRequestPrivate *self = + HsActivityDbAsyncRequestPrivate::NewLC(observer, + session, + ENotifyDataChange); + self->mSession.PushL(self); + CleanupStack::Pop(self); + self->notifyDataChange(); +} // ----------------------------------------------------------------------------- // @@ -58,12 +81,14 @@ void HsActivityDbAsyncRequestPrivate::getThumbnailLD(HsActivityDbAsyncRequestObserver &observer, HsActivityDbClientPrivate &session, QSize size, - QString imagePath, - QString mimeType, + const QString &imagePath, + const QString &mimeType, void *userDdata) { HsActivityDbAsyncRequestPrivate *instance = - HsActivityDbAsyncRequestPrivate::NewL(observer, session, EWaitGetThumbnail, userDdata); + HsActivityDbAsyncRequestPrivate::NewLC(observer, session, EWaitGetThumbnail, userDdata); + session.PushL(instance); + CleanupStack::Pop(instance); instance->getThumbnail( size, imagePath, mimeType); } @@ -104,7 +129,10 @@ void HsActivityDbAsyncRequestPrivate::DoCancel() { if (IsActive()) { - mSession.cancelWaitActivity(); + switch (mRequestType) { + case EWaitActivity: mSession.cancelWaitActivity(); break; + case ENotifyDataChange: mSession.cancelNotifyDataChange(); break; + }; } } @@ -114,35 +142,45 @@ // void HsActivityDbAsyncRequestPrivate::RunL() { - int requestResult(iStatus.Int()); - if (KErrNone == requestResult) { - switch (mRequestType){ - case WaitActivity: { + switch (mRequestType) { + case WaitActivity: { + QString data; + if (KErrNone == iStatus.Int()) { RBuf8 buff; CleanupClosePushL(buff); - QString data; if (0 < mDataSize()) { buff.CreateL(mDataSize()); } mSession.getData(mTaskId(), buff); data = QString::fromAscii(reinterpret_cast(buff.Ptr()), buff.Length()); - buff.Close(); - mObserver.asyncRequestCompleated(requestResult, mRequestType, data); CleanupStack::PopAndDestroy(&buff); - break; - } - case EWaitGetThumbnail: { + } + mObserver.asyncRequestCompleated(iStatus.Int(), mRequestType, data); + mSession.Pop(this); + delete this; + break; + } + case EWaitGetThumbnail: { + QPixmap pixmap; + if (KErrNone == iStatus.Int()) { CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; CleanupStack::PushL(bitmap); User::LeaveIfError(bitmap->Duplicate(mBitmapId())); mSession.getData(mTaskId(), mDataBuf);//ACK Bitmap copy - mObserver.asyncRequestCompleated(requestResult, mRequestType, QPixmap::fromSymbianCFbsBitmap(bitmap), mUserData); + pixmap = QPixmap::fromSymbianCFbsBitmap(bitmap); CleanupStack::PopAndDestroy(bitmap); - break; - } + } + mObserver.asyncRequestCompleated(iStatus.Int(), mRequestType, pixmap, mUserData); + mSession.Pop(this); + delete this; + break; } + case ENotifyDataChange: { + mObserver.asyncRequestCompleated(iStatus.Int(),mRequestType); mSession.Pop(this); + delete this; + } } } @@ -174,3 +212,14 @@ mBitmapMimeType = XQConversions::qStringToS60Desc8(mimeType); mSession.sendDataAsync(mRequestType, TIpcArgs(&mBitmapId, &mTaskId, mBitmapPath, mBitmapMimeType), iStatus); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void HsActivityDbAsyncRequestPrivate::notifyDataChange() +{ + iStatus = KRequestPending; + SetActive(); + mSession.sendDataAsync(ENotifyDataChange, TIpcArgs(), iStatus); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbclient_p.cpp --- a/activityfw/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbclient_p.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbclient_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -20,7 +20,7 @@ #include "hsactivityglobals.h" #include "hsserializer.h" #include -#include +#include // ----------------------------------------------------------------------------- @@ -30,8 +30,7 @@ HsActivityDbClientPrivate::HsActivityDbClientPrivate(HsActivityDbAsyncRequestObserver &observer): mObserver(observer) { - mAsyncDataHandler = HsActivityDbAsyncRequestPrivate::newWaitActivityL( - observer, *this); + } // ----------------------------------------------------------------------------- @@ -41,7 +40,6 @@ HsActivityDbClientPrivate::~HsActivityDbClientPrivate() { mAsyncTasks.ResetAndDestroy(); - delete mAsyncDataHandler; Close(); } @@ -156,6 +154,16 @@ // // ----------------------------------------------------------------------------- // +int HsActivityDbClientPrivate::notifyDataChange() +{ + TRAPD(errNo,HsActivityDbAsyncRequestPrivate::notifyDataChangeLD(mObserver, *this);) + return errNo; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// int HsActivityDbClientPrivate::launchActivity(const QVariantHash &activity) { TRAPD(errNo, execSimpleRequestL(LaunchActivity, activity);) @@ -175,6 +183,15 @@ // // ----------------------------------------------------------------------------- // +int HsActivityDbClientPrivate::cancelNotifyDataChange() +{ + return SendReceive(CancelNotify, TIpcArgs()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// void HsActivityDbClientPrivate::startServerL() { RProcess server; @@ -295,11 +312,7 @@ // void HsActivityDbClientPrivate::waitActivityL(const QVariantHash &activity) { - if (mAsyncDataHandler->IsActive()) { - User::Leave(KErrServerBusy); - } else { - mAsyncDataHandler->waitActivity(activity); - } + HsActivityDbAsyncRequestPrivate::waitActivityLD(mObserver,*this, activity); } // ----------------------------------------------------------------------------- diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbclient/src/hsactivitydbclient.cpp --- a/activityfw/activitydatabase/hsactivitydbclient/src/hsactivitydbclient.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbclient/src/hsactivitydbclient.cpp Thu May 27 13:11:12 2010 +0300 @@ -57,9 +57,13 @@ { switch (requestType) { case WaitActivity: + if(KErrCancel != result) { + waitActivity(QVariantHash()); + } if (KErrNone == result) { emit activityRequested(data); } + break; } } @@ -75,9 +79,8 @@ { switch (requestType) { case GetThumbnail: - if (KErrNone == result) { - emit thumbnailRequested(pixmap, userData); - } + emit thumbnailRequested(0 == result ? pixmap : QPixmap(), + userData); break; } } @@ -86,6 +89,24 @@ // // ----------------------------------------------------------------------------- // +void HsActivityDbClient::asyncRequestCompleated(int result,int requestType) +{ + switch(requestType) { + case NotifyChange: + if (KErrCancel != result) { + d_ptr->notifyDataChange(); + } + if (KErrNone == result) { + emit dataChanged(); + } + break; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// int HsActivityDbClient::addActivity(const QVariantHash &activity) { return d_ptr->addActivity(activity); @@ -143,7 +164,11 @@ // int HsActivityDbClient::waitActivity(const QVariantHash &activity) { - return d_ptr->waitActivity(activity); + QVariantHash condition(activity); + RProcess process; + condition.insert(ActivityApplicationKeyword, + static_cast(process.SecureId().iId)); + return d_ptr->waitActivity(condition); } // ----------------------------------------------------------------------------- @@ -159,8 +184,16 @@ // // ----------------------------------------------------------------------------- // -//int HsActivityDbClient::getThumbnail(const QVariantHash &condition) int HsActivityDbClient::getThumbnail(QSize size, QString imagePath, QString mimeType, void* userDdata) { return d_ptr->getThumbnail(size, imagePath, mimeType, userDdata); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +int HsActivityDbClient::notifyDataChange() +{ + return d_ptr->notifyDataChange(); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/inc/activitygraphicfilescaling.h --- a/activityfw/activitydatabase/hsactivitydbserver/inc/activitygraphicfilescaling.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/inc/activitygraphicfilescaling.h Thu May 27 13:11:12 2010 +0300 @@ -56,8 +56,18 @@ ~CGraphicsSalingHandler(); - static CGraphicsSalingHandler* NewL(MImageReadyCallBack &aNotify, RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType, const TSize &aNewSize, TKindOfScaling aKindOfScaling); - static CGraphicsSalingHandler* NewLC(MImageReadyCallBack &aNotify, RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType, const TSize &aNewSize, TKindOfScaling aKindOfScaling); + static CGraphicsSalingHandler* NewL(MImageReadyCallBack &aNotify, + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling = CGraphicsSalingHandler::EIgnoreAspectRatio); + static CGraphicsSalingHandler* NewLC(MImageReadyCallBack &aNotify, + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling = CGraphicsSalingHandler::EIgnoreAspectRatio); protected: void DoCancel(); @@ -66,7 +76,9 @@ private: void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType); - CGraphicsSalingHandler(MImageReadyCallBack &aNotify, const TSize &aNewSize, TKindOfScaling aKindOfScaling); + CGraphicsSalingHandler(MImageReadyCallBack &aNotify, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling = CGraphicsSalingHandler::EIgnoreAspectRatio); TSize Scaling(); private: diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/inc/activitystoragesynctask.h --- a/activityfw/activitydatabase/hsactivitydbserver/inc/activitystoragesynctask.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/inc/activitystoragesynctask.h Thu May 27 13:11:12 2010 +0300 @@ -23,6 +23,7 @@ #include "activitytask.h" #include "activitystorage.h" +#include "activitytaskstorage.h" /** * CActivityStorageSyncTask @@ -36,7 +37,8 @@ * @param dataStorage - data storage * @param msg - request message */ - static void ExecuteL(CActivityStorage& dataStorage, + static void ExecuteL(MActivityTaskStorage& observers, + CActivityStorage& dataStorage, const RMessage2& msg); private: @@ -71,6 +73,9 @@ */ static void DeleteApplicationActivitiesL(CActivityStorage& dataStorage, const RMessage2& msg); + + static void NotifyChangeL(MActivityTaskStorage& observers, + const RMessage2& msg); }; diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitybroadcasttask.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitybroadcasttask.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitybroadcasttask.cpp Thu May 27 13:11:12 2010 +0300 @@ -24,7 +24,7 @@ const RMessage2& msg) { const RPointerArray &tasks(storage.StorageData()); - for (TInt iter(0); iter < tasks.Count(); ++iter) { + for (TInt iter(tasks.Count() - 1); iter >= 0 ; --iter ) { (tasks[iter])->BroadcastReceivedL(msg); } msg.Complete(KErrNone); diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitydataprovidertask.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitydataprovidertask.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitydataprovidertask.cpp Thu May 27 13:11:12 2010 +0300 @@ -47,6 +47,8 @@ void ActivityDataProviderTask::ProvideDataL(const RMessage2& msg, const CActivityTask& src) { - msg.WriteL(KResponseDataOffset, src.Data()); - msg.Complete(KErrNone); + if (EFalse ==msg.IsNull()) { + msg.WriteL(KResponseDataOffset, src.Data()); + msg.Complete(KErrNone); + } } diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitygraphicfilescaling.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitygraphicfilescaling.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitygraphicfilescaling.cpp Thu May 27 13:11:12 2010 +0300 @@ -21,9 +21,10 @@ // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // -CGraphicsSalingHandler::CGraphicsSalingHandler(MImageReadyCallBack &aNotify, - const TSize &aNewSize, - TKindOfScaling aKindOfScaling): +CGraphicsSalingHandler::CGraphicsSalingHandler(MImageReadyCallBack &aNotify, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling + /* = CGraphicsSalingHandler::EIgnoreAspectRatio*/) : CActive(EPriorityNormal), mNotify(aNotify), mNewSize(aNewSize), @@ -48,17 +49,18 @@ // ----------------------------------------------------------------------------- // CGraphicsSalingHandler* CGraphicsSalingHandler::NewL(MImageReadyCallBack &aNotify, - RFs &aFs, - const TDesC &aFileName, - const TDesC8& aMimeType, - const TSize &aNewSize, - TKindOfScaling aKindOfScaling) + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling + /* = CGraphicsSalingHandler::EIgnoreAspectRatio*/) { - CGraphicsSalingHandler *self = CGraphicsSalingHandler::NewLC(aNotify, - aFs, - aFileName, - aMimeType, - aNewSize, + CGraphicsSalingHandler *self = CGraphicsSalingHandler::NewLC(aNotify, + aFs, + aFileName, + aMimeType, + aNewSize, aKindOfScaling); CleanupStack::Pop(); return self; @@ -68,15 +70,19 @@ // ----------------------------------------------------------------------------- // CGraphicsSalingHandler* CGraphicsSalingHandler::NewLC(MImageReadyCallBack &aNotify, - RFs &aFs, - const TDesC &aFileName, - const TDesC8& aMimeType, - const TSize &aNewSize, - TKindOfScaling aKindOfScaling) + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling + /* = CGraphicsSalingHandler::EIgnoreAspectRatio*/) { - CGraphicsSalingHandler *self = new (ELeave) CGraphicsSalingHandler(aNotify, - aNewSize, + CGraphicsSalingHandler *self = new (ELeave) CGraphicsSalingHandler(aNotify, + aNewSize, aKindOfScaling); + + + CleanupStack::PushL(self); self->ConstructL(aFs, aFileName, aMimeType); return self; @@ -87,13 +93,21 @@ // void CGraphicsSalingHandler::ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType) { - CActiveScheduler::Add(this); - if (aFileName.Length() == 0 || aFs.IsValidName(aFileName) == EFalse) { User::Leave(KErrPathNotFound); } + if (aMimeType.Length() == 0) { + User::Leave(KErrBadName); + } + + if(0>=mNewSize.iWidth || 0>=mNewSize.iHeight) { + User::Leave(KErrCorrupt); + } + + CActiveScheduler::Add(this); + mBitmapScaler = CBitmapScaler::NewL(); mBitmapScaler->SetQualityAlgorithm(CBitmapScaler::EMaximumQuality); @@ -103,7 +117,7 @@ const TFrameInfo frameInfo(mImageDecoder->FrameInfo(0)); User::LeaveIfError(mBitmapFromFile->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode)); - + mImageDecoder->Convert(&iStatus, *mBitmapFromFile, 0); mCurrentOperation = EConvertBitmapFromFile; SetActive(); @@ -149,13 +163,17 @@ } case EScale: { mCurrentOperation = ENone; - + delete mBitmapScaler; mBitmapScaler = 0; delete mBitmapFromFile; mBitmapFromFile = 0; - + + if (mKindOfScaling == CGraphicsSalingHandler::EKeepAspectRatioByExpanding) { + User::LeaveIfError(mBitmapOutput->Resize(mNewSize)); + } + mNotify.ImageReadyCallBack(iStatus.Int(), mBitmapOutput); break; } @@ -170,7 +188,9 @@ TSize originalSize = mBitmapFromFile->SizeInPixels(); float widthFactor = mNewSize.iWidth / (float)originalSize.iWidth; float heightFactor = mNewSize.iHeight / (float)originalSize.iHeight; + TSize retSize(mNewSize); + if (mKindOfScaling == CGraphicsSalingHandler::EKeepAspectRatio) { retSize = (widthFactor < heightFactor) ? TSize(mNewSize.iWidth, widthFactor * originalSize.iHeight) : diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activityobservertask.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activityobservertask.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activityobservertask.cpp Thu May 27 13:11:12 2010 +0300 @@ -72,10 +72,14 @@ // void CActivityObserverTask::BroadcastReceivedL(const RMessage2& msg) { - if (WaitActivity == mMsg.Function() && - LaunchActivity == msg.Function()) { - TPckgBuf observerdId; - mMsg.ReadL(KRequestAppIdOffset, observerdId); + if(EFalse != mMsg.IsNull()) { + mGlobalStorage.Pop(this);// + mLocalStorage.Pop(this); + delete this; + } else if (WaitActivity == mMsg.Function() && + LaunchActivity == msg.Function()) { + TPckgBuf observerdId; + mMsg.ReadL(KRequestAppIdOffset, observerdId); TPckgBuf requestedId; msg.ReadL(KRequestAppIdOffset, requestedId); @@ -95,6 +99,20 @@ mGlobalStorage.Pop(this); mMsg.Complete(KErrCancel); delete this; + } else if (NotifyChange == mMsg.Function() && + CancelNotify == msg.Function() && + mMsg.Session() == msg.Session()) { + mGlobalStorage.Pop(this); + mMsg.Complete(KErrCancel); + delete this; + } else if(NotifyChange == mMsg.Function() && + (AddActivity == msg.Function() || + UpdateActivity == msg.Function() || + RemoveActivity == msg.Function() || + RemoveApplicationActivities == msg.Function())){ + mMsg.Complete(KErrNone); + mGlobalStorage.Pop(this); + delete this; } } diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitysession.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitysession.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitysession.cpp Thu May 27 13:11:12 2010 +0300 @@ -87,7 +87,7 @@ case UpdateActivity: case RemoveActivity: case RemoveApplicationActivities: - ActivityStorageSyncTask::ExecuteL(mStorage, message); + ActivityStorageSyncTask::ExecuteL(mTasksStorage, mStorage, message); break; case Activities: @@ -96,6 +96,7 @@ break; case WaitActivity: + case NotifyChange: CActivityObserverTask::ExecuteLD(mTasksStorage, *this, message); break; case GetThumbnail: @@ -104,6 +105,7 @@ case LaunchActivity: case CancelWait: + case CancelNotify: ActivityBroadcastTask::ExecuteL(mTasksStorage, message); break; diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitystorageasynctask.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitystorageasynctask.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitystorageasynctask.cpp Thu May 27 13:11:12 2010 +0300 @@ -121,6 +121,10 @@ // void CActivityStorageAsyncTask::WriteResponseL(const RMessage2& msg) { - msg.WriteL(KResponseDataSizeOffset, TPckgBuf(mData.Length()));//write data size - msg.WriteL(KResponseIdOffset, TPckgBuf(this));//task identyfier + if (EFalse == msg.IsNull()) { + msg.WriteL(KResponseDataSizeOffset, + TPckgBuf(mData.Length()));//write data size + msg.WriteL(KResponseIdOffset, + TPckgBuf(this));//task identyfier + } } diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitystoragesynctask.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitystoragesynctask.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitystoragesynctask.cpp Thu May 27 13:11:12 2010 +0300 @@ -23,7 +23,9 @@ // // ----------------------------------------------------------------------------- // -void ActivityStorageSyncTask::ExecuteL(CActivityStorage& dataStorage, const RMessage2& msg) +void ActivityStorageSyncTask::ExecuteL(MActivityTaskStorage& observers, + CActivityStorage& dataStorage, + const RMessage2& msg) { switch (msg.Function()) { case AddActivity: @@ -43,6 +45,7 @@ User::Panic(KUnsupportedStorageSyncTask, KErrGeneral); }; msg.Complete(KErrNone); + NotifyChangeL(observers, msg); } // ----------------------------------------------------------------------------- @@ -124,3 +127,16 @@ msg.ReadL(KRequestAppIdOffset, appId); dataStorage.DeleteActivitiesL(appId()); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void ActivityStorageSyncTask::NotifyChangeL(MActivityTaskStorage& observers, + const RMessage2& msg) +{ + const RPointerArray &table(observers.StorageData()); + for (TInt iter(table.Count() - 1); 0 <= iter; --iter) { + table[iter]->BroadcastReceivedL(msg); + } +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/hsactivitydbserver/src/activitythumbnailtask.cpp --- a/activityfw/activitydatabase/hsactivitydbserver/src/activitythumbnailtask.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/hsactivitydbserver/src/activitythumbnailtask.cpp Thu May 27 13:11:12 2010 +0300 @@ -75,14 +75,7 @@ mMsg.ReadL(2, path); mime.CreateL(mMsg.GetDesLengthL(3)); mMsg.ReadL(3, mime); - if(0 >= width() || - 0 >=height() || - 0 >= path.Length() || - 0 >= mime.Length() - ) { - User::Leave(KErrCorrupt); - } - + mService = CGraphicsSalingHandler::NewL(*this, session, path, @@ -100,12 +93,15 @@ // void CActivityThumbnailTask::ImageReadyCallBack(TInt error,const CFbsBitmap *bitmap) { - if (KErrNone == error) { + if (EFalse == mMsg.IsNull() && + KErrNone == error) { mMsg.Write(0, TPckgBuf(const_cast(bitmap)->Handle())); mMsg.Write(1, TPckgBuf(this)); mMsg.Complete(error); } else { - mMsg.Complete(error); + if (EFalse == mMsg.IsNull()) { + mMsg.Complete(error); + } mStorage.Pop(this); delete this; } @@ -124,7 +120,7 @@ // // ----------------------------------------------------------------------------- // -void CActivityThumbnailTask::BroadcastReceivedL(const RMessage2& ) +void CActivityThumbnailTask::BroadcastReceivedL(const RMessage2&) { } diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/inc/activitycmd.h --- a/activityfw/activitydatabase/inc/activitycmd.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/inc/activitycmd.h Thu May 27 13:11:12 2010 +0300 @@ -38,7 +38,9 @@ LaunchActivity, GetThumbnail, GetData, - CancelWait + NotifyChange, + CancelWait, + CancelNotify }; #endif //ACTIVITYCMD_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/inc/hsactivitydbclientinterface.h --- a/activityfw/activitydatabase/inc/hsactivitydbclientinterface.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/inc/hsactivitydbclientinterface.h Thu May 27 13:11:12 2010 +0300 @@ -24,6 +24,7 @@ const char ActivityApplicationKeyword [] = ":ApplicationId"; const char ActivityActivityKeyword [] = ":ActivityName"; +const char ActivityParametersKeyword [] = ":ActivityParams"; const char ActivityScreenshotKeyword [] = "screenshot"; class HsActivityDbClientInterface diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/s60/inc/hsserializer.h --- a/activityfw/activitydatabase/s60/inc/hsserializer.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/s60/inc/hsserializer.h Thu May 27 13:11:12 2010 +0300 @@ -18,15 +18,6 @@ #define HSSERIALIZER_H #include #include -/** - * Operator serialize QPixmap to RBuf8 - */ -RBuf8 &operator <<(RBuf8 &dst, const QPixmap &src); - -/** - * Operator deserialize TDesc8 to QPixmap - */ -QPixmap &operator <<(QPixmap &dst, const TDesC8 &src); /** * Operator serialize VarinatHash to RBuf8 @@ -39,11 +30,6 @@ QVariantHash &operator <<(QVariantHash &dst, const TDesC8 &src); /** - * Operator serialize QList to RBuf8 - */ -RBuf8 &operator <<(RBuf8 &dst, const QList& src); - -/** * Operator deserialize RBuf8 to QList */ QList& operator <<(QList& dst, const TDesC8 &src); diff -r 4bc7b118b3df -r 397d00875918 activityfw/activitydatabase/s60/src/hsserializer.cpp --- a/activityfw/activitydatabase/s60/src/hsserializer.cpp Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activitydatabase/s60/src/hsserializer.cpp Thu May 27 13:11:12 2010 +0300 @@ -20,39 +20,6 @@ // // ----------------------------------------------------------------------------- // -RBuf8 &operator <<(RBuf8 &dst, const QPixmap &src) -{ - QByteArray buffer; - QDataStream stream(&buffer, QIODevice::WriteOnly); - - QT_TRYCATCH_LEAVING(stream << src); - const int dataLength(buffer.length()); - const unsigned char *dataPtr(reinterpret_cast(buffer.constData())); - if (dst.MaxLength() < dataLength) { - dst.ReAllocL(dataLength); - } - dst.Copy(dataPtr, dataLength); - return dst; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -QPixmap &operator <<(QPixmap &dst, const TDesC8 &src) -{ - QByteArray buffer(QByteArray::fromRawData(reinterpret_cast(src.Ptr()), - src.Length()) ); - - QDataStream stream(&buffer, QIODevice::ReadOnly); - QT_TRYCATCH_LEAVING(stream >> dst); - return dst; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// RBuf8 &operator <<(RBuf8 &dst, const QVariantHash &src) { QByteArray buffer; @@ -86,24 +53,6 @@ // // ----------------------------------------------------------------------------- // -RBuf8 &operator <<(RBuf8 &dst, const QList& src) -{ - QByteArray buffer; - QDataStream stream(&buffer, QIODevice::WriteOnly); - - QT_TRYCATCH_LEAVING(stream << src); - - if (dst.MaxLength() < buffer.length()) { - dst.ReAllocL(buffer.length()); - } - dst.Copy(reinterpret_cast(buffer.data()), buffer.length()); - return dst; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// QList& operator <<(QList& dst, const TDesC8 &src) { dst.clear(); diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityfw.pro --- a/activityfw/activityfw.pro Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activityfw.pro Thu May 27 13:11:12 2010 +0300 @@ -18,14 +18,18 @@ CONFIG += ordered +SUBDIRS += tsutils + symbian:SUBDIRS += activitydatabase SUBDIRS += activityserviceplugin \ - orbitintegration/hbactivityplugin + orbitintegration/hbactivityplugin \ +tests { + SUBDIRS += activityserviceplugin/tsrc \ + tsutils/tsrc \ +} - -tests:SUBDIRS += activityserviceplugin/unittests symbian:SUBDIRS += activityserviceplugin/symbianinstaller symbian:include(rom.pri) \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityclient.cpp --- a/activityfw/activityserviceplugin/activityclient.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "activityclient.h" -#include "activityclient_p.h" - -ActivityClient::ActivityClient(QObject *parent) : QObject(parent), d_ptr(new ActivityClientPrivate(this)) -{ -} - -ActivityClient::~ActivityClient() -{ -} - -bool ActivityClient::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) -{ - return d_ptr->addActivity(activityId, data, parameters); -} - -bool ActivityClient::removeActivity(const QString &activityId) -{ - return d_ptr->removeActivity(activityId); -} - -bool ActivityClient::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) -{ - return d_ptr->updateActivity(activityId, data, parameters); -} - -QList ActivityClient::activities() const -{ - return d_ptr->activities(); -} - -QVariant ActivityClient::activityData(const QString &activityId) const -{ - return d_ptr->activityData(activityId); -} - -bool ActivityClient::waitActivity() -{ - return d_ptr->waitActivity(); -} - -QVariantHash ActivityClient::parseCommandLine(const QStringList &commandLineParams) const -{ - return d_ptr->parseCommandLine(commandLineParams); -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityclient.h --- a/activityfw/activityserviceplugin/activityclient.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYCLIENT_H -#define ACTIVITYCLIENT_H - -#include -#include -#include - -class ActivityClientPrivate; - -class ActivityClient : public QObject -{ - - Q_OBJECT - -public: - ActivityClient(QObject *parent = 0); - ~ActivityClient(); - -public slots: - bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); - bool removeActivity(const QString &activityId); - bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); - QList activities() const; - QVariant activityData(const QString &activityId) const; - bool waitActivity(); - QVariantHash parseCommandLine(const QStringList &commandLineParams) const; - -signals: - void activityRequested(const QString &activityId); - -private: - ActivityClientPrivate *d_ptr; - friend class ActivityClientPrivate; - -}; - -#endif // ACTIVITYCLIENT_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityclient_p.cpp --- a/activityfw/activityserviceplugin/activityclient_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "activityclient_p.h" -#include "activityclient.h" -#include "activitydatastorage.h" -#include - -#include -#include -#include -#include -#include -#include - -ActivityClientPrivate::ActivityClientPrivate(ActivityClient *q) : QObject(q), mIsconnected(false) -{ - mDataStorage = new ActivityDataStorage(); - mServerClient = new HsActivityDbClient(); - mIsconnected = ( KErrNone == mServerClient->connect()); - connect(mServerClient, SIGNAL(activityRequested(QString)), q, SIGNAL(activityRequested(QString))); -} - -ActivityClientPrivate::~ActivityClientPrivate() -{ - delete mServerClient; - delete mDataStorage; -} - -bool ActivityClientPrivate::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) -{ - bool result(false); - if (mIsconnected) { - result = mDataStorage->addActivity(activityId, data); - if ( result ) { - QVariantHash activity(parameters); - RProcess process; - registerThumbnail(activityId, activity); - activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); - activity.insert(ActivityActivityKeyword, activityId); - int error = mServerClient->addActivity(activity); - result = error == KErrNone ? true : false; - } - } - // @todo make those operations atomic - return result; -} - -bool ActivityClientPrivate::removeActivity(const QString &activityId) -{ - bool result(false); - if (mIsconnected) { - result = mDataStorage->removeActivity(activityId); - if ( result ) { - QVariantHash activity; - RProcess process; - activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); - activity.insert(ActivityActivityKeyword, activityId); - int error = mServerClient->removeActivity(activity); - result = error == KErrNone ? true : false; - if (result) { - result = QFile::remove(thumbnailName(activityId)); - } - } - } - // @todo make those operations atomic - return result; -} - -bool ActivityClientPrivate::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) -{ - bool result(false); - if (mIsconnected) { - result = mDataStorage->updateActivity(activityId, data); - if ( result ) { - QVariantHash activity(parameters); - RProcess process; - registerThumbnail(activityId, activity); - activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); - activity.insert(ActivityActivityKeyword, activityId); - int error = mServerClient->updateActivity(activity); - result = error == KErrNone ? true : false; - } - } - // @todo make those operations atomic - return result; -} - -QList ActivityClientPrivate::activities() const -{ - QList activities; - if (mIsconnected) { - QVariantHash activity; - RProcess process; - activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); - mServerClient->applicationActivities(activities, activity); - } - return activities; -} - -QVariant ActivityClientPrivate::activityData(const QString &activityId) const -{ - return mIsconnected ? mDataStorage->activityData(activityId) : QVariant(); -} - -bool ActivityClientPrivate::waitActivity() -{ - bool retVal(mIsconnected); - if (mIsconnected) { - RProcess process; - QVariantHash activity; - activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); - retVal = !mServerClient->waitActivity(activity); - } - return retVal; -} - -QVariantHash ActivityClientPrivate::parseCommandLine(const QStringList &commandLineParams) const -{ - QVariantHash activityParams; - int activityMarkerIndex = commandLineParams.indexOf("-activity"); - if (activityMarkerIndex != -1 && commandLineParams.count() - 1 > activityMarkerIndex) { - QUrl activityUri(commandLineParams.at(activityMarkerIndex+1)); - if (activityUri.scheme() == "appto") { - QList > parameters = activityUri.queryItems(); - for (QList >::const_iterator i = parameters.constBegin(); i != parameters.constEnd(); ++i) { - activityParams.insert(i->first, i->second); - } - - if (activityParams.contains("activityname") && !activityParams.value("activityname").toString().isEmpty()) { - return activityParams; - } - } - } - return QVariantHash(); -} - -void ActivityClientPrivate::registerThumbnail(const QString &name, QVariantHash &activity) -{ - QVariantHash::const_iterator findIterator(activity.constFind(ActivityScreenshotKeyword)); - if (activity.constEnd() != findIterator && - findIterator.value().canConvert()) { - const QString thumbnailManagerName = thumbnailName(name); - if (findIterator.value().value().save(thumbnailManagerName)) { - activity.insert(ActivityScreenshotKeyword, thumbnailManagerName); - } else { - activity.remove(ActivityScreenshotKeyword); - } - } -} - -QString ActivityClientPrivate::thumbnailName(const QString &activityId) const -{ - return QDir::toNativeSeparators(qApp->applicationDirPath() + - "/" + - QString::number(qHash(activityId), 16) + - ".png"); -} - diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityclient_p.h --- a/activityfw/activityserviceplugin/activityclient_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYCLIENT_P_H -#define ACTIVITYCLIENT_P_H - -#include -#include -#include -#include - -class ActivityClient; -class ActivityDataStorage; -class ActivityServerClient; -class HsActivityDbClient; -class ActivityClientPrivate : public QObject -{ - - Q_OBJECT - -public: - ActivityClientPrivate(ActivityClient *q); - ~ActivityClientPrivate(); - -public: - bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); - bool removeActivity(const QString &activityId); - bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); - QList activities() const; - QVariant activityData(const QString &activityId) const; - bool waitActivity(); - QVariantHash parseCommandLine(const QStringList &commandLineParams) const; - -private: - void registerThumbnail(const QString &, QVariantHash&); - QString thumbnailName(const QString &) const; - -private: - ActivityDataStorage *mDataStorage; - HsActivityDbClient *mServerClient; - bool mIsconnected; -}; - -#endif // ACTIVITYCLIENT_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activitydatastorage.cpp --- a/activityfw/activityserviceplugin/activitydatastorage.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "activitydatastorage.h" - -#include -#include -#include -#include - -const char KConnectionName[] = "ActivityDataStorage"; - -ActivityDataStorage::ActivityDataStorage() -{ - QSqlDatabase database; - if (QSqlDatabase::contains(KConnectionName)) { - database = QSqlDatabase::database(KConnectionName); - } else { - database = QSqlDatabase::addDatabase("QSQLITE", KConnectionName); - database.setDatabaseName("activitydatastorage.db"); - if (!database.open()) { - qFatal(qPrintable(database.lastError().text())); - } - } - - if (!checkTables()) { - recreateTables(); - } -} - -ActivityDataStorage::~ActivityDataStorage() -{ - QSqlDatabase::database(KConnectionName).close(); -} - -bool ActivityDataStorage::addActivity(const QString &activityId, const QVariant &data) -{ - QSqlDatabase database = QSqlDatabase::database(KConnectionName); - - QByteArray streamedData; - { - QDataStream stream(&streamedData, QIODevice::WriteOnly); - stream << data; - } - - // insert data - QSqlQuery query(database); - if (!query.prepare("INSERT INTO Activities(Name, Data) VALUES(:Name, :Data)")) { - qCritical(qPrintable(query.lastError().text())); - return false; - } - query.bindValue(":Name", activityId); - query.bindValue(":Data", streamedData); - if (!query.exec()) { - qCritical(qPrintable(query.lastError().text())); - return false; - } - - return true; -} - -bool ActivityDataStorage::removeActivity(const QString &activityId) -{ - QString sqlCommand = QString("DELETE FROM Activities WHERE Name = '%1'").arg(activityId); - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - if (!query.exec(sqlCommand)) { - qCritical(qPrintable(query.lastError().text())); - return false; - } - return query.numRowsAffected() > 0; -} - -bool ActivityDataStorage::updateActivity(const QString &activityId, const QVariant &data) -{ - QSqlDatabase database = QSqlDatabase::database(KConnectionName); - - QByteArray streamedData; - { - QDataStream stream(&streamedData, QIODevice::WriteOnly); - stream << data; - } - - // update data - QSqlQuery query(database); - if (!query.prepare("UPDATE Activities SET Data = :Data WHERE Name = :Name")) { - qCritical(qPrintable(query.lastError().text())); - return false; - } - query.bindValue(":Data", streamedData); - query.bindValue(":Name", activityId); - if (!query.exec()) { - qCritical(qPrintable(query.lastError().text())); - return false; - } - - return query.numRowsAffected() > 0; -} - -QVariant ActivityDataStorage::activityData(const QString &activityId) const -{ - QSqlDatabase database = QSqlDatabase::database(KConnectionName); - QSqlQuery query(database); - if (!query.exec(QString("SELECT Data FROM Activities WHERE Name = '%1'").arg(activityId))) { - qCritical(qPrintable(query.lastError().text())); - return QVariant(); - } - - QVariant result; - if (query.next()) { - QByteArray data(query.value(0).toByteArray()); - QDataStream stream(&data, QIODevice::ReadOnly); - stream >> result; - } - return result; -} - -bool ActivityDataStorage::checkTables() -{ - QStringList expectedTables("Activities"); - QStringList actualTables = QSqlDatabase::database(KConnectionName).tables(); - return (expectedTables == actualTables); -} - -void ActivityDataStorage::recreateTables() -{ - QSqlDatabase database = QSqlDatabase::database(KConnectionName); - - if (!database.transaction()) { - qFatal(qPrintable(database.lastError().text())); - } - - // drop any existing tables - { - QSqlQuery dropQuery(database); - foreach(const QString &tableName, database.tables()) { - if (!dropQuery.exec(QString("DROP TABLE %1").arg(tableName))) { - qFatal(qPrintable(dropQuery.lastError().text())); - } - } - } - - // create new table - { - QSqlQuery createQuery(database); - QString statement( - "CREATE TABLE Activities(" - "Name TEXT NOT NULL PRIMARY KEY UNIQUE," - "Data BLOB NOT NULL)"); - - if (!createQuery.exec(statement)) { - qFatal(qPrintable(createQuery.lastError().text())); - } - } - - if (!database.commit()) { - qFatal(qPrintable(database.lastError().text())); - } -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activitydatastorage.h --- a/activityfw/activityserviceplugin/activitydatastorage.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYDATASTORAGE_H -#define ACTIVITYDATASTORAGE_H - -#include -#include - -class ActivityDataStorage -{ - -public: - ActivityDataStorage(); - ~ActivityDataStorage(); - -public: - bool addActivity(const QString &activityId, const QVariant &data); - bool removeActivity(const QString &activityId); - bool updateActivity(const QString &activityId, const QVariant &data); - QVariant activityData(const QString &activityId) const; - -private: - bool checkTables(); - void recreateTables(); - -}; - -#endif // ACTIVITYDATASTORAGE_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activitymanager.cpp --- a/activityfw/activityserviceplugin/activitymanager.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "activitymanager.h" -#include "activitymanager_p.h" - -ActivityManager::ActivityManager(QObject *parent) : QObject(parent), d_ptr(new ActivityManagerPrivate(this)) -{ -} - -ActivityManager::~ActivityManager() -{ -} - -QList ActivityManager::activitiesList() -{ - return d_ptr->activitiesList(); -} - -void ActivityManager::launchActivity(const QString &uri) -{ - d_ptr->launchActivity(uri); -} - -void ActivityManager::launchActivity(int applicationId, const QString &activityId) -{ - d_ptr->launchActivity(applicationId, activityId); -} - -void ActivityManager::getThumbnail(QSize resolution,const QString &thumbnailPath, void *data) -{ - d_ptr->getThumbnail(resolution, thumbnailPath, data); -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activitymanager.h --- a/activityfw/activityserviceplugin/activitymanager.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYMANAGER_H -#define ACTIVITYMANAGER_H - -#include -#include -#include -#include -#include - -class ActivityManagerPrivate; - -class ActivityManager : public QObject -{ - - Q_OBJECT - -public: - ActivityManager(QObject *parent = 0); - ~ActivityManager(); - -public slots: - QList activitiesList(); - void launchActivity(const QString &uri); - void launchActivity(int applicationId, const QString &activityId); - void getThumbnail(QSize resolution,const QString &thumbnailPath, void *data =0); - -signals: - void thumbnailReady(QPixmap, void *); - -private: - ActivityManagerPrivate *d_ptr; - - friend class ActivityManagerPrivate; -}; - -#endif // ACTIVITYMANAGER_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activitymanager_p.cpp --- a/activityfw/activityserviceplugin/activitymanager_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "activitymanager_p.h" -#include "activitymanager.h" -#include - -#include -#include - -ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager *q) : QObject(q), q_ptr(q) -{ - mServerClient = new HsActivityDbClient(); - mServerClient->connect(); - connect(mServerClient, - SIGNAL(thumbnailRequested(QPixmap, void *)), - q, - SIGNAL(thumbnailReady(QPixmap, void *))); -} - -ActivityManagerPrivate::~ActivityManagerPrivate() -{ - delete mServerClient; -} - -QList ActivityManagerPrivate::activitiesList() -{ - QList retVal; - mServerClient->activities(retVal); - return retVal; -} - -void ActivityManagerPrivate::launchActivity(const QString &uri) -{ - // @todo use the same parser as in HbApplicationPrivate (if possible) - QRegExp uriMatcher("^appto://(.+)\\?activityname=(.+)$"); - if (uriMatcher.indexIn(uri) != -1) { - QStringList list = uriMatcher.capturedTexts(); - Q_ASSERT(list.count() == 3); - launchActivity(list.at(1).toUInt(0, 16), list.at(2)); - } else { - qWarning("Activity URI parsing error"); - } -} - -void ActivityManagerPrivate::launchActivity(int applicationId, const QString &activityId) -{ - ApplicationLauncher applicationLauncher; - if (applicationLauncher.isRunning(applicationId)) { - QVariantHash activity; - activity.insert(ActivityApplicationKeyword, applicationId); - activity.insert(ActivityActivityKeyword, activityId); - mServerClient->launchActivity(activity); - applicationLauncher.bringToForeground(applicationId); - } else { - applicationLauncher.startApplication(applicationId, activityId); - } -} - -void ActivityManagerPrivate::getThumbnail(QSize resolution,const QString &thumbnailPath, void *data) -{ - mServerClient->getThumbnail(resolution, thumbnailPath, "image/png", data); -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activitymanager_p.h --- a/activityfw/activityserviceplugin/activitymanager_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYMANAGER_P_H -#define ACTIVITYMANAGER_P_H - -#include -#include -#include -#include -#include "applicationlauncher.h" - -class ActivityManager; -class HsActivityDbClient; - -class ActivityManagerPrivate : public QObject -{ - - Q_OBJECT - -public: - ActivityManagerPrivate(ActivityManager *q); - ~ActivityManagerPrivate(); - -public slots: - QList activitiesList(); - void launchActivity(const QString &uri); - void launchActivity(int applicationId, const QString &activityId); - void getThumbnail(QSize resolution,const QString &thumbnailPath, void *data); - -private: - ActivityManager *q_ptr; - HsActivityDbClient *mServerClient; -}; - -#endif // ACTIVITYMANAGER_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityserviceplugin.cpp --- a/activityfw/activityserviceplugin/activityserviceplugin.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "activityserviceplugin.h" - -#include -#include -#include - -#include "activityclient.h" -#include "activitymanager.h" - -QObject *ActivityServicePlugin::createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session) -{ - Q_UNUSED(context); - Q_UNUSED(session); - - if (descriptor.interfaceName() == "com.nokia.qt.activities.ActivityClient") { - return new ActivityClient(); - } else if (descriptor.interfaceName() == "com.nokia.qt.activities.ActivityManager") { - return new ActivityManager(); - } else { - return NULL; - } -} - -Q_EXPORT_PLUGIN2(activityserviceplugin, ActivityServicePlugin) diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityserviceplugin.h --- a/activityfw/activityserviceplugin/activityserviceplugin.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYSERVICEPLUGIN_H -#define ACTIVITYSERVICEPLUGIN_H - -#include -#include - -QTM_USE_NAMESPACE - -class ActivityServicePlugin : public QObject, public QServicePluginInterface -{ - Q_OBJECT - Q_INTERFACES(QtMobility::QServicePluginInterface) - -public: - QObject *createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session); - -}; - -#endif //ACTIVITYSERVICEPLUGIN_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityserviceplugin.pro --- a/activityfw/activityserviceplugin/activityserviceplugin.pro Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activityserviceplugin/activityserviceplugin.pro Thu May 27 13:11:12 2010 +0300 @@ -20,27 +20,32 @@ CONFIG += plugin include(activityserviceplugin.pri) -HEADERS += activityserviceplugin.h \ - activitydatastorage.h \ - activityclient.h \ - activityclient_p.h \ - activitymanager.h \ - activitymanager_p.h \ - applicationlauncher.h \ +INCLUDEPATH += ./inc \ + #../cautils/inc \ + #../extinc \ -SOURCES += activityserviceplugin.cpp \ - activitydatastorage.cpp \ - activityclient.cpp \ - activityclient_p.cpp \ - activitymanager.cpp \ - activitymanager_p.cpp \ - applicationlauncher.cpp \ +HEADERS += ./inc/activityserviceplugin.h \ + ./inc/activitydatastorage.h \ + ./inc/activityclient.h \ + ./inc/activityclient_p.h \ + ./inc/activitymanager.h \ + ./inc/activitymanager_p.h \ + ./inc/applicationlauncher.h \ + +SOURCES += ./src/activityserviceplugin.cpp \ + ./src/activitydatastorage.cpp \ + ./src/activityclient.cpp \ + ./src/activityclient_p.cpp \ + ./src/activitymanager.cpp \ + ./src/activitymanager_p.cpp \ + ./src/applicationlauncher.cpp \ symbian { - INCLUDEPATH += ./s60/ - SOURCES += ./s60/applicationlauncher_p.cpp + INCLUDEPATH += ./s60/inc \ + + SOURCES += ./s60/src/applicationlauncher_p.cpp - HEADERS += ./s60/applicationlauncher_p.h + HEADERS += ./s60/src/applicationlauncher_p.h LIBS += -lapparc \ -lapgrfx \ @@ -51,10 +56,11 @@ } win32 { - INCLUDEPATH += ./win/ - SOURCES += ./win/applicationlauncher_p.cpp + INCLUDEPATH += ./win/inc \ - HEADERS += ./win/applicationlauncher_p.h + SOURCES += ./win/src/applicationlauncher_p.cpp + + HEADERS += ./win/inc/applicationlauncher_p.h } symbian { @@ -63,7 +69,11 @@ TARGET.CAPABILITY = ALL -TCB TARGET.UID3 = 0x200267B2 - plugin.sources = activityserviceplugin.dll plugin.path = $$QT_PLUGINS_BASE_DIR + + xml.sources = ./data/activityserviceplugin.xml + xml.path = $$RESOURCE_FILES_DIR/activity + + DEPLOYMENT += xml } diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/activityserviceplugin.xml --- a/activityfw/activityserviceplugin/activityserviceplugin.xml Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ - - - ActivityService - activityserviceplugin - Activities service - - com.nokia.qt.activities.ActivityClient - 1.0 - Implementation of ActivityClient - - - com.nokia.qt.activities.ActivityManager - 1.0 - Implementation of ActivityManager - - diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/applicationlauncher.cpp --- a/activityfw/activityserviceplugin/applicationlauncher.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "applicationlauncher.h" -#include "applicationlauncher_p.h" - -ApplicationLauncher::ApplicationLauncher() : d_ptr(new ApplicationLauncherPrivate()) -{ -} - -ApplicationLauncher::~ApplicationLauncher() -{ - delete d_ptr; -} - -bool ApplicationLauncher::isRunning(int applicationId) -{ - return d_ptr->isRunning(applicationId); -} - -void ApplicationLauncher::startApplication(int applicationId, const QString &activityId) -{ - d_ptr->startApplication(applicationId, activityId); -} - -void ApplicationLauncher::bringToForeground(int applicationId) -{ - d_ptr->bringToForeground(applicationId); -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/applicationlauncher.h --- a/activityfw/activityserviceplugin/applicationlauncher.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef APPLICATIONLAUNCHER_H -#define APPLICATIONLAUNCHER_H - -class ApplicationLauncherPrivate; - -#include - -class ApplicationLauncher -{ - -public: - ApplicationLauncher(); - ~ApplicationLauncher(); - -public: - bool isRunning(int applicationId); - void startApplication(int applicationId, const QString &activityId); - void bringToForeground(int applicationId); - -private: - ApplicationLauncherPrivate *d_ptr; - -}; - -#endif // APPLICATIONLAUNCHER_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/data/activityserviceplugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/data/activityserviceplugin.xml Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,16 @@ + + + ActivityService + activityserviceplugin + Activities service + + com.nokia.qt.activities.ActivityClient + 1.0 + Implementation of ActivityClient + + + com.nokia.qt.activities.ActivityManager + 1.0 + Implementation of ActivityManager + + diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/activityclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/activityclient.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYCLIENT_H +#define ACTIVITYCLIENT_H + +#include +#include +#include + +class ActivityClientPrivate; + +class ActivityClient : public QObject +{ + + Q_OBJECT + +public: + ActivityClient(QObject *parent = 0); + ~ActivityClient(); + +public slots: + bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); + bool removeActivity(const QString &activityId); + bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); + QList activities() const; + QVariant activityData(const QString &activityId) const; + QVariantHash parseCommandLine(const QStringList &commandLineParams) const; + +signals: + void activityRequested(const QString &activityId); + +private: + ActivityClientPrivate *d_ptr; + friend class ActivityClientPrivate; + +}; + +#endif // ACTIVITYCLIENT_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/activityclient_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/activityclient_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYCLIENT_P_H +#define ACTIVITYCLIENT_P_H + +#include +#include +#include +#include + +class ActivityClient; +class ActivityDataStorage; +class ActivityServerClient; +class HsActivityDbClient; +class ActivityClientPrivate : public QObject +{ + + Q_OBJECT + +public: + ActivityClientPrivate(ActivityClient *q); + ~ActivityClientPrivate(); + +public: + bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); + bool removeActivity(const QString &activityId); + bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters); + QList activities() const; + QVariant activityData(const QString &activityId) const; + QVariantHash parseCommandLine(const QStringList &commandLineParams) const; + +private: + void registerThumbnail(const QString &, QVariantHash&); + QString thumbnailName(const QString &) const; + +private: + ActivityDataStorage *mDataStorage; + HsActivityDbClient *mServerClient; + bool mIsconnected; +}; + +#endif // ACTIVITYCLIENT_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/activitydatastorage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/activitydatastorage.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYDATASTORAGE_H +#define ACTIVITYDATASTORAGE_H + +#include +#include + +class ActivityDataStorage +{ + +public: + ActivityDataStorage(); + ~ActivityDataStorage(); + +public: + bool addActivity(const QString &activityId, const QVariant &data); + bool removeActivity(const QString &activityId); + bool updateActivity(const QString &activityId, const QVariant &data); + QVariant activityData(const QString &activityId) const; + +private: + bool checkTables(); + void recreateTables(); + +}; + +#endif // ACTIVITYDATASTORAGE_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/activitymanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/activitymanager.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYMANAGER_H +#define ACTIVITYMANAGER_H + +#include +#include +#include +#include +#include + +class ActivityManagerPrivate; + +class ActivityManager : public QObject +{ + + Q_OBJECT + +public: + ActivityManager(QObject *parent = 0); + ~ActivityManager(); + +public slots: + QList activitiesList(); + void launchActivity(const QString &uri); + void launchActivity(const QUrl &uri); + void launchActivity(int applicationId, const QString &activityId, const QVariantHash& parameters = QVariantHash()); + void getThumbnail(QSize resolution,const QString &thumbnailPath, void *data =0); + +signals: + void thumbnailReady(QPixmap, void *); + void dataChanged(); + +private: + ActivityManagerPrivate *d_ptr; + + friend class ActivityManagerPrivate; +}; + +#endif // ACTIVITYMANAGER_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/activitymanager_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/activitymanager_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYMANAGER_P_H +#define ACTIVITYMANAGER_P_H + +#include +#include +#include +#include +#include "applicationlauncher.h" + +class ActivityManager; +class HsActivityDbClient; + +class ActivityManagerPrivate : public QObject +{ + + Q_OBJECT + +public: + ActivityManagerPrivate(ActivityManager *q); + ~ActivityManagerPrivate(); + +public slots: + QList activitiesList(); + void launchActivity(const QUrl &uri); + void launchActivity(int applicationId, const QString &activityId, const QVariantHash& parameters); + void getThumbnail(QSize resolution,const QString &thumbnailPath, void *data); + +private: + void launchActivity(const QVariantHash& activity); + QUrl activityToUri(const QVariantHash& activity) const; + +private: + ActivityManager *q_ptr; + HsActivityDbClient *mServerClient; +}; + +#endif // ACTIVITYMANAGER_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/activityserviceplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/activityserviceplugin.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYSERVICEPLUGIN_H +#define ACTIVITYSERVICEPLUGIN_H + +#include +#include + +QTM_USE_NAMESPACE + +class ActivityServicePlugin : public QObject, public QServicePluginInterface +{ + Q_OBJECT + Q_INTERFACES(QtMobility::QServicePluginInterface) + +public: + QObject *createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session); + +}; + +#endif //ACTIVITYSERVICEPLUGIN_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/inc/applicationlauncher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/inc/applicationlauncher.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef APPLICATIONLAUNCHER_H +#define APPLICATIONLAUNCHER_H + +class ApplicationLauncherPrivate; + +#include +#include + +class ApplicationLauncher +{ + +public: + ApplicationLauncher(); + ~ApplicationLauncher(); + +public: + bool isRunning(int applicationId); + void startApplication(int applicationId, const QUrl &uri); + void bringToForeground(int applicationId); + +private: + ApplicationLauncherPrivate *d_ptr; + +}; + +#endif // APPLICATIONLAUNCHER_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/activitydatabase_p.cpp --- a/activityfw/activityserviceplugin/s60/activitydatabase_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "activitydatabase_p.h" - -#include -#include -#include -#include -#include - - - -ActivityDatabasePrivate::ActivityDatabasePrivate() -{ - mClient.connect(); -} - -ActivityDatabasePrivate::~ActivityDatabasePrivate() -{ -} - -void ActivityDatabasePrivate::saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata) -{ - QVariantHash request(activityMetadata); - request.insert(ActivityApplicationKeyword,applicationName); - request.insert(ActivityActivityKeyword,activityName); - mClient.saveActivity(request); - -} - -void ActivityDatabasePrivate::deleteActivity(const QString &applicationName, const QString &activityName) -{ - QVariantHash request; - request.insert(ActivityApplicationKeyword,applicationName); - request.insert(ActivityActivityKeyword,activityName); - mClient.deleteActivity(request); -} - -void ActivityDatabasePrivate::deleteApplicationActivities(const QString &applicationName) -{ - QVariantHash request; - request.insert(ActivityApplicationKeyword,applicationName); - mClient.deleteApplicationActivities(request); -} - -QList ActivityDatabasePrivate::allActivitiesList() -{ - QList retVal; - mClient.activities(retVal); - return retVal; -} - -QList ActivityDatabasePrivate::applicationActivitiesList(const QString &applicationName) -{ - QList result; - QVariantHash request; - request.insert(ActivityApplicationKeyword,applicationName); - mClient.applicationActivities(result, request); - return result; -} - - -QString ActivityDatabasePrivate::requestedActivityName(const QString &applicationName) -{ - QString result; - QVariantHash request; - request.insert(ActivityApplicationKeyword,applicationName); - mClient.requestedActivityName(result, request); - return result; -} - -void ActivityDatabasePrivate::setActivityRequestFlag(const QString &applicationName, const QString &activityName) -{ - QVariantHash request; - request.insert(ActivityApplicationKeyword,applicationName); - request.insert(ActivityActivityKeyword,activityName); - mClient.setActivityRequestFlag(request); -} - -void ActivityDatabasePrivate::clearActivityRequestFlag(const QString &applicationName, const QString &activityName) -{ - QVariantHash request; - request.insert(ActivityApplicationKeyword,applicationName); - request.insert(ActivityActivityKeyword,activityName); - mClient.clearActivityRequestFlag(request); -} - diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/activitydatabase_p.h --- a/activityfw/activityserviceplugin/s60/activitydatabase_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYDATABASE_P_H -#define ACTIVITYDATABASE_P_H - -#include -#include -#include -class ActivityDatabasePrivate -{ - -public: - ActivityDatabasePrivate(); - ~ActivityDatabasePrivate(); - -public: - void saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata); - void deleteActivity(const QString &applicationName, const QString &activityName); - void deleteApplicationActivities(const QString &applicationName); - QList allActivitiesList(); - QList applicationActivitiesList(const QString &applicationName); - QString requestedActivityName(const QString &applicationName); - void setActivityRequestFlag(const QString &applicationName, const QString &activityName); - void clearActivityRequestFlag(const QString &applicationName, const QString &activityName); - -private: - HsActivityDbClient mClient; -}; - -#endif // ACTIVITYDATABASE_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/activityserverclient_p.cpp --- a/activityfw/activityserviceplugin/s60/activityserverclient_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "activityserverclient_p.h" - -ActivityServerClientPrivate::ActivityServerClientPrivate() -{ -} - -bool ActivityServerClientPrivate::addActivity(const QString &activityId, const QVariantHash ¶meters) -{ - return true; -} - -bool ActivityServerClientPrivate::removeActivity(const QString &activityId) -{ - return true; -} - -bool ActivityServerClientPrivate::updateActivity(const QString &activityId, const QVariantHash ¶meters) -{ - return true; -} - -QList ActivityServerClientPrivate::applicationActivities() -{ - return QList(); -} - -bool ActivityServerClientPrivate::removeActivity(int applicationId, const QString &activityId) -{ - return true; -} - -bool ActivityServerClientPrivate::removeApplicationActivities(int applicationId) -{ - return true; -} - -QList ActivityServerClientPrivate::activities() -{ - return QList(); -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/activityserverclient_p.h --- a/activityfw/activityserviceplugin/s60/activityserverclient_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYSERVERCLIENT_P_H -#define ACTIVITYSERVERCLIENT_P_H - -#include -#include - -class ActivityServerClient; - -class ActivityServerClientPrivate -{ - -public: - ActivityServerClientPrivate(); - -public: // API used by ActivityClient - bool addActivity(const QString &activityId, const QVariantHash ¶meters); - bool removeActivity(const QString &activityId); - bool updateActivity(const QString &activityId, const QVariantHash ¶meters); - QList applicationActivities(); - -public: // API used by ActivityManager - bool removeActivity(int applicationId, const QString &activityId); - bool removeApplicationActivities(int applicationId); - QList activities(); - -public: - ActivityServerClient *q_ptr; - -}; - -#endif // ACTIVITYSERVERCLIENT_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/applicationlauncher_p.cpp --- a/activityfw/activityserviceplugin/s60/applicationlauncher_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "applicationlauncher_p.h" - -#include -#include -#include -#include - -#include - -bool ApplicationLauncherPrivate::isRunning(int applicationId) -{ - TApaTaskList taskList(CEikonEnv::Static()->WsSession()); - TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); - return task.Exists(); -} - -void ApplicationLauncherPrivate::startApplication(int applicationId, const QString &activityId) -{ - QString actId = "\""+activityId+"\""; - QString uri = QString("-activity appto://%1?activityname=%2").arg(uint(applicationId), 8, 16, QChar('0')).arg(actId); - - QT_TRAP_THROWING( { - HBufC *uriAsDescriptor = XQConversions::qStringToS60Desc(uri); - CleanupStack::PushL(uriAsDescriptor); - - RApaLsSession apaLsSession; - User::LeaveIfError(apaLsSession.Connect()); - CleanupClosePushL(apaLsSession); - - TApaAppInfo appInfo; - TInt retVal = apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)); - - if (retVal == KErrNone) { - RProcess application; - User::LeaveIfError(application.Create(appInfo.iFullName, *uriAsDescriptor)); - application.Resume(); - } else { - // @todo - } - - CleanupStack::PopAndDestroy(&apaLsSession); - CleanupStack::PopAndDestroy(uriAsDescriptor); - } - ); -} - -void ApplicationLauncherPrivate::bringToForeground(int applicationId) -{ - TApaTaskList taskList(CEikonEnv::Static()->WsSession()); - TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); - if (task.Exists()) { - task.BringToForeground(); - } else { - qCritical("Cannot bring to forward task %08x", applicationId); - } -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/applicationlauncher_p.h --- a/activityfw/activityserviceplugin/s60/applicationlauncher_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef APPLICATIONLAUNCHER_P_H -#define APPLICATIONLAUNCHER_P_H - -#include - -class ApplicationLauncherPrivate -{ - -public: - bool isRunning(int applicationId); - void startApplication(int applicationId, const QString &activityId); - void bringToForeground(int applicationId); - -}; - -#endif // APPLICATIONLAUNCHER_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/inc/activitydatabase_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/s60/inc/activitydatabase_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYDATABASE_P_H +#define ACTIVITYDATABASE_P_H + +#include +#include +#include +class ActivityDatabasePrivate +{ + +public: + ActivityDatabasePrivate(); + ~ActivityDatabasePrivate(); + +public: + void saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata); + void deleteActivity(const QString &applicationName, const QString &activityName); + void deleteApplicationActivities(const QString &applicationName); + QList allActivitiesList(); + QList applicationActivitiesList(const QString &applicationName); + QString requestedActivityName(const QString &applicationName); + void setActivityRequestFlag(const QString &applicationName, const QString &activityName); + void clearActivityRequestFlag(const QString &applicationName, const QString &activityName); + +private: + HsActivityDbClient mClient; +}; + +#endif // ACTIVITYDATABASE_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/inc/activityserverclient_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/s60/inc/activityserverclient_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYSERVERCLIENT_P_H +#define ACTIVITYSERVERCLIENT_P_H + +#include +#include + +class ActivityServerClient; + +class ActivityServerClientPrivate +{ + +public: + ActivityServerClientPrivate(); + +public: // API used by ActivityClient + bool addActivity(const QString &activityId, const QVariantHash ¶meters); + bool removeActivity(const QString &activityId); + bool updateActivity(const QString &activityId, const QVariantHash ¶meters); + QList applicationActivities(); + +public: // API used by ActivityManager + bool removeActivity(int applicationId, const QString &activityId); + bool removeApplicationActivities(int applicationId); + QList activities(); + +public: + ActivityServerClient *q_ptr; + +}; + +#endif // ACTIVITYSERVERCLIENT_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/inc/applicationlauncher_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/s60/inc/applicationlauncher_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef APPLICATIONLAUNCHER_P_H +#define APPLICATIONLAUNCHER_P_H + +#include +#include + +class ApplicationLauncherPrivate +{ + +public: + bool isRunning(int applicationId); + void startApplication(int applicationId, const QUrl &uri); + void bringToForeground(int applicationId); + +}; + +#endif // APPLICATIONLAUNCHER_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/src/activitydatabase_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/s60/src/activitydatabase_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "activitydatabase_p.h" + +#include +#include +#include +#include +#include + + + +ActivityDatabasePrivate::ActivityDatabasePrivate() +{ + mClient.connect(); +} + +ActivityDatabasePrivate::~ActivityDatabasePrivate() +{ +} + +void ActivityDatabasePrivate::saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata) +{ + QVariantHash request(activityMetadata); + request.insert(ActivityApplicationKeyword,applicationName); + request.insert(ActivityActivityKeyword,activityName); + mClient.saveActivity(request); + +} + +void ActivityDatabasePrivate::deleteActivity(const QString &applicationName, const QString &activityName) +{ + QVariantHash request; + request.insert(ActivityApplicationKeyword,applicationName); + request.insert(ActivityActivityKeyword,activityName); + mClient.deleteActivity(request); +} + +void ActivityDatabasePrivate::deleteApplicationActivities(const QString &applicationName) +{ + QVariantHash request; + request.insert(ActivityApplicationKeyword,applicationName); + mClient.deleteApplicationActivities(request); +} + +QList ActivityDatabasePrivate::allActivitiesList() +{ + QList retVal; + mClient.activities(retVal); + return retVal; +} + +QList ActivityDatabasePrivate::applicationActivitiesList(const QString &applicationName) +{ + QList result; + QVariantHash request; + request.insert(ActivityApplicationKeyword,applicationName); + mClient.applicationActivities(result, request); + return result; +} + + +QString ActivityDatabasePrivate::requestedActivityName(const QString &applicationName) +{ + QString result; + QVariantHash request; + request.insert(ActivityApplicationKeyword,applicationName); + mClient.requestedActivityName(result, request); + return result; +} + +void ActivityDatabasePrivate::setActivityRequestFlag(const QString &applicationName, const QString &activityName) +{ + QVariantHash request; + request.insert(ActivityApplicationKeyword,applicationName); + request.insert(ActivityActivityKeyword,activityName); + mClient.setActivityRequestFlag(request); +} + +void ActivityDatabasePrivate::clearActivityRequestFlag(const QString &applicationName, const QString &activityName) +{ + QVariantHash request; + request.insert(ActivityApplicationKeyword,applicationName); + request.insert(ActivityActivityKeyword,activityName); + mClient.clearActivityRequestFlag(request); +} + diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/src/activityserverclient_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/s60/src/activityserverclient_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "activityserverclient_p.h" + +ActivityServerClientPrivate::ActivityServerClientPrivate() +{ +} + +bool ActivityServerClientPrivate::addActivity(const QString &activityId, const QVariantHash ¶meters) +{ + return true; +} + +bool ActivityServerClientPrivate::removeActivity(const QString &activityId) +{ + return true; +} + +bool ActivityServerClientPrivate::updateActivity(const QString &activityId, const QVariantHash ¶meters) +{ + return true; +} + +QList ActivityServerClientPrivate::applicationActivities() +{ + return QList(); +} + +bool ActivityServerClientPrivate::removeActivity(int applicationId, const QString &activityId) +{ + return true; +} + +bool ActivityServerClientPrivate::removeApplicationActivities(int applicationId) +{ + return true; +} + +QList ActivityServerClientPrivate::activities() +{ + return QList(); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/s60/src/applicationlauncher_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/s60/src/applicationlauncher_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "applicationlauncher_p.h" + +#include +#include +#include +#include + +#include + +bool ApplicationLauncherPrivate::isRunning(int applicationId) +{ + TApaTaskList taskList(CEikonEnv::Static()->WsSession()); + TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); + return task.Exists(); +} + +void ApplicationLauncherPrivate::startApplication(int applicationId, const QUrl &uri) +{ + QString commandLine = QString("-activity %1").arg(uri.toString()); + + QT_TRAP_THROWING( { + HBufC *commandLineAsDescriptor = XQConversions::qStringToS60Desc(commandLine); + CleanupStack::PushL(commandLineAsDescriptor); + + RApaLsSession apaLsSession; + User::LeaveIfError(apaLsSession.Connect()); + CleanupClosePushL(apaLsSession); + + TApaAppInfo appInfo; + TInt retVal = apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)); + + if (retVal == KErrNone) { + RProcess application; + User::LeaveIfError(application.Create(appInfo.iFullName, *commandLineAsDescriptor)); + application.Resume(); + } else { + // @todo ? + } + + CleanupStack::PopAndDestroy(&apaLsSession); + CleanupStack::PopAndDestroy(commandLineAsDescriptor); + } + ); +} + +void ApplicationLauncherPrivate::bringToForeground(int applicationId) +{ + TApaTaskList taskList(CEikonEnv::Static()->WsSession()); + TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); + if (task.Exists()) { + task.BringToForeground(); + } else { + qCritical("Cannot bring to forward task %08x", applicationId); + } +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/activityclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/activityclient.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "activityclient.h" +#include "activityclient_p.h" + +ActivityClient::ActivityClient(QObject *parent) : QObject(parent) +{ + qDebug("[JCH] activity client creation started"); + d_ptr = new ActivityClientPrivate(this); + qDebug("[JCH] activity client creation stopped"); +} + +ActivityClient::~ActivityClient() +{ +} + +bool ActivityClient::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) +{ + return d_ptr->addActivity(activityId, data, parameters); +} + +bool ActivityClient::removeActivity(const QString &activityId) +{ + return d_ptr->removeActivity(activityId); +} + +bool ActivityClient::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) +{ + return d_ptr->updateActivity(activityId, data, parameters); +} + +QList ActivityClient::activities() const +{ + return d_ptr->activities(); +} + +QVariant ActivityClient::activityData(const QString &activityId) const +{ + return d_ptr->activityData(activityId); +} + +QVariantHash ActivityClient::parseCommandLine(const QStringList &commandLineParams) const +{ + return d_ptr->parseCommandLine(commandLineParams); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/activityclient_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/activityclient_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "activityclient_p.h" +#include "activityclient.h" +#include "activitydatastorage.h" +#include + +#include +#include +#include +#include +#include +#include + +ActivityClientPrivate::ActivityClientPrivate(ActivityClient *q) : QObject(q), mIsconnected(false) +{ + mDataStorage = new ActivityDataStorage(); + mServerClient = new HsActivityDbClient(); + mIsconnected = ( KErrNone == mServerClient->connect()); + if( mIsconnected) { + mServerClient->waitActivity(QVariantHash()); + } + connect(mServerClient, SIGNAL(activityRequested(QString)), q, SIGNAL(activityRequested(QString))); +} + +ActivityClientPrivate::~ActivityClientPrivate() +{ + delete mServerClient; + delete mDataStorage; +} + +bool ActivityClientPrivate::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) +{ + bool result(false); + if (mIsconnected) { + result = mDataStorage->addActivity(activityId, data); + if ( result ) { + QVariantHash activity(parameters); + RProcess process; + registerThumbnail(activityId, activity); + activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); + activity.insert(ActivityActivityKeyword, activityId); + int error = mServerClient->addActivity(activity); + result = error == KErrNone ? true : false; + } + } + // @todo make those operations atomic + return result; +} + +bool ActivityClientPrivate::removeActivity(const QString &activityId) +{ + bool result(false); + if (mIsconnected) { + result = mDataStorage->removeActivity(activityId); + if ( result ) { + QVariantHash activity; + RProcess process; + activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); + activity.insert(ActivityActivityKeyword, activityId); + int error = mServerClient->removeActivity(activity); + result = error == KErrNone ? true : false; + if (result) { + result = QFile::remove(thumbnailName(activityId)); + } + } + } + // @todo make those operations atomic + return result; +} + +bool ActivityClientPrivate::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) +{ + bool result(false); + if (mIsconnected) { + result = mDataStorage->updateActivity(activityId, data); + if ( result ) { + QVariantHash activity(parameters); + RProcess process; + registerThumbnail(activityId, activity); + activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); + activity.insert(ActivityActivityKeyword, activityId); + int error = mServerClient->updateActivity(activity); + result = error == KErrNone ? true : false; + } + } + // @todo make those operations atomic + return result; +} + +QList ActivityClientPrivate::activities() const +{ + QList activities; + if (mIsconnected) { + QVariantHash activity; + RProcess process; + activity.insert(ActivityApplicationKeyword, static_cast(process.SecureId().iId)); + mServerClient->applicationActivities(activities, activity); + } + return activities; +} + +QVariant ActivityClientPrivate::activityData(const QString &activityId) const +{ + return mIsconnected ? mDataStorage->activityData(activityId) : QVariant(); +} + +QVariantHash ActivityClientPrivate::parseCommandLine(const QStringList &commandLineParams) const +{ + QVariantHash activityParams; + int activityMarkerIndex = commandLineParams.indexOf("-activity"); + if (activityMarkerIndex != -1 && commandLineParams.count() - 1 > activityMarkerIndex) { + QUrl activityUri(commandLineParams.at(activityMarkerIndex+1)); + if (activityUri.scheme() == "appto") { + QList > parameters = activityUri.queryItems(); + for (QList >::const_iterator i = parameters.constBegin(); i != parameters.constEnd(); ++i) { + activityParams.insert(i->first, i->second); + } + + if (activityParams.contains("activityname") && !activityParams.value("activityname").toString().isEmpty()) { + return activityParams; + } + } + } + return QVariantHash(); +} + +void ActivityClientPrivate::registerThumbnail(const QString &name, QVariantHash &activity) +{ + QVariantHash::const_iterator findIterator(activity.constFind(ActivityScreenshotKeyword)); + if (activity.constEnd() != findIterator && + findIterator.value().canConvert()) { + const QString thumbnailManagerName = thumbnailName(name); + if (findIterator.value().value().save(thumbnailManagerName)) { + activity.insert(ActivityScreenshotKeyword, thumbnailManagerName); + } else { + activity.remove(ActivityScreenshotKeyword); + } + } +} + +QString ActivityClientPrivate::thumbnailName(const QString &activityId) const +{ + return QDir::toNativeSeparators(qApp->applicationDirPath() + + "/" + + QString::number(qHash(activityId), 16) + + ".png"); +} + diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/activitydatastorage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/activitydatastorage.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "activitydatastorage.h" + +#include +#include +#include +#include + +const char KConnectionName[] = "ActivityDataStorage"; + +ActivityDataStorage::ActivityDataStorage() +{ + QSqlDatabase database; + if (QSqlDatabase::contains(KConnectionName)) { + database = QSqlDatabase::database(KConnectionName); + } else { + database = QSqlDatabase::addDatabase("QSQLITE", KConnectionName); + database.setDatabaseName("activitydatastorage.db"); + if (!database.open()) { + qFatal(qPrintable(database.lastError().text())); + } + } + + if (!checkTables()) { + recreateTables(); + } +} + +ActivityDataStorage::~ActivityDataStorage() +{ + QSqlDatabase::database(KConnectionName).close(); +} + +bool ActivityDataStorage::addActivity(const QString &activityId, const QVariant &data) +{ + QSqlDatabase database = QSqlDatabase::database(KConnectionName); + + QByteArray streamedData; + { + QDataStream stream(&streamedData, QIODevice::WriteOnly); + stream << data; + } + + // insert data + QSqlQuery query(database); + if (!query.prepare("INSERT INTO Activities(Name, Data) VALUES(:Name, :Data)")) { + qCritical(qPrintable(query.lastError().text())); + return false; + } + query.bindValue(":Name", activityId); + query.bindValue(":Data", streamedData); + if (!query.exec()) { + qCritical(qPrintable(query.lastError().text())); + return false; + } + + return true; +} + +bool ActivityDataStorage::removeActivity(const QString &activityId) +{ + QString sqlCommand = QString("DELETE FROM Activities WHERE Name = '%1'").arg(activityId); + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + if (!query.exec(sqlCommand)) { + qCritical(qPrintable(query.lastError().text())); + return false; + } + return query.numRowsAffected() > 0; +} + +bool ActivityDataStorage::updateActivity(const QString &activityId, const QVariant &data) +{ + QSqlDatabase database = QSqlDatabase::database(KConnectionName); + + QByteArray streamedData; + { + QDataStream stream(&streamedData, QIODevice::WriteOnly); + stream << data; + } + + // update data + QSqlQuery query(database); + if (!query.prepare("UPDATE Activities SET Data = :Data WHERE Name = :Name")) { + qCritical(qPrintable(query.lastError().text())); + return false; + } + query.bindValue(":Data", streamedData); + query.bindValue(":Name", activityId); + if (!query.exec()) { + qCritical(qPrintable(query.lastError().text())); + return false; + } + + return query.numRowsAffected() > 0; +} + +QVariant ActivityDataStorage::activityData(const QString &activityId) const +{ + QSqlDatabase database = QSqlDatabase::database(KConnectionName); + QSqlQuery query(database); + if (!query.exec(QString("SELECT Data FROM Activities WHERE Name = '%1'").arg(activityId))) { + qCritical(qPrintable(query.lastError().text())); + return QVariant(); + } + + QVariant result; + if (query.next()) { + QByteArray data(query.value(0).toByteArray()); + QDataStream stream(&data, QIODevice::ReadOnly); + stream >> result; + } + return result; +} + +bool ActivityDataStorage::checkTables() +{ + QStringList expectedTables("Activities"); + QStringList actualTables = QSqlDatabase::database(KConnectionName).tables(); + return (expectedTables == actualTables); +} + +void ActivityDataStorage::recreateTables() +{ + QSqlDatabase database = QSqlDatabase::database(KConnectionName); + + if (!database.transaction()) { + qFatal(qPrintable(database.lastError().text())); + } + + // drop any existing tables + { + QSqlQuery dropQuery(database); + foreach(const QString &tableName, database.tables()) { + if (!dropQuery.exec(QString("DROP TABLE %1").arg(tableName))) { + qFatal(qPrintable(dropQuery.lastError().text())); + } + } + } + + // create new table + { + QSqlQuery createQuery(database); + QString statement( + "CREATE TABLE Activities(" + "Name TEXT NOT NULL PRIMARY KEY UNIQUE," + "Data BLOB NOT NULL)"); + + if (!createQuery.exec(statement)) { + qFatal(qPrintable(createQuery.lastError().text())); + } + } + + if (!database.commit()) { + qFatal(qPrintable(database.lastError().text())); + } +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/activitymanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/activitymanager.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "activitymanager.h" +#include "activitymanager_p.h" + +#include + +ActivityManager::ActivityManager(QObject *parent) : QObject(parent), d_ptr(new ActivityManagerPrivate(this)) +{ +} + +ActivityManager::~ActivityManager() +{ +} + +QList ActivityManager::activitiesList() +{ + return d_ptr->activitiesList(); +} + +void ActivityManager::launchActivity(const QUrl &uri) +{ + d_ptr->launchActivity(uri); +} + +void ActivityManager::launchActivity(const QString &uri) +{ + qWarning("ActivityManager::launchActivity(const QString &uri) is deprecated, use ActivityManager::launchActivity(const QUrl &uri) instead"); + launchActivity(QUrl(uri)); +} + +void ActivityManager::launchActivity(int applicationId, const QString &activityId, const QVariantHash& parameters) +{ + d_ptr->launchActivity(applicationId, activityId, parameters); +} + +void ActivityManager::getThumbnail(QSize resolution,const QString &thumbnailPath, void *data) +{ + d_ptr->getThumbnail(resolution, thumbnailPath, data); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/activitymanager_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/activitymanager_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "activitymanager_p.h" +#include "activitymanager.h" +#include + +#include +#include + +ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager *q) : QObject(q), q_ptr(q) +{ + mServerClient = new HsActivityDbClient(); + if(0 == mServerClient->connect()){ + mServerClient->notifyDataChange(); + } + connect(mServerClient, + SIGNAL(thumbnailRequested(QPixmap, void *)), + q, + SIGNAL(thumbnailReady(QPixmap, void *))); + connect(mServerClient, + SIGNAL(dataChanged()), + q, + SIGNAL(dataChanged())); +} + +ActivityManagerPrivate::~ActivityManagerPrivate() +{ + delete mServerClient; +} + +QList ActivityManagerPrivate::activitiesList() +{ + QList retVal; + mServerClient->activities(retVal); + return retVal; +} + +void ActivityManagerPrivate::launchActivity(const QUrl &uri) +{ + if (uri.scheme() != "appto") + return; + + bool conversionOk(false); + int applicationId = uri.host().toUInt(&conversionOk, 16); + if (!conversionOk) + return; + + QVariantHash activity; + activity.insert(ActivityApplicationKeyword, applicationId); + + QVariantHash parameters; + QList > uriParams = uri.queryItems(); + for (QList >::const_iterator i = uriParams.constBegin(); i != uriParams.constEnd(); ++i) { + parameters.insert(i->first, i->second); + } + + if (parameters.contains("activityname")) { + activity.insert(ActivityActivityKeyword, parameters.value("activityname").toString()); + parameters.remove("activityname"); + } + + activity.insert(ActivityParametersKeyword, parameters); + + launchActivity(activity); +} + +void ActivityManagerPrivate::launchActivity(int applicationId, const QString &activityId, const QVariantHash& parameters) +{ + QVariantHash activity; + activity.insert(ActivityApplicationKeyword, applicationId); + activity.insert(ActivityActivityKeyword, activityId); + activity.insert(ActivityParametersKeyword, parameters); + + launchActivity(activity); +} + +void ActivityManagerPrivate::launchActivity(const QVariantHash &activity) +{ + ApplicationLauncher applicationLauncher; + int applicationId = activity.value(ActivityApplicationKeyword).toInt(); + + if (applicationLauncher.isRunning(applicationId)) { + mServerClient->launchActivity(activity); + applicationLauncher.bringToForeground(applicationId); + } else { + applicationLauncher.startApplication(applicationId, activityToUri(activity)); + } +} + +QUrl ActivityManagerPrivate::activityToUri(const QVariantHash &activity) const +{ + QUrl uri; + uri.setScheme("appto"); + uri.setHost(QString("%1").arg(activity.value(ActivityApplicationKeyword).toUInt(), 8, 16, QChar('0'))); + + if (activity.contains(ActivityActivityKeyword)) + uri.addQueryItem("activityname", activity.value(ActivityActivityKeyword).toString()); + + QVariantHash parameters = activity.value(ActivityParametersKeyword).toHash(); + foreach(const QString &key, parameters.keys()) { + uri.addQueryItem(key, parameters.value(key).toString()); + } + + return uri; +} + +void ActivityManagerPrivate::getThumbnail(QSize resolution,const QString &thumbnailPath, void *data) +{ + mServerClient->getThumbnail(resolution, thumbnailPath, "image/png", data); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/activityserviceplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/activityserviceplugin.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "activityserviceplugin.h" + +#include +#include +#include + +#include "activityclient.h" +#include "activitymanager.h" + +QObject *ActivityServicePlugin::createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session) +{ + Q_UNUSED(context); + Q_UNUSED(session); + + if (descriptor.interfaceName() == "com.nokia.qt.activities.ActivityClient") { + return new ActivityClient(); + } else if (descriptor.interfaceName() == "com.nokia.qt.activities.ActivityManager") { + return new ActivityManager(); + } else { + return NULL; + } +} + +Q_EXPORT_PLUGIN2(activityserviceplugin, ActivityServicePlugin) diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/src/applicationlauncher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/src/applicationlauncher.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "applicationlauncher.h" +#include "applicationlauncher_p.h" + +ApplicationLauncher::ApplicationLauncher() : d_ptr(new ApplicationLauncherPrivate()) +{ +} + +ApplicationLauncher::~ApplicationLauncher() +{ + delete d_ptr; +} + +bool ApplicationLauncher::isRunning(int applicationId) +{ + return d_ptr->isRunning(applicationId); +} + +void ApplicationLauncher::startApplication(int applicationId, const QUrl &uri) +{ + d_ptr->startApplication(applicationId, uri); +} + +void ApplicationLauncher::bringToForeground(int applicationId) +{ + d_ptr->bringToForeground(applicationId); +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.qrc --- a/activityfw/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.qrc Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.qrc Thu May 27 13:11:12 2010 +0300 @@ -1,5 +1,5 @@ - ../../activityserviceplugin.xml + ../../data/activityserviceplugin.xml diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/activitydatabase_p.cpp --- a/activityfw/activityserviceplugin/win/activitydatabase_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,249 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "activitydatabase_p.h" - -#include -#include -#include -#include -#include - -#include - -const char KConnectionName[] = "ActivityDatabase"; - -ActivityDatabasePrivate::ActivityDatabasePrivate() -{ - // determine database localization - QSettings settings("nokia", "activities"); - if (!settings.contains("activitydatabase")) { - settings.setValue("activitydatabase", "C:\\activitydatabase.db"); - } - QString databaseFile = settings.value("activitydatabase").toString(); - - QSqlDatabase database; - if (QSqlDatabase::contains(KConnectionName)) { - database = QSqlDatabase::database(KConnectionName); - } else { - database = QSqlDatabase::addDatabase("QSQLITE", KConnectionName); - database.setDatabaseName(databaseFile); - if (!database.open()) { - qFatal(qPrintable(database.lastError().text())); - } - } - - if (!checkTables()) { - recreateTables(); - } -} - -ActivityDatabasePrivate::~ActivityDatabasePrivate() -{ - QSqlDatabase::database(KConnectionName).close(); -} - -void ActivityDatabasePrivate::saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata) -{ - if (applicationName.isEmpty() || activityName.isEmpty() || activityMetadata.value("screenshot").isNull()) { - qWarning("Activity entry is invalid, aborting save"); - return; - } - - QVariantHash activityData(activityMetadata); - activityData.insert(ActivityApplicationKeyword, applicationName); - activityData.insert(ActivityActivityKeyword, activityName); - - // stream whole entry to bytearray - QByteArray streamedData; - { - QDataStream stream(&streamedData, QIODevice::WriteOnly); - stream << activityData; - } - - QSqlDatabase database = QSqlDatabase::database(KConnectionName); - - if (!database.transaction()) { - qFatal(qPrintable(database.lastError().text())); - } - - // update or insert data - { - QSqlQuery query(database); - if (!query.exec(QString("SELECT ApplicationName FROM Activities WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName))) { - qFatal(qPrintable(query.lastError().text())); - } - - if (query.next()) { - if (!query.prepare("UPDATE Activities SET Data = :Data WHERE ApplicationName = :ApplicationName AND ActivityName = :ActivityName")) { - qFatal(qPrintable(query.lastError().text())); - } - query.bindValue(":Data", streamedData); - query.bindValue(":ApplicationName", applicationName); - query.bindValue(":ActivityName", activityName); - if (!query.exec()) { - qFatal(qPrintable(query.lastError().text())); - } - } else { - if (!query.prepare("INSERT INTO Activities(ApplicationName, ActivityName, Data) VALUES(:ApplicationName, :ActivityName, :Data)")) { - qFatal(qPrintable(query.lastError().text())); - } - query.bindValue(":ApplicationName", applicationName); - query.bindValue(":ActivityName", activityName); - query.bindValue(":Data", streamedData); - if (!query.exec()) { - qFatal(qPrintable(query.lastError().text())); - } - } - } - - if (!database.commit()) { - qFatal(qPrintable(database.lastError().text())); - } -} - -void ActivityDatabasePrivate::deleteActivity(const QString &applicationName, const QString &activityName) -{ - QString sqlCommand = QString("DELETE FROM Activities WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName); - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - if (!query.exec(sqlCommand)) { - qFatal(qPrintable(query.lastError().text())); - } -} - -void ActivityDatabasePrivate::deleteApplicationActivities(const QString &applicationName) -{ - QString sqlCommand = QString("DELETE FROM Activities WHERE ApplicationName = '%1'").arg(applicationName); - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - if (!query.exec(sqlCommand)) { - qFatal(qPrintable(query.lastError().text())); - } -} - -QList ActivityDatabasePrivate::allActivitiesList() -{ - return activitiesList("SELECT Data FROM Activities"); -} - -QList ActivityDatabasePrivate::applicationActivitiesList(const QString &applicationName) -{ - return activitiesList(QString("SELECT Data FROM Activities WHERE ApplicationName = '%1'").arg(applicationName)); -} - -QList ActivityDatabasePrivate::activitiesList(const QString &sqlCommand) -{ - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - if (!query.exec(sqlCommand)) { - qFatal(qPrintable(query.lastError().text())); - } - - QList result; - while (query.next()) { - QVariantHash activityEntry; - { - QByteArray data(query.value(0).toByteArray()); - QDataStream stream(&data, QIODevice::ReadOnly); - stream >> activityEntry; - } - result.append(activityEntry); - } - return result; -} - -QString ActivityDatabasePrivate::requestedActivityName(const QString &applicationName) -{ - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - if (!query.exec(QString("SELECT ActivityName FROM Activities WHERE ApplicationName = '%1' AND RequestFlag").arg(applicationName))) { - qFatal(qPrintable(query.lastError().text())); - } - - QString result; - if (query.next()) { - result = query.value(0).toString(); - } - return result; -} - -void ActivityDatabasePrivate::setActivityRequestFlag(const QString &applicationName, const QString &activityName) -{ - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - - // clear old requests for given application - if (!query.exec(QString("UPDATE Activities SET RequestFlag=0 WHERE ApplicationName = '%1'").arg(applicationName))) { - qFatal(qPrintable(query.lastError().text())); - } - - // set new request - if (!query.exec(QString("UPDATE Activities SET RequestFlag=1 WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName))) { - qFatal(qPrintable(query.lastError().text())); - } -} - -void ActivityDatabasePrivate::clearActivityRequestFlag(const QString &applicationName, const QString &activityName) -{ - QSqlQuery query(QSqlDatabase::database(KConnectionName)); - - // just clear the given request - if (!query.exec(QString("UPDATE Activities SET RequestFlag=0 WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName))) { - qFatal(qPrintable(query.lastError().text())); - } -} - -bool ActivityDatabasePrivate::checkTables() -{ - QStringList expectedTables("Activities"); - QStringList actualTables = QSqlDatabase::database(KConnectionName).tables(); - return (expectedTables == actualTables); -} - -void ActivityDatabasePrivate::recreateTables() -{ - QSqlDatabase database = QSqlDatabase::database(KConnectionName); - - if (!database.transaction()) { - qFatal(qPrintable(database.lastError().text())); - } - - // drop any existing tables - { - QSqlQuery dropQuery(database); - foreach(const QString &tableName, database.tables()) { - if (!dropQuery.exec(QString("DROP TABLE %1").arg(tableName))) { - qFatal(qPrintable(dropQuery.lastError().text())); - } - } - } - - // create new table - { - QSqlQuery createQuery(database); - QString statement( - "CREATE TABLE Activities(" - "ApplicationName TEXT NOT NULL," - "ActivityName TEXT NOT NULL," - "RequestFlag BOOL NOT NULL DEFAULT FALSE," - "Data BLOB NOT NULL," - "PRIMARY KEY(ActivityName, ApplicationName))"); - - if (!createQuery.exec(statement)) { - qFatal(qPrintable(createQuery.lastError().text())); - } - } - - if (!database.commit()) { - qFatal(qPrintable(database.lastError().text())); - } -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/activitydatabase_p.h --- a/activityfw/activityserviceplugin/win/activitydatabase_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef ACTIVITYDATABASE_P_H -#define ACTIVITYDATABASE_P_H - -#include -#include - -class ActivityDatabasePrivate -{ - -public: - ActivityDatabasePrivate(); - ~ActivityDatabasePrivate(); - -public: - void saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata); - void deleteActivity(const QString &applicationName, const QString &activityName); - void deleteApplicationActivities(const QString &applicationName); - QList allActivitiesList(); - QList applicationActivitiesList(const QString &applicationName); - QString requestedActivityName(const QString &applicationName); - void setActivityRequestFlag(const QString &applicationName, const QString &activityName); - void clearActivityRequestFlag(const QString &applicationName, const QString &activityName); - -private: - QList activitiesList(const QString &sqlCommand); - -private: - bool checkTables(); - void recreateTables(); - -}; - -#endif // ACTIVITYDATABASE_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/applicationlauncher_p.cpp --- a/activityfw/activityserviceplugin/win/applicationlauncher_p.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "applicationlauncher_p.h" -#include - -bool ApplicationLauncherPrivate::isRunning(int applicationId) -{ - // @todo - return true; -} - -void ApplicationLauncherPrivate::startApplication(int applicationId, const QString &activityId) -{ - // @todo -} - -void ApplicationLauncherPrivate::bringToForeground(int applicationId) -{ - // @todo -} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/applicationlauncher_p.h --- a/activityfw/activityserviceplugin/win/applicationlauncher_p.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#ifndef APPLICATIONLAUNCHER_P_H -#define APPLICATIONLAUNCHER_P_H - -#include - -class ApplicationLauncherPrivate -{ - -public: - bool isRunning(int applicationId); - void startApplication(int applicationId, const QString &activityId); - void bringToForeground(int applicationId); - -}; - -#endif // APPLICATIONLAUNCHER_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/inc/activitydatabase_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/win/inc/activitydatabase_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef ACTIVITYDATABASE_P_H +#define ACTIVITYDATABASE_P_H + +#include +#include + +class ActivityDatabasePrivate +{ + +public: + ActivityDatabasePrivate(); + ~ActivityDatabasePrivate(); + +public: + void saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata); + void deleteActivity(const QString &applicationName, const QString &activityName); + void deleteApplicationActivities(const QString &applicationName); + QList allActivitiesList(); + QList applicationActivitiesList(const QString &applicationName); + QString requestedActivityName(const QString &applicationName); + void setActivityRequestFlag(const QString &applicationName, const QString &activityName); + void clearActivityRequestFlag(const QString &applicationName, const QString &activityName); + +private: + QList activitiesList(const QString &sqlCommand); + +private: + bool checkTables(); + void recreateTables(); + +}; + +#endif // ACTIVITYDATABASE_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/inc/applicationlauncher_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/win/inc/applicationlauncher_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef APPLICATIONLAUNCHER_P_H +#define APPLICATIONLAUNCHER_P_H + +#include + +class ApplicationLauncherPrivate +{ + +public: + bool isRunning(int applicationId); + void startApplication(int applicationId, const QString &activityId); + void bringToForeground(int applicationId); + +}; + +#endif // APPLICATIONLAUNCHER_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/src/activitydatabase_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/win/src/activitydatabase_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,249 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "activitydatabase_p.h" + +#include +#include +#include +#include +#include + +#include + +const char KConnectionName[] = "ActivityDatabase"; + +ActivityDatabasePrivate::ActivityDatabasePrivate() +{ + // determine database localization + QSettings settings("nokia", "activities"); + if (!settings.contains("activitydatabase")) { + settings.setValue("activitydatabase", "C:\\activitydatabase.db"); + } + QString databaseFile = settings.value("activitydatabase").toString(); + + QSqlDatabase database; + if (QSqlDatabase::contains(KConnectionName)) { + database = QSqlDatabase::database(KConnectionName); + } else { + database = QSqlDatabase::addDatabase("QSQLITE", KConnectionName); + database.setDatabaseName(databaseFile); + if (!database.open()) { + qFatal(qPrintable(database.lastError().text())); + } + } + + if (!checkTables()) { + recreateTables(); + } +} + +ActivityDatabasePrivate::~ActivityDatabasePrivate() +{ + QSqlDatabase::database(KConnectionName).close(); +} + +void ActivityDatabasePrivate::saveActivity(const QString &applicationName, const QString &activityName, const QVariantHash &activityMetadata) +{ + if (applicationName.isEmpty() || activityName.isEmpty() || activityMetadata.value("screenshot").isNull()) { + qWarning("Activity entry is invalid, aborting save"); + return; + } + + QVariantHash activityData(activityMetadata); + activityData.insert(ActivityApplicationKeyword, applicationName); + activityData.insert(ActivityActivityKeyword, activityName); + + // stream whole entry to bytearray + QByteArray streamedData; + { + QDataStream stream(&streamedData, QIODevice::WriteOnly); + stream << activityData; + } + + QSqlDatabase database = QSqlDatabase::database(KConnectionName); + + if (!database.transaction()) { + qFatal(qPrintable(database.lastError().text())); + } + + // update or insert data + { + QSqlQuery query(database); + if (!query.exec(QString("SELECT ApplicationName FROM Activities WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName))) { + qFatal(qPrintable(query.lastError().text())); + } + + if (query.next()) { + if (!query.prepare("UPDATE Activities SET Data = :Data WHERE ApplicationName = :ApplicationName AND ActivityName = :ActivityName")) { + qFatal(qPrintable(query.lastError().text())); + } + query.bindValue(":Data", streamedData); + query.bindValue(":ApplicationName", applicationName); + query.bindValue(":ActivityName", activityName); + if (!query.exec()) { + qFatal(qPrintable(query.lastError().text())); + } + } else { + if (!query.prepare("INSERT INTO Activities(ApplicationName, ActivityName, Data) VALUES(:ApplicationName, :ActivityName, :Data)")) { + qFatal(qPrintable(query.lastError().text())); + } + query.bindValue(":ApplicationName", applicationName); + query.bindValue(":ActivityName", activityName); + query.bindValue(":Data", streamedData); + if (!query.exec()) { + qFatal(qPrintable(query.lastError().text())); + } + } + } + + if (!database.commit()) { + qFatal(qPrintable(database.lastError().text())); + } +} + +void ActivityDatabasePrivate::deleteActivity(const QString &applicationName, const QString &activityName) +{ + QString sqlCommand = QString("DELETE FROM Activities WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName); + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + if (!query.exec(sqlCommand)) { + qFatal(qPrintable(query.lastError().text())); + } +} + +void ActivityDatabasePrivate::deleteApplicationActivities(const QString &applicationName) +{ + QString sqlCommand = QString("DELETE FROM Activities WHERE ApplicationName = '%1'").arg(applicationName); + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + if (!query.exec(sqlCommand)) { + qFatal(qPrintable(query.lastError().text())); + } +} + +QList ActivityDatabasePrivate::allActivitiesList() +{ + return activitiesList("SELECT Data FROM Activities"); +} + +QList ActivityDatabasePrivate::applicationActivitiesList(const QString &applicationName) +{ + return activitiesList(QString("SELECT Data FROM Activities WHERE ApplicationName = '%1'").arg(applicationName)); +} + +QList ActivityDatabasePrivate::activitiesList(const QString &sqlCommand) +{ + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + if (!query.exec(sqlCommand)) { + qFatal(qPrintable(query.lastError().text())); + } + + QList result; + while (query.next()) { + QVariantHash activityEntry; + { + QByteArray data(query.value(0).toByteArray()); + QDataStream stream(&data, QIODevice::ReadOnly); + stream >> activityEntry; + } + result.append(activityEntry); + } + return result; +} + +QString ActivityDatabasePrivate::requestedActivityName(const QString &applicationName) +{ + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + if (!query.exec(QString("SELECT ActivityName FROM Activities WHERE ApplicationName = '%1' AND RequestFlag").arg(applicationName))) { + qFatal(qPrintable(query.lastError().text())); + } + + QString result; + if (query.next()) { + result = query.value(0).toString(); + } + return result; +} + +void ActivityDatabasePrivate::setActivityRequestFlag(const QString &applicationName, const QString &activityName) +{ + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + + // clear old requests for given application + if (!query.exec(QString("UPDATE Activities SET RequestFlag=0 WHERE ApplicationName = '%1'").arg(applicationName))) { + qFatal(qPrintable(query.lastError().text())); + } + + // set new request + if (!query.exec(QString("UPDATE Activities SET RequestFlag=1 WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName))) { + qFatal(qPrintable(query.lastError().text())); + } +} + +void ActivityDatabasePrivate::clearActivityRequestFlag(const QString &applicationName, const QString &activityName) +{ + QSqlQuery query(QSqlDatabase::database(KConnectionName)); + + // just clear the given request + if (!query.exec(QString("UPDATE Activities SET RequestFlag=0 WHERE ApplicationName = '%1' AND ActivityName = '%2'").arg(applicationName).arg(activityName))) { + qFatal(qPrintable(query.lastError().text())); + } +} + +bool ActivityDatabasePrivate::checkTables() +{ + QStringList expectedTables("Activities"); + QStringList actualTables = QSqlDatabase::database(KConnectionName).tables(); + return (expectedTables == actualTables); +} + +void ActivityDatabasePrivate::recreateTables() +{ + QSqlDatabase database = QSqlDatabase::database(KConnectionName); + + if (!database.transaction()) { + qFatal(qPrintable(database.lastError().text())); + } + + // drop any existing tables + { + QSqlQuery dropQuery(database); + foreach(const QString &tableName, database.tables()) { + if (!dropQuery.exec(QString("DROP TABLE %1").arg(tableName))) { + qFatal(qPrintable(dropQuery.lastError().text())); + } + } + } + + // create new table + { + QSqlQuery createQuery(database); + QString statement( + "CREATE TABLE Activities(" + "ApplicationName TEXT NOT NULL," + "ActivityName TEXT NOT NULL," + "RequestFlag BOOL NOT NULL DEFAULT FALSE," + "Data BLOB NOT NULL," + "PRIMARY KEY(ActivityName, ApplicationName))"); + + if (!createQuery.exec(statement)) { + qFatal(qPrintable(createQuery.lastError().text())); + } + } + + if (!database.commit()) { + qFatal(qPrintable(database.lastError().text())); + } +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/activityserviceplugin/win/src/applicationlauncher_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/activityserviceplugin/win/src/applicationlauncher_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "applicationlauncher_p.h" +#include + +bool ApplicationLauncherPrivate::isRunning(int applicationId) +{ + // @todo + return true; +} + +void ApplicationLauncherPrivate::startApplication(int applicationId, const QString &activityId) +{ + // @todo +} + +void ApplicationLauncherPrivate::bringToForeground(int applicationId) +{ + // @todo +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/orbitintegration/hbactivityplugin/hbactivityplugin.qrc --- a/activityfw/orbitintegration/hbactivityplugin/hbactivityplugin.qrc Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/orbitintegration/hbactivityplugin/hbactivityplugin.qrc Thu May 27 13:11:12 2010 +0300 @@ -1,5 +1,5 @@ - ../../activityserviceplugin/activityserviceplugin.xml + ../../activityserviceplugin/data/activityserviceplugin.xml \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 activityfw/orbitintegration/hbactivityplugin/hbactivityplugininterface_p.h --- a/activityfw/orbitintegration/hbactivityplugin/hbactivityplugininterface_p.h Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/orbitintegration/hbactivityplugin/hbactivityplugininterface_p.h Thu May 27 13:11:12 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -11,11 +11,10 @@ * * Contributors: * -* Description: +* Description: * */ - #ifndef HBACTIVITYPLUGININTERFACE_P_H #define HBACTIVITYPLUGININTERFACE_P_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/rom/activitymanager_core.iby --- a/activityfw/rom/activitymanager_core.iby Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/rom/activitymanager_core.iby Thu May 27 13:11:12 2010 +0300 @@ -17,19 +17,17 @@ #ifndef __TSACTMAN_CORE_IBY__ #define __TSACTMAN_CORE_IBY__ -//file=ABI_DIR\BUILD_DIR\activityserviceinstaller.exe PROGRAMS_DIR\activityserviceinstaller.exe file=ABI_DIR\BUILD_DIR\activityserviceplugin.dll SHARED_LIB_DIR\activityserviceplugin.dll data=\epoc32\data\z\resource\qt\plugins\activityserviceplugin.qtplugin resource\qt\plugins\activityserviceplugin.qtplugin file=ABI_DIR\BUILD_DIR\hsactivitydbserver.exe PROGRAMS_DIR\hsactivitydbserver.exe -data=ZPRIVATE\10003a3f\import\apps\hsactivitydbserver_reg.rsc private\10003a3f\import\apps\hsactivitydbserver_reg.rsc -data=\epoc32\data\z\resource\apps\hsactivitydbserver.rsc resource\apps\hsactivitydbserver.rsc file=ABI_DIR\BUILD_DIR\hsactivitydbclient.dll SHARED_LIB_DIR\hsactivitydbclient.dll file=ABI_DIR\BUILD_DIR\hbactivityplugin.dll SHARED_LIB_DIR\hbactivityplugin.dll data=\epoc32\data\z\resource\qt\plugins\hbactivityplugin.qtplugin resource\qt\plugins\hbactivityplugin.qtplugin +data=DATAZ_\resource\activity\activityserviceplugin.xml resource\activity\activityserviceplugin.xml // stub sis data=ZSYSTEM/install/activitymanager_stub.sis system/install/activitymanager_stub.sis diff -r 4bc7b118b3df -r 397d00875918 activityfw/sis/activitymanager.pkg --- a/activityfw/sis/activitymanager.pkg Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/sis/activitymanager.pkg Thu May 27 13:11:12 2010 +0300 @@ -26,14 +26,10 @@ ;Unique Vendor name :"Nokia" - -;"/epoc32/release/armv5/urel/activityserviceinstaller.exe" - "!:\sys\bin\activityserviceinstaller.exe" "/epoc32/release/armv5/urel/activityserviceplugin.dll"-"!:\sys\bin\activityserviceplugin.dll" "/epoc32/data/z/resource/qt/plugins/activityserviceplugin.qtplugin"-"!:\resource\qt\plugins\activityserviceplugin.qtplugin" "/epoc32/release/armv5/urel/hsactivitydbserver.exe" - "!:\sys\bin\hsactivitydbserver.exe" -"/epoc32/data/z/resource/apps/hsactivitydbserver.rsc" - "!:\resource\apps\hsactivitydbserver.rsc" -"/epoc32/data/z/private/10003a3f/import/apps/hsactivitydbserver_reg.rsc" - "!:\private\10003a3f\import\apps\hsactivitydbserver_reg.rsc" "/epoc32/release/armv5/urel/hsactivitydbclient.dll" - "!:\sys\bin\hsactivitydbclient.dll" diff -r 4bc7b118b3df -r 397d00875918 activityfw/sis/stubs/activitymanager_stub.pkg --- a/activityfw/sis/stubs/activitymanager_stub.pkg Fri May 14 16:10:06 2010 +0300 +++ b/activityfw/sis/stubs/activitymanager_stub.pkg Thu May 27 13:11:12 2010 +0300 @@ -36,8 +36,6 @@ "" - "Z:\resource\qt\plugins\activityserviceplugin.qtplugin" "" - "Z:\sys\bin\hsactivitydbserver.exe" -"" - "Z:\resource\apps\hsactivitydbserver.rsc" -"" - "Z:\private\10003a3f\import\apps\hsactivitydbserver_reg.rsc" "" - "Z:\sys\bin\hsactivitydbclient.dll" diff -r 4bc7b118b3df -r 397d00875918 activityfw/sis/stubs/activitymanager_stub.sis Binary file activityfw/sis/stubs/activitymanager_stub.sis has changed diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/bwins/tsutilsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/bwins/tsutilsu.def Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,5 @@ +EXPORTS + ?NewLC@CTsGraphicFileScalingHandler@@SAPAV1@AAVMImageReadyCallBack@@AAVRFs@@ABVTDesC16@@ABVTDesC8@@ABVTSize@@W4TKindOfScaling@1@@Z @ 1 NONAME ; class CTsGraphicFileScalingHandler * CTsGraphicFileScalingHandler::NewLC(class MImageReadyCallBack &, class RFs &, class TDesC16 const &, class TDesC8 const &, class TSize const &, enum CTsGraphicFileScalingHandler::TKindOfScaling) + ?NewL@CTsGraphicFileScalingHandler@@SAPAV1@AAVMImageReadyCallBack@@AAVRFs@@ABVTDesC16@@ABVTDesC8@@ABVTSize@@W4TKindOfScaling@1@@Z @ 2 NONAME ; class CTsGraphicFileScalingHandler * CTsGraphicFileScalingHandler::NewL(class MImageReadyCallBack &, class RFs &, class TDesC16 const &, class TDesC8 const &, class TSize const &, enum CTsGraphicFileScalingHandler::TKindOfScaling) + ??1CTsGraphicFileScalingHandler@@UAE@XZ @ 3 NONAME ; CTsGraphicFileScalingHandler::~CTsGraphicFileScalingHandler(void) + diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/eabi/tsutilsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/eabi/tsutilsu.def Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,9 @@ +EXPORTS + _ZN28CTsGraphicFileScalingHandler4NewLER19MImageReadyCallBackR3RFsRK7TDesC16RK6TDesC8RK5TSizeNS_14TKindOfScalingE @ 1 NONAME + _ZN28CTsGraphicFileScalingHandler5NewLCER19MImageReadyCallBackR3RFsRK7TDesC16RK6TDesC8RK5TSizeNS_14TKindOfScalingE @ 2 NONAME + _ZN28CTsGraphicFileScalingHandlerD0Ev @ 3 NONAME + _ZN28CTsGraphicFileScalingHandlerD1Ev @ 4 NONAME + _ZN28CTsGraphicFileScalingHandlerD2Ev @ 5 NONAME + _ZTI28CTsGraphicFileScalingHandler @ 6 NONAME + _ZTV28CTsGraphicFileScalingHandler @ 7 NONAME + diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/group/bld.inf Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/tsgraphicfilescalinghandler.h + +PRJ_MMPFILES +tsutils.mmp diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/group/tsutils.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/group/tsutils.mmp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +TARGET tsutils.dll +TARGETTYPE dll +UID 0x1000008d 0x20026782 + +CAPABILITY CAP_GENERAL_DLL + +USERINCLUDE ../inc + +SOURCEPATH ../src +SOURCE tsgraphicfilescalinghandler.cpp + +LIBRARY euser.lib +LIBRARY bitmaptransforms.lib +LIBRARY imageconversion.lib +LIBRARY fbscli.lib +LIBRARY efsrv.lib + +//EXPORTUNFROZEN + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/inc/tsgraphicfilescalinghandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/inc/tsgraphicfilescalinghandler.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description : + * + */ +#ifndef TSGRAPHICFILESCALINGHANDLER_H +#define TSGRAPHICFILESCALINGHANDLER_H + +#ifndef __E32SVR_H__ +#define __E32SVR_H__ +#endif + + +#ifndef SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT +#define SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT +#endif + +#include + +class CImageDecoder; +class CFbsBitmap; + +class MImageReadyCallBack +{ +public: + virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap ) = 0; +}; + +class CTsGraphicFileScalingHandler : public CActive +{ +public: + +enum TCurrentOperation{ + ENone = 0, + EConvertBitmapFromFile = 1, + EScale = 2 + }; + +enum TKindOfScaling +{ + EIgnoreAspectRatio = 0, + EKeepAspectRatio = 1, + EKeepAspectRatioByExpanding = 2, +}; + + IMPORT_C ~CTsGraphicFileScalingHandler(); + + IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify, + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); + IMPORT_C static CTsGraphicFileScalingHandler* NewLC(MImageReadyCallBack &aNotify, + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); + +protected: + void DoCancel(); + void RunL(); + TInt RunError(TInt); + +private: + void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType); + CTsGraphicFileScalingHandler(MImageReadyCallBack &aNotify, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); + TSize Scaling(); + +private: + MImageReadyCallBack &mNotify; + CImageDecoder *mImageDecoder; + CFbsBitmap *mBitmapFromFile; + CFbsBitmap *mBitmapOutput; + CBitmapScaler *mBitmapScaler; + TSize mNewSize; + TBool mKindOfScaling; + + TCurrentOperation mCurrentOperation; +}; + +#endif // TSGRAPHICFILESCALINGHANDLER_H diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/src/tsgraphicfilescalinghandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/src/tsgraphicfilescalinghandler.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description : + * + */ +#include "tsgraphicfilescalinghandler.h" +#include + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +CTsGraphicFileScalingHandler::CTsGraphicFileScalingHandler(MImageReadyCallBack &aNotify, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling + /* = CTsGraphicFileScalingHandler::EIgnoreAspectRatio*/) : + CActive(EPriorityNormal), + mNotify(aNotify), + mNewSize(aNewSize), + mKindOfScaling(aKindOfScaling), + mCurrentOperation(ENone) +{ +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +EXPORT_C CTsGraphicFileScalingHandler::~CTsGraphicFileScalingHandler() +{ + Cancel(); + delete mBitmapFromFile; + delete mBitmapOutput; + delete mImageDecoder; + delete mBitmapScaler; +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +EXPORT_C CTsGraphicFileScalingHandler* CTsGraphicFileScalingHandler::NewL(MImageReadyCallBack &aNotify, + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling + /* = CTsGraphicFileScalingHandler::EIgnoreAspectRatio*/) +{ + CTsGraphicFileScalingHandler *self = CTsGraphicFileScalingHandler::NewLC(aNotify, + aFs, + aFileName, + aMimeType, + aNewSize, + aKindOfScaling); + CleanupStack::Pop(); + return self; +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +EXPORT_C CTsGraphicFileScalingHandler* CTsGraphicFileScalingHandler::NewLC(MImageReadyCallBack &aNotify, + RFs &aFs, + const TDesC &aFileName, + const TDesC8& aMimeType, + const TSize &aNewSize, + TKindOfScaling aKindOfScaling + /* = CTsGraphicFileScalingHandler::EIgnoreAspectRatio*/) +{ + CTsGraphicFileScalingHandler *self = new (ELeave) CTsGraphicFileScalingHandler(aNotify, + aNewSize, + aKindOfScaling); + + CleanupStack::PushL(self); + self->ConstructL(aFs, aFileName, aMimeType); + return self; +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CTsGraphicFileScalingHandler::ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType) +{ + if (aFileName.Length() == 0 + || aFs.IsValidName(aFileName) == EFalse) { + User::Leave(KErrPathNotFound); + } + + if (aMimeType.Length() == 0) { + User::Leave(KErrBadName); + } + + if(0>=mNewSize.iWidth || 0>=mNewSize.iHeight) { + User::Leave(KErrCorrupt); + } + + CActiveScheduler::Add(this); + + mBitmapScaler = CBitmapScaler::NewL(); + mBitmapScaler->SetQualityAlgorithm(CBitmapScaler::EMaximumQuality); + + // convert *.png to bitmap + mImageDecoder = CImageDecoder::FileNewL(aFs, aFileName, aMimeType); + mBitmapFromFile = new(ELeave)CFbsBitmap(); + const TFrameInfo frameInfo(mImageDecoder->FrameInfo(0)); + User::LeaveIfError(mBitmapFromFile->Create(frameInfo.iOverallSizeInPixels, + frameInfo.iFrameDisplayMode)); + + mImageDecoder->Convert(&iStatus, *mBitmapFromFile, 0); + mCurrentOperation = EConvertBitmapFromFile; + SetActive(); +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CTsGraphicFileScalingHandler::DoCancel() +{ + switch (mCurrentOperation) { + case EConvertBitmapFromFile: + mImageDecoder->Cancel(); + break; + case EScale: + mBitmapScaler->Cancel(); + break; + } + mNotify.ImageReadyCallBack(KErrCancel, 0); +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CTsGraphicFileScalingHandler::RunL() +{ + User::LeaveIfError(iStatus.Int()); + + switch (mCurrentOperation) { + case EConvertBitmapFromFile: { + delete mImageDecoder; + mImageDecoder = 0; + + mBitmapOutput = new (ELeave)CFbsBitmap(); + User::LeaveIfError(mBitmapOutput->Create(Scaling(), mBitmapFromFile->DisplayMode())); + mBitmapScaler->Scale(&iStatus, *mBitmapFromFile, *mBitmapOutput, EFalse); + mCurrentOperation = EScale; + SetActive(); + break; + } + case EScale: { + mCurrentOperation = ENone; + + delete mBitmapScaler; + mBitmapScaler = 0; + + delete mBitmapFromFile; + mBitmapFromFile = 0; + + if (mKindOfScaling == CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding) { + User::LeaveIfError(mBitmapOutput->Resize(mNewSize)); + } + + mNotify.ImageReadyCallBack(iStatus.Int(), mBitmapOutput); + break; + } + } +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +TSize CTsGraphicFileScalingHandler::Scaling() +{ + TSize originalSize = mBitmapFromFile->SizeInPixels(); + float widthFactor = mNewSize.iWidth / (float)originalSize.iWidth; + float heightFactor = mNewSize.iHeight / (float)originalSize.iHeight; + + TSize retSize(mNewSize); + + if (mKindOfScaling == CTsGraphicFileScalingHandler::EKeepAspectRatio) { + retSize = (widthFactor < heightFactor) ? + TSize(mNewSize.iWidth, widthFactor * originalSize.iHeight) : + TSize(heightFactor * originalSize.iWidth, mNewSize.iHeight); + } else if (mKindOfScaling == CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding) { + retSize = (widthFactor < heightFactor) ? + TSize(heightFactor * originalSize.iWidth, mNewSize.iHeight) : + TSize(mNewSize.iWidth, widthFactor * originalSize.iHeight); + } + return retSize; +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +TInt CTsGraphicFileScalingHandler::RunError(TInt aError) +{ + mNotify.ImageReadyCallBack(aError, 0); + return KErrNone; +} diff -r 4bc7b118b3df -r 397d00875918 activityfw/tsutils/tsutils.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/tsutils.pro Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,18 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +TEMPLATE = subdirs + +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"group/bld.inf\"" diff -r 4bc7b118b3df -r 397d00875918 contentstorage/bwins/camenuu.def --- a/contentstorage/bwins/camenuu.def Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/bwins/camenuu.def Thu May 27 13:11:12 2010 +0300 @@ -21,4 +21,6 @@ ?GetLocalizationsL@CCaStorageProxy@@QAEXAAV?$RPointerArray@VCCaLocalizationEntry@@@@@Z @ 20 NONAME ; void CCaStorageProxy::GetLocalizationsL(class RPointerArray &) ?RunCaServer@@YAHXZ @ 21 NONAME ; int RunCaServer(void) ?GetEntriesIdsL@CCaStorageProxy@@QAEXPBVCCaInnerQuery@@AAV?$RArray@H@@@Z @ 22 NONAME ; void CCaStorageProxy::GetEntriesIdsL(class CCaInnerQuery const *, class RArray &) + ?NewL@CCaSrvMmcHistory@@SAPAV1@XZ @ 23 NONAME ; class CCaSrvMmcHistory * CCaSrvMmcHistory::NewL(void) + ?AddLocalizationL@CCaStorageProxy@@QAEXABVCCaLocalizationEntry@@@Z @ 24 NONAME ; void CCaStorageProxy::AddLocalizationL(class CCaLocalizationEntry const &) diff -r 4bc7b118b3df -r 397d00875918 contentstorage/bwins/cautilsu.def --- a/contentstorage/bwins/cautilsu.def Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/bwins/cautilsu.def Thu May 27 13:11:12 2010 +0300 @@ -96,4 +96,6 @@ ?SetStringIdL@CCaLocalizationEntry@@QAEXABVTDesC16@@@Z @ 95 NONAME ; void CCaLocalizationEntry::SetStringIdL(class TDesC16 const &) ?SetTextId@CCaLocalizationEntry@@QAEXI@Z @ 96 NONAME ; void CCaLocalizationEntry::SetTextId(unsigned int) ?RemoveAttribute@RCaEntryAttrArray@@QAEXABVTDesC16@@@Z @ 97 NONAME ; void RCaEntryAttrArray::RemoveAttribute(class TDesC16 const &) + ?GetQmFilename@CCaLocalizationEntry@@QBEABVRBuf16@@XZ @ 98 NONAME ; class RBuf16 const & CCaLocalizationEntry::GetQmFilename(void) const + ?SetQmFilenameL@CCaLocalizationEntry@@QAEXABVTDesC16@@@Z @ 99 NONAME ; void CCaLocalizationEntry::SetQmFilenameL(class TDesC16 const &) diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/caclient.pri --- a/contentstorage/caclient/caclient.pri Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/caclient.pri Thu May 27 13:11:12 2010 +0300 @@ -15,5 +15,15 @@ # HEADERS += ./inc/*.h \ - ../../homescreensrv_plat/contentstorage_api/*.h + ./../homescreensrv_plat/contentstorage_api/caclient_global.h \ + ./../homescreensrv_plat/contentstorage_api/cadefs.h \ + ./../homescreensrv_plat/contentstorage_api/caentry.h \ + ./../homescreensrv_plat/contentstorage_api/caicondescription.h \ + ./../homescreensrv_plat/contentstorage_api/caitemmodel.h \ + ./../homescreensrv_plat/contentstorage_api/camenuiconutility.h \ + ./../homescreensrv_plat/contentstorage_api/canotifier.h \ + ./../homescreensrv_plat/contentstorage_api/canotifierfilter.h \ + ./../homescreensrv_plat/contentstorage_api/caquery.h \ + ./../homescreensrv_plat/contentstorage_api/caservice.h + SOURCES += ./src/*.cpp diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/inc/canotifier_p.h --- a/contentstorage/caclient/inc/canotifier_p.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/inc/canotifier_p.h Thu May 27 13:11:12 2010 +0300 @@ -18,10 +18,13 @@ #ifndef CANOTIFIER_PRIVATE_H #define CANOTIFIER_PRIVATE_H +#include + class CaClientNotifierProxy; class CaNotifier; class CaNotifierFilter; class CaObserver; +class CaService; class CaNotifierPrivate { @@ -53,6 +56,8 @@ CaClientNotifierProxy *mNotifierProxy; + QSharedPointer mCaService; + friend class CaNotifier; }; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/s60/src/camenuiconmifutility.cpp --- a/contentstorage/caclient/s60/src/camenuiconmifutility.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/s60/src/camenuiconmifutility.cpp Thu May 27 13:11:12 2010 +0300 @@ -20,7 +20,7 @@ #include #include #include // avkon -#include // fbsbitmap +#include // fbsbitmap #include "cabitmapadapter.h" #include "camenuiconmifutility.h" diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/s60/src/camenuiconutility.cpp --- a/contentstorage/caclient/s60/src/camenuiconutility.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/s60/src/camenuiconutility.cpp Thu May 27 13:11:12 2010 +0300 @@ -19,9 +19,14 @@ #include // apparc #include -#include +#include +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#endif // cfbsbitmap -#include +#include #include #include "camenuiconutility.h" @@ -223,16 +228,19 @@ { HbIcon icon; icon = getIconFromEntry(entry); - + if (icon.isNull() || !(icon.size().isValid())) { TRAP_IGNORE(icon = getIconFromApparcL(entry, size)); } - + if (icon.isNull() || !(icon.size().isValid())) { icon = getDefaultIcon(entry); } - + + if (entry.entryTypeName() == XQConversions::s60DescToQString( + KCaTypeWidget)) { + icon.addBadge(Qt::AlignBottom | Qt::AlignLeft, + HbIcon("qtg_small_hs_widget")); + } return icon; } - - diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/src/caicondescription.cpp --- a/contentstorage/caclient/src/caicondescription.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/src/caicondescription.cpp Thu May 27 13:11:12 2010 +0300 @@ -190,7 +190,7 @@ CaIconDescriptionPrivate::CaIconDescriptionPrivate( CaIconDescription *iconDescriptionPublic) : m_q(iconDescriptionPublic), mId(0), mFilename(), mSkinId(), - mApplicationId(0) + mApplicationId() { } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/src/caitemmodel.cpp --- a/contentstorage/caclient/src/caitemmodel.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/src/caitemmodel.cpp Thu May 27 13:11:12 2010 +0300 @@ -712,10 +712,6 @@ && ids.indexOf(id) == mEntries.indexOf(id)) { emit m_q->dataChanged(index(mEntries.indexOf(id)), index( mEntries.indexOf(id))); - } else if (ids.indexOf(id) < 0){ - removeItem(id); - } else if (mEntries.indexOf(id) < 0){ - addItem(id); } else if (mParentEntry && id == mParentEntry->id()) { updateParentEntry(); m_q->reset(); @@ -737,9 +733,17 @@ //we use beginInsertRows and endInsertRows to emit proper signal //(see Qt documentation of QAbstractItemModel) if (mEntries.indexOf(id) < 0 && row >= 0) { - m_q->beginInsertRows(QModelIndex(), row, row); - mEntries.insert(row, id); + if (row > mEntries.count()) { + m_q->beginInsertRows(QModelIndex(), mEntries.count(), mEntries.count()); + mEntries.insert(mEntries.count(), id); + } else { + m_q->beginInsertRows(QModelIndex(), row , row); + mEntries.insert(row, id); + } m_q->endInsertRows(); + } else if (row == -1) { + //we udpade whole model because we do not know parent collecion for given item + updateModel(); } CACLIENTTEST_FUNC_EXIT("CaItemModelPrivate::addItem"); } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/src/canotifier.cpp --- a/contentstorage/caclient/src/canotifier.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/src/canotifier.cpp Thu May 27 13:11:12 2010 +0300 @@ -15,6 +15,8 @@ * */ +#include + #include "canotifier.h" #include "canotifier_p.h" #include "canotifierfilter.h" @@ -53,6 +55,10 @@ CaNotifierFilter notifierFilter(); CaNotifier * notifier = service->createNotifier(notifierfilter); +CaService instance is a singleton and is deleted when nothing references +it but CaNotifier contains a member referencing it, +so, CaService instance is not deleted before notifier is deleted. + // Connections cause that notifier is registered to server distributed // notifications while data changes. if( notifier ) @@ -221,7 +227,8 @@ CaClientNotifierProxy *notifierProxy) : m_q(NULL), mNotifierFilter(NULL), - mObserver(NULL) + mObserver(NULL), + mCaService(CaService::instance()) { mNotifierProxy = notifierProxy; mNotifierFilter = new CaNotifierFilter(notifierFilter); diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/src/caservice.cpp --- a/contentstorage/caclient/src/caservice.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/src/caservice.cpp Thu May 27 13:11:12 2010 +0300 @@ -38,19 +38,25 @@ /*! \class CaService. - \brief This class operates on data, anable creating and inserting new entry + \brief This class operates on data, enables creating and inserting new entry to DB, removing entry from DB, update entry or get entry from DB, execute - command on entry and create notifier to notify client about changes onto DB. + command on entry and create notifier to notify a client about changes onto DB. CaService class uses singleton design pattern, so that it contains static method called instance() to get instance of a class. + References to CaService instance are counted. When the number of references + drops to zero the instance is deleted to save memory. + CaNotifier class contains a member referencing to the CaService instance so + it is not deleted unless all CaNotifier instances are deleted (and there are + no variables referencing CaService). + \code QSharedPointer service = CaService::instance(); \endcode - For every operations on data is used always one instantiation of a class. - Below are examples how to create data and work on those ones. + For every operations on data is used always one instantiation of the class. + Below, there are examples how to create data and work on those ones. */ diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/stub/inc/hswidgetcomponentparser.h --- a/contentstorage/caclient/stub/inc/hswidgetcomponentparser.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/stub/inc/hswidgetcomponentparser.h Thu May 27 13:11:12 2010 +0300 @@ -1,19 +1,20 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ + * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + #ifndef HSWIDGETCOMPONENTPARSER_H #define HSWIDGETCOMPONENTPARSER_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/caclient/stub/src/hswidgetcomponentparser.cpp --- a/contentstorage/caclient/stub/src/hswidgetcomponentparser.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/caclient/stub/src/hswidgetcomponentparser.cpp Thu May 27 13:11:12 2010 +0300 @@ -1,19 +1,20 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ + * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + #include "hswidgetcomponentparser.h" #include diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cahandler/app/app.pro --- a/contentstorage/cahandler/app/app.pro Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/cahandler/app/app.pro Thu May 27 13:11:12 2010 +0300 @@ -50,7 +50,7 @@ -lscrclient \ -lxqutils - exists($${EPOCROOT}epoc32/include/mw/XQSettingsManager):LIBS += -lxqsettingsmanager + exists($${EPOCROOT}epoc32/include/platform/mw/XQSettingsManager):LIBS += -lxqsettingsmanager } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cahandler/app/inc/caapphandler.h --- a/contentstorage/cahandler/app/inc/caapphandler.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/cahandler/app/inc/caapphandler.h Thu May 27 13:11:12 2010 +0300 @@ -23,7 +23,6 @@ // forward declarations class CEikonEnv; class CCaInnerEntry; -class CCaUninstallOperation; class CCaUsifUninstallOperation; /** @@ -100,20 +99,11 @@ * @param aComponentId component id */ void StartUsifUninstallL( TInt aComponentId ); - - - /** - * Start uninstall operation via swi - * @param aEntry the entry - */ - void StartSwiUninstallL(CCaInnerEntry &aEntry ); - private: // data CEikonEnv* iEikEnv; - CCaUninstallOperation* iUninstallOperation; CCaUsifUninstallOperation* iUsifUninstallOperation; }; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cahandler/app/inc/cauninstalloperation.h --- a/contentstorage/cahandler/app/inc/cauninstalloperation.h Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: ?Description - * - */ - -#ifndef C_CAUNINSTALLOPERATION_H -#define C_CAUNINSTALLOPERATION_H - -#include -#include - -/** - * Uninstall CMenuOperation - * Encapsulates the functionality of uninstalling an application. - * - * @lib caclient.lib - */ -NONSHARABLE_CLASS(CCaUninstallOperation): public CActive { - -public: - /** - * Destructor - */ - virtual ~CCaUninstallOperation(); - - /** - * Two-phased constructor. Leaves on failure. - * Allocates memory for and constructs an uninstaller object. After that - * starts asynchronous uninnstallation of the requested entry - * @param aEntry entry to be uninstalled - * @param aPriority priority of the active scheduler responsible for handling - * asynchronous installation operation - * @return The constructed object. - */ - static CCaUninstallOperation *NewL(CCaInnerEntry &aEntry, - TInt aPriority = CActive::EPriorityStandard); - -private: - // construction - /** - * Constructor. - * Starts active scheduler. - * @param aEntry entry to be uninstalle - * @param aPriority priority of the active scheduler responsible for handling - * asynchronous installation operation - */ - CCaUninstallOperation(CCaInnerEntry &aEntry, TInt aPriority); - - /** - * Initializes the object and starts asynchronous uninstallation process. - * @param aEntry entry to be uninstalle - * asynchronous installation operation - */ - void ConstructL(CCaInnerEntry &aEntry); - - /** - * Retrieves package information for requested application uid - * @param aAppUid application uid - @param aMimeType placeholder for resulting mime type of the package - * @param aPackageUid placeholder for resulting package uid of the application - */ - void AppInfoL(const TUid &aAppUid, TPtrC8 &aMimeType, TUid &aPackageUid); - - /** - * Retrieves package uid - * @param aAppFullName application full name - @param aPackageUid placeholder for resulting package uid of the application - @return true if package uid was found - */ - TBool GetInstallPkgUidL(const TDesC &aAppFullName, TUid &aPackageUid); - -private: - // from CActive - - void RunL(); - void DoCancel(); - TInt RunError(TInt aError); - -private: - - CCaInnerEntry &iEntry; - SwiUI::RSWInstLauncher iUninstaller; - TInt iId; -}; - -#endif // C_CAUNINSTALLOPERATION_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cahandler/app/src/caapphandler.cpp --- a/contentstorage/cahandler/app/src/caapphandler.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/cahandler/app/src/caapphandler.cpp Thu May 27 13:11:12 2010 +0300 @@ -29,7 +29,6 @@ #include "caapphandler.h" #include "cainnerentry.h" -#include "cauninstalloperation.h" #include "causifuninstalloperation.h" #include "catasklist.h" @@ -45,7 +44,6 @@ // CCaAppHandler::~CCaAppHandler() { - delete iUninstallOperation; delete iUsifUninstallOperation; } @@ -69,7 +67,6 @@ CCaAppHandler::CCaAppHandler() { iEikEnv = CEikonEnv::Static(); - iUninstallOperation = NULL; iUsifUninstallOperation = NULL; } @@ -226,31 +223,21 @@ // --------------------------------------------------------------------------- // void CCaAppHandler::HandleRemoveL( CCaInnerEntry &aEntry ) -{ - if (!( aEntry.GetFlags() & ERemovable ) ) + { + if( !( aEntry.GetFlags() & ERemovable ) ) { User::Leave( KErrAccessDenied ); } - if ( aEntry.GetEntryTypeName() == KCaTypeApp() ) - { - TComponentId componentId( GetComponentIdL( aEntry,KSoftwareTypeJava ) ); - if ( componentId != KErrNotFound ) - { - StartUsifUninstallL( componentId ); - } - else - { - StartSwiUninstallL( aEntry ); - } - } - else if ( aEntry.GetEntryTypeName() == KCaTypeWidget() ) - { - StartSwiUninstallL( aEntry ); - } - else if( aEntry.GetEntryTypeName() == KCaTypePackage() ) + + const TPtrC entryTypeName(aEntry.GetEntryTypeName()); + + if( entryTypeName == KCaTypeApp() || + entryTypeName == KCaTypePackage() || + entryTypeName == KCaTypeWidget() ) { TPtrC componentId; - if ( aEntry.FindAttribute( KCaAttrComponentId, componentId ) ) + TBool result = aEntry.FindAttribute( KCaAttrComponentId, componentId ); + if( result ) { TInt32 id ; TLex idDesc; @@ -258,12 +245,16 @@ User::LeaveIfError( idDesc.Val( id ) ); StartUsifUninstallL( id ); } + else + { + User::Leave( KErrNotFound ); + } } else { User::Leave( KErrNotSupported ); } -} + } // --------------------------------------------------------------------------- // @@ -307,17 +298,3 @@ iUsifUninstallOperation = CCaUsifUninstallOperation::NewL( aComponentId ); } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CCaAppHandler::StartSwiUninstallL(CCaInnerEntry &aEntry ) -{ - if ( iUninstallOperation && iUninstallOperation->IsActive() ) - { - User::Leave( KErrInUse ); - } - delete iUninstallOperation; - iUninstallOperation = NULL; - iUninstallOperation = CCaUninstallOperation::NewL( aEntry ); -} diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cahandler/app/src/cauninstalloperation.cpp --- a/contentstorage/cahandler/app/src/cauninstalloperation.cpp Fri May 14 16:10:06 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: ?Description - * - */ - -#include -#include -#include - -#include "cautils.h" -#include "cadef.h" -#include "cainnerentry.h" -#include "cauninstalloperation.h" -_LIT8(KAppMimeType, "x-epoc/x-sisx-app"); - -// ================= MEMBER FUNCTIONS ======================= - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::~CCaUninstallOperation -// --------------------------------------------------------------------------- -// -CCaUninstallOperation::~CCaUninstallOperation() -{ - Cancel(); - iUninstaller.Close(); -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::NewL -// --------------------------------------------------------------------------- -// -CCaUninstallOperation *CCaUninstallOperation::NewL(CCaInnerEntry &aEntry, - TInt aPriority) -{ - CCaUninstallOperation *self; - - self = new(ELeave) CCaUninstallOperation(aEntry, aPriority); - CleanupStack::PushL(self); - self->ConstructL(aEntry); - CleanupStack::Pop(self); - return self; -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::CCaUninstallOperation -// --------------------------------------------------------------------------- -// -CCaUninstallOperation::CCaUninstallOperation(CCaInnerEntry &aEntry, - TInt aPriority) : - CActive(aPriority), iEntry(aEntry), iUninstaller(), iId(0) -{ - CActiveScheduler::Add(this); -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::ConstructL -// --------------------------------------------------------------------------- -// -void CCaUninstallOperation::ConstructL(CCaInnerEntry &aEntry) -{ - TUint uid = aEntry.GetUid(); - - TUid packageUid = KNullUid; - TPtrC8 mimeType; - - if (!(aEntry.GetFlags() & ERemovable)) { - User::Leave(KErrAccessDenied); - } - - User::LeaveIfError(iUninstaller.Connect()); - iId = aEntry.GetId(); - if (aEntry.GetEntryTypeName() == KCaTypeWidget()) { - TBuf uidDesc; - aEntry.FindAttribute(KCaPackageUid, uidDesc); - TLex uidLex(uidDesc); - TUint32 uidValue; - User::LeaveIfError(uidLex.Val(uidValue, EHex)); - - packageUid.iUid = static_cast(uidValue); - mimeType.Set(KAppMimeType); - } else { - AppInfoL(TUid::Uid(uid), mimeType, packageUid); - } - - // Commence the uninstallations - iUninstaller.Uninstall(iStatus, packageUid, mimeType); - SetActive(); -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::AppInfo -// --------------------------------------------------------------------------- -// -void CCaUninstallOperation::AppInfoL(const TUid &aAppUid, - TPtrC8 &aMimeType, TUid &aPackageUid) -{ - RApaLsSession apaLsSession; - - User::LeaveIfError(apaLsSession.Connect()); - CleanupClosePushL(apaLsSession); - User::LeaveIfError(apaLsSession.GetAllApps()); - - // TApaAppInfo size is greater then 1024 bytes - // so its instances should not be created on the stack. - TApaAppInfo* appInfo = new(ELeave) TApaAppInfo(); - CleanupStack::PushL(appInfo); - User::LeaveIfError(apaLsSession.GetAppInfo(*appInfo, aAppUid)); - if (!GetInstallPkgUidL(appInfo->iFullName, aPackageUid)) { - aPackageUid = aAppUid; - } - CleanupStack::PopAndDestroy(appInfo); - aMimeType.Set(KAppMimeType); - - CleanupStack::PopAndDestroy(&apaLsSession); -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::GetInstallPkgUidL -// --------------------------------------------------------------------------- -// -TBool CCaUninstallOperation::GetInstallPkgUidL(const TDesC &aAppFullName, - TUid &aPackageUid) -{ - // Search for the full name of the application amongst every file name in - // every installed packages. - TBool found = EFalse; - Swi::RSisRegistrySession iSisRegSession; - - // Get the array of ids of every installed packages - if (KErrNone != iSisRegSession.Connect()) { - return found; - } - CleanupClosePushL(iSisRegSession); - - RArray packageIds; - CleanupClosePushL(packageIds); - - iSisRegSession.InstalledUidsL(packageIds); - - RPointerArray packageFiles; - CleanupClosePushL(packageFiles); - - for (TInt i = 0; i < packageIds.Count() && !found; ++i) { - const TUid packageId = packageIds[i]; - Swi::RSisRegistryEntry packageEntry; - - // Get the array of file names in the current install package and look - // if there is one suggesting that the application was installed from - // the package. - if (KErrNone == packageEntry.Open(iSisRegSession, packageId)) { - CleanupClosePushL(packageEntry); - packageEntry.FilesL(packageFiles); - for (TInt pf = 0; pf < packageFiles.Count() && !found; ++pf) { - if (packageFiles[pf]->FindC(aAppFullName) == 0) { - aPackageUid = packageId; - found = ETrue; - } - } - packageFiles.ResetAndDestroy(); - CleanupStack::PopAndDestroy(&packageEntry); - } - } - - CleanupStack::PopAndDestroy(&packageFiles); - CleanupStack::PopAndDestroy(&packageIds); - CleanupStack::PopAndDestroy(&iSisRegSession); - - return found; -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::RunL -// --------------------------------------------------------------------------- -// -void CCaUninstallOperation::RunL() -{ - iUninstaller.Close(); -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::DoCancel -// --------------------------------------------------------------------------- -// -void CCaUninstallOperation::DoCancel() -{ - iUninstaller.CancelAsyncRequest(SwiUI::ERequestUninstall); -} - -// --------------------------------------------------------------------------- -// CCaUninstallOperation::RunError -// --------------------------------------------------------------------------- -// -TInt CCaUninstallOperation::RunError(TInt /* aError */) -{ - return KErrNone; -} diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cahandler/url/url.pro --- a/contentstorage/cahandler/url/url.pro Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/cahandler/url/url.pro Thu May 27 13:11:12 2010 +0300 @@ -48,7 +48,7 @@ -lefsrv \ -lxqutils - exists($${EPOCROOT}epoc32/include/mw/XQSettingsManager):LIBS += -lxqsettingsmanager + exists($${EPOCROOT}epoc32/include/platform/mw/XQSettingsManager):LIBS += -lxqsettingsmanager } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/casoftwareregistry.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/casoftwareregistry.pri Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,18 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +HEADERS += ../../homescreensrv_plat/contentstorage_api/casoftwareregistry.h +SOURCES += ./src/*.cpp diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/casoftwareregistry.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/casoftwareregistry.pro Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,54 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = lib + +DEFINES += CACLIENT_LIB + +include(../../common.pri) +include(casoftwareregistry.pri) + +DEPENDPATH += ./inc \ + ./src +INCLUDEPATH += ./inc \ + ../inc + +symbian: { + +TARGET.UID2 = 0x1000008D +TARGET.UID3 = 0x2002DCF5 + +TARGET.CAPABILITY = CAP_GENERAL_DLL +TARGET.VENDORID = VID_DEFAULT + +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + +LIBS += -leuser \ + -lbafl \ + -lestor \ + -lscrclient \ + -lxqutils + +include(casoftwareregistry_s60.pri) +} + +win32: { +DEPENDPATH += ./stub/inc \ + ./stub/src +INCLUDEPATH += ./stub/inc + +include(casoftwareregistry_stub.pri) +} \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/casoftwareregistry_s60.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/casoftwareregistry_s60.pri Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +DEPENDPATH += ./s60/inc \ + ./s60/src + +INCLUDEPATH += ./s60/inc + +HEADERS += ./s60/inc/*.h + +SOURCES += ./s60/src/*.cpp diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/casoftwareregistry_stub.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/casoftwareregistry_stub.pri Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,20 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +DEPENDPATH += ./stub/inc \ + ./stub/src +INCLUDEPATH += ./stub/inc +HEADERS += ./stub/inc/*.h +SOURCES += ./stub/src/*.cpp \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/s60/inc/casoftwareregistry_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/s60/inc/casoftwareregistry_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: casoftwareregistry_p.h + * + */ + +#ifndef CA_SOFTWARE_REGISTRY_PRIVATE_H +#define CA_SOFTWARE_REGISTRY_PRIVATE_H + +#include +#include + +class CaSoftwareRegistry; +namespace Usif +{ + class CComponentEntry; +} + +class CaSoftwareRegistryPrivate +{ +public: + + typedef QHash DetailMap; + + explicit CaSoftwareRegistryPrivate( + CaSoftwareRegistry *softwareRegistryPublic); + ~CaSoftwareRegistryPrivate(); + + DetailMap entryDetails(int componentId) const; + + DetailMap entryDetails( + const Usif::CComponentEntry& entry) const; +private: + CaSoftwareRegistry *const m_q; + +}; + +#endif // CA_SOFTWARE_REGISTRY_PRIVATE_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/s60/src/casoftwareregistry_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/s60/src/casoftwareregistry_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: ?Description + * + */ +#include +#include +#include +#include + +#include +#include +#include + +#include "casoftwareregistry.h" +#include "casoftwareregistry_p.h" + +using namespace Usif; + +template +struct RClassDeleter +{ + static inline void cleanup(RClass *ptr) + { + ptr->Close(); + } +}; + +typedef QScopedPointer > ScrScopedPointer; +/*! + Constructor + \param servicePublic Pointer to object of the public class. + */ +CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate( + CaSoftwareRegistry *servicePublic): + m_q(servicePublic) +{ +} + +/*! + Destructor. + */ +CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate() +{ +} + +/*! + \param componentId Component id of the entry which details are requested for. + \return Map of component details if component id was greater than 0 or + empty map otherwise. + */ +CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails( + int componentId) const +{ + CaSoftwareRegistry::DetailMap result; + + if (componentId >= 1) { + ScrScopedPointer scr(new RSoftwareComponentRegistry); + QT_TRAP_THROWING(User::LeaveIfError(scr->Connect())); + + QScopedPointer entry; + + QT_TRAP_THROWING(entry.reset(CComponentEntry::NewL())); + QT_TRAP_THROWING(scr->GetComponentL(componentId, *entry)); + result = entryDetails(*entry); + } + + return result; +} + +/*! + \param entry Software registry entry providing details. + \return Map with details for the component represented by \entry. + */ +CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails( + const CComponentEntry& entry) const +{ + CaSoftwareRegistry::DetailMap detailMap; + + detailMap[CaSoftwareRegistry::componentNameKey()] = + XQConversions::s60DescToQString(entry.Name()); + + detailMap[CaSoftwareRegistry::componentVersionKey()] = + XQConversions::s60DescToQString(entry.Version()); + + detailMap[CaSoftwareRegistry::componentVendorKey()] = + XQConversions::s60DescToQString(entry.Vendor()); + + QString drives; + const TInt driveListLen(entry.InstalledDrives().Length()); + for (TInt i( 0 ); i < driveListLen; ++i) { + if (entry.InstalledDrives()[i] != '\0') { + if (!drives.isEmpty()) { + drives = drives.append(","); + } + drives = drives.append(QChar('A'+ i)).append(":"); + } + } + + detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives; + detailMap[CaSoftwareRegistry::componentSizeKey()].setNum( + entry.ComponentSize() / 1024); + + detailMap[CaSoftwareRegistry::componentTypeKey()] = + XQConversions::s60DescToQString(entry.SoftwareType()); + + return detailMap; +} diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/src/casoftwareregistry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/src/casoftwareregistry.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: ?Description + * + */ +#include +#include +#include + + +#include "casoftwareregistry.h" +#include "casoftwareregistry_p.h" + + +// ======== MEMBER FUNCTIONS ======== + +/*! + + \class CaSoftwareRegistry. + \brief This class provides access to USIF provided data and converting + them from Symbian to Qt types. + + CaSoftwareRegistry class provides a factory method which returns smart pointer + to CaSoftwareRegistry instnce to ensure + automatical memory cleanup once the reference count drops to 0. + + \code + QSharedPointer service = CaSoftwareRegistry::create(); + \endcode + + Subsequent calls to CaSoftwareRegistry::create() may return pointers to different + instances. It is a case when between the calls instance counter of the created + object dropped to 0 and it was deleted. + + */ + +/*! \typedef typedef QHash DetailMap; + * Defines map type for component details. + * + */ + +/*! + \var CaSoftwareRegistryPrivate::m_q + Points to the CaSoftwareRegistry instance that uses this private implementation. + */ + + +// Initialization of a static member variable. +QWeakPointer CaSoftwareRegistry::m_instance = + QWeakPointer(); + + +/*! + Constructor. + \param parent pointer to a parent. It defaults to NULL. + */ +CaSoftwareRegistry::CaSoftwareRegistry(QObject *parent) : + QObject(parent), m_d(new CaSoftwareRegistryPrivate(this)) +{ + +} + +/*! + Returns a pointer to an instance of the CaSoftwareRegistry class. + \retval A pointer to an instance of the CaSoftwareRegistry class. + */ +QSharedPointer CaSoftwareRegistry::create() +{ + QSharedPointer service(m_instance); + if (!service) { + service = QSharedPointer(new CaSoftwareRegistry); + m_instance = service.toWeakRef(); + } + return service; +} + +/*! + Destructor. + */ +CaSoftwareRegistry::~CaSoftwareRegistry() +{ + delete m_d; +} + +/*! + The method provides component details from USIF for a given component id. + \code + QSharedPointer service = CaSoftwareRegistry::create(); + CaSoftwareRegistry::DetailMap detailMap = service->entryDetails(5); + QString appName = detailMap[CaSoftwareRegistry::componentNameKey()]; + \endcode + \param componentId Component id of the entry details are requested for. + \return Map of the component details if component id was greater than 0 or + empty map otherwise. + + */ +CaSoftwareRegistry::DetailMap CaSoftwareRegistry::entryDetails( + int componentId) const +{ + return m_d->entryDetails(componentId); +} + +/*! + * \return Component name key in CaSoftwareRegistry::DetailMap. + */ +QString CaSoftwareRegistry::componentNameKey() +{ + static const QString key("name"); + return key; +} + +/*! + * \return Component version key in CaSoftwareRegistry::DetailMap. + */ +QString CaSoftwareRegistry::componentVersionKey() +{ + static const QString key("version"); + return key; +} + +/*! + * \return Component vendor key in CaSoftwareRegistry::DetailMap. + */ +QString CaSoftwareRegistry::componentVendorKey() +{ + static const QString key("vendor"); + return key; +} + +/*! + * \return Component drive info key in CaSoftwareRegistry::DetailMap. + */ +QString CaSoftwareRegistry::componentDriveInfoKey() +{ + static const QString key("driveInfo"); + return key; +} + +/*! + * \return Component size info key in CaSoftwareRegistry::DetailMap. + */ +QString CaSoftwareRegistry::componentSizeKey() +{ + static const QString key("size"); + return key; +} + +/*! + * \return Component type key in CaSoftwareRegistry::DetailMap. + */ +QString CaSoftwareRegistry::componentTypeKey() +{ + static const QString key("type"); + return key; +} + + + diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/stub/inc/casoftwareregistry_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/stub/inc/casoftwareregistry_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: casoftwareregistry_p.h + * + */ + +#ifndef CA_SOFTWARE_REGISTRY_PRIVATE_H +#define CA_SOFTWARE_REGISTRY_PRIVATE_H + +#include +#include + +class CaSoftwareRegistry; + +class CaSoftwareRegistryPrivate +{ +public: + typedef QHash DetailMap; + + explicit CaSoftwareRegistryPrivate( + CaSoftwareRegistry *softwareRegistryPublic); + ~CaSoftwareRegistryPrivate(); + + DetailMap entryDetails(int componentId) const; +private: + + CaSoftwareRegistry *const m_q; + +}; + +#endif // CA_SOFTWARE_REGISTRY_PRIVATE_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casoftwareregistry/stub/src/casoftwareregistry_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/casoftwareregistry/stub/src/casoftwareregistry_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: ?Description + * + */ +#include +#include +#include + + +#include "casoftwareregistry.h" +#include "casoftwareregistry_p.h" + + +/* + Constructor + \param servicePublic Pointer to object of the public class. + */ +CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate(CaSoftwareRegistry *servicePublic) : + m_q(servicePublic) +{ +} + +/* + Destructor. + */ +CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate() +{ +} + +/* + Stub for windows development. + \param Component id. + \return Map with dummy entries when component id is greater than 0, otherwise + empty map. + */ +CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails( + int componentId) const +{ + CaSoftwareRegistry::DetailMap detailMap; + + if (componentId >=1) { + detailMap[CaSoftwareRegistry::componentNameKey()] = "no data"; + + detailMap[CaSoftwareRegistry::componentVersionKey()] = "no data"; + + detailMap[CaSoftwareRegistry::componentVendorKey()] = "no data"; + + detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = "no data"; + + detailMap[CaSoftwareRegistry::componentSizeKey()] = "no data"; + + detailMap[CaSoftwareRegistry::componentTypeKey()] = "no data"; + } + return detailMap; +} + diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/caappscanner/group/caappscanner.mmp --- a/contentstorage/casrv/caappscanner/group/caappscanner.mmp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/caappscanner/group/caappscanner.mmp Thu May 27 13:11:12 2010 +0300 @@ -57,5 +57,6 @@ LIBRARY efsrv.lib LIBRARY sisregistryclient.lib LIBRARY platformenv.lib +LIBRARY scrclient.lib // temporary till cWRT will be in SCR LIBRARY WidgetRegistryClient.lib diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/caappscanner/inc/casrvappscanner.h --- a/contentstorage/casrv/caappscanner/inc/casrvappscanner.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/caappscanner/inc/casrvappscanner.h Thu May 27 13:11:12 2010 +0300 @@ -22,10 +22,10 @@ #include #include #include +#include #include "cainstallnotifier.h" #include "castorage_global.h" -class TCaAppAtributes; class CCaSrvMmcHistory; class CCaInnerEntry; class CCaStorageProxy; @@ -78,6 +78,16 @@ static CCaSrvAppScanner* NewL( CCaStorageProxy& aCaStorageProxy, CCaSrvEngUtils& aUtils ); +public: + // from MCaInstallListener + + /** + * Handle Install Event. + * @since S60 v5.0 + * @param aUid installed/uninstalled app uid. + */ + void HandleInstallNotifyL( TInt aUid ); + private: // Constructors and destructor @@ -94,29 +104,19 @@ */ void ConstructL(); -public: - // from MCaInstallListener - - /** - * Handle Install Event. - * @since S60 v5.0 - * @param aUid installed/uninstalled app uid. - */ - void HandleInstallNotifyL( TInt aUid ); - private: /** - * Notifies storage abaut change for aAppUid. + * Notifies storage about change for aAppUid. * @param aAppUid application uid. */ void NotifyL( TInt aAppUid ); /** - * Notifies storage abaut change for aPackageEntry related app. + * Notifies storage about change for aPackageEntry related app. * @param aPackageEntry application package entry. */ - void NotifyL( Swi::RSisRegistryEntry & aPackageEntry ); + void NotifyL( Swi::RSisRegistryEntry& aPackageEntry ); private: // from CActive @@ -133,7 +133,7 @@ /** * Error handling: ignore error. - * @param aErr Error code. + * @param aError Error code. */ TInt RunError( TInt aError ); @@ -142,46 +142,39 @@ void HandleAppListEvent( TInt aEvent ); -public: - /** - * Schedule appscanner run. - * Self complete active object. - */ - void ScheduleScan(); - private: // new methods /** - * Gets collectionId of download collection - * @result id of download collection + * Gets collectionId of download collection. + * @result id of download collection. */ TInt GetCollectionDownloadIdL(); /** - * Gets collectionId of all collection - * @result id of all collection + * Gets collectionId of all collection. + * @result id of all collection. */ TInt GetAllCollectionIdL(); /** - * Adds application entry to downloaded collection + * Adds application entry to downloaded collection. * @param aEntryId application entry id. */ void AddEntryToDownloadedCollectionL( TInt aEntryId ); /** - * Add application entry to predefined collection + * Add application entry to predefined collection. * @param aEntry application entry. - * @param aUpdate is entry updated by a client + * @param aUpdate is entry updated by a client. */ void AddEntryToPredefinedCollectionL( CCaInnerEntry* aEntry, TBool aUpdate = EFalse ); /** - * Create predefined collection + * Create predefined collection. * @param aGroupName group name. - * @result id of new created collection + * @result id of a newly created collection. */ TInt CreatePredefinedCollectionL( const TDesC& aGroupName ); @@ -192,94 +185,95 @@ void AddCollectionToAllCollectionL( TInt aCollectionId ); /** - * Removes application entry from downloaded collection + * Removes application entry from downloaded collection. * @param aEntryId application entry id. */ void RemoveEntryFromDownloadedL( TInt aEntryId ); - TBool HandleLockDeleteFlagUpdateL( CCaInnerEntry* aItem ); + /** + * Updates application's removable and visible flags. + * @param aItem menu item. + * @return ETrue if flags were updated. + */ + TBool HandleRemovableVisibleFlagsUpdateL( CCaInnerEntry* aItem ); /** * Updates application's missing and visible flags. - * Add new menu item referring to this application. * @param aItem menu item. - * @return ETrue if flags were updated + * @return ETrue if flags were updated. */ TBool HandleMissingVisibleFlagsUpdate( CCaInnerEntry* aItem ); /** * Updates visible flag. * @param aItem menu item. - * @param aUid Application's uid. - * @return ETrue if visible flag was updated + * @return ETrue if visible flag was updated. */ TBool HandleVisibleFlagUpdate( CCaInnerEntry* aItem ); /** * Updates used flag. * @param aItem menu item. - * @param aUid Application's uid. - * @return ETrue if used flag was updated + * @return ETrue if used flag was updated. */ TBool HandleUsedFlagUpdate( CCaInnerEntry* aItem ); + /** * Updates mmc attribute. * @param aItem menu item. - * @param aUid Application's uid. * @param aMmcId MMC ID of currently inserted MMC, or 0. - * @return ETrue if mmc attribute was updated + * @return ETrue if mmc attribute was updated. */ TBool HandleMmcAttrUpdateL( CCaInnerEntry* aItem, TUint aMmcId ); /** - * Check if application is in rom + * Check if application is in rom. * Add new menu item referring to this application. - * @param aUid uid applications - * @return ETrue if app is in rom + * @return ETrue if app is in rom. */ TBool IsInRomL( TInt aUid ); /** - * Get applications from AppArc - * @param aArray RArray with applications + * Get applications from AppArc. + * @param aArray RArray with applications' uids. */ - void GetApaItemsL( RArray& aArray ); + void GetApaItemsL( RArray& aArray ); /** - * Remove application from array (found in AppArc) - * @param aArray RArray with application - * @param aUid uid of application to remove + * Remove application from array (found in AppArc). + * @param aArray RArray with applications' uids. + * @param aUid uid of application to remove. */ - void RemoveApp( RArray& aArray, TInt32 aUid ); + void RemoveApp( RArray& aArray, TInt32 aUid ); /** - * Get applications from CaStorage - * @param aArray RPointerArray with CCaInnerEntries - * contains applications + * Get applications from CaStorage. + * @param aArray RPointerArray with CCaInnerEntries. + * contains applications. */ void GetCaAppEntriesL( RPointerArray& aArray ); /** - * Remove sat application from array(found in CaStorage) + * Remove sat application from array(found in CaStorage). * @param aArray RPointerArray with CCaInnerEntries - * contains applications + * contains applications. */ void RemoveSatAppL( RPointerArray& aArray ); /** - * Ensure that HsApplicaiton is not visible: Add HsApplication + * Ensure that HsApplicaiton is not visible: Add HsApplication. * as hidden to CaStorage or remove HsApplication entry * from array (found in CaStorage). * @param aArray RPointerArray with CCaInnerEntries - * contains application + * contains application. */ void HandleHsAppEntryL( RPointerArray& aArray ); /** - * Get application with specified uid from CaStorage - * @param aUid RPointerArray with CCaInnerEntries + * Get application with specified uid from CaStorage. + * @param aUid RPointerArray with CCaInnerEntries. * @param aArray RPointerArray with CCaInnerEntries - * contains application + * contains application. */ void GetCaAppEntriesL( TInt aUid, RPointerArray& aArray ); @@ -293,30 +287,22 @@ /** * Removes given uid from iInstalledPackages. - * Add new menu item referring to this application. - * @param aUid Application capability. + * @param aUid Application uid. */ void RemoveFromInstalledPackages( TUint aUid ); /** - * Set information from TApaAppInfo to entry + * Set information from TApaAppInfo to entry. * @param aEntry CCaInnerEntry with application. * @return ETrue if app info was updatedd */ TBool SetApaAppInfoL( CCaInnerEntry* aEntry ); /** - * Find the default folder (folder having attribute 'default="1"'). - * If not found, return 0. - * @param aFolderId Dedault folder or 0. - */ - void DefaultFolderL( TInt& aFolderId ); - - /** - * Handle items are in the menu but no corresponding app is present: - * - Items that are on a recently used MMC are get "missing" flag but kept. + * Handle items which are in the menu but no corresponding app is present: + * - Items that are on a recently used MMC get "missing" flag but kept. * - Items that are not on MMC or the MMC is not recently used, are - * removed form the menu. + * removed from the menu. * @param aItems Missing items. */ void HandleMissingItemsL( RPointerArray& aCaEnties ); @@ -334,7 +320,7 @@ void SetMissingFlagL( CCaInnerEntry* aEntry ); /** - * Set "visible" flag. + * Clear "visible" flag (and also "missing" and "used"). * @param aEntry entry. */ void ClearVisibleFlagL( CCaInnerEntry* aEntry ); @@ -347,23 +333,24 @@ /** * Get current MMC id. 0 if no MMC is inserted, or in case of any errors. - * @return Current MMC id, or 0. + * @return Current MMC id or 0. */ TUint CurrentMmcId() const; /** - * Check if file is on given default drive type. + * Check if file is on a given default drive type. * @param aFileName File name. - * @return ETrue if aFileName is on given default drive type. + * @param aDefaultDrive default drive type + * @return ETrue if aFileName is on a given default drive type. */ TBool IsFileInDrive( const TDesC& aFileName, const DriveInfo::TDefaultDrives& aDefaultDrive ) const; /** - * Check if application is installed on given drive type. + * Check if application is installed on a given drive type. * @param aUid app uid. - * @param aDefaultDrive drive type. - * @return ETrue if app is installed on given drive type. + * @param aDefaultDrive default drive type. + * @return ETrue if app is installed on a given drive type. */ TBool IsAppInDriveL( const TUid aUid, const DriveInfo::TDefaultDrives& aDefaultDrive ) const; @@ -390,29 +377,29 @@ TBool IsDriveInUse( const DriveInfo::TDefaultDrives& aDefaultDrive ); /** - * Add application to storage or update entry if necessary - * @param aCaEnties with applications from storage - * @param aApaItem application item with uid and hidden flag on or off - * @param aMmcId unique mmc id + * Add application to storage or update entry if necessary. + * @param aCaEnties with applications from storage. + * @param aAppUid application uid. + * @param aMmcId unique mmc id. */ void UpdateApplicationEntryL( RPointerArray& aCaEnties, - const TCaAppAtributes& aApaItem, TUint aMmcId ); + TUint aAppUid, TUint aMmcId ); /** - * Update entry from storage - * @param aEntry application entry - * @param aMmcId unique mmc id + * Update entry from storage. + * @param aEntry application entry. + * @param aMmcId unique mmc id. */ void UpdateAppEntryL( CCaInnerEntry* aEntry, TUint aMmcId ); /** - * Get all application from storage and visible from apparc - * and update if necessary + * Get all applications from storage and visible from apparc + * and update if necessary. */ void UpdateApplicationEntriesL(); /** - * Notifys storage abaut updated apps + * Notifys storage about updated apps. */ void InstallationNotifyL(); @@ -423,22 +410,38 @@ /** * Make collection visible if has visible entry. - * @param aEntry application entry + * @param aEntry application entry. */ void MakeCollectionVisibleIfHasVisibleEntryL( CCaInnerEntry* aEntry ); + + /** + * Adds or updates component id attribute in entry based on SCR provided data + * @param appInfo application data carrying full path name of application file. + * @param aEntry entry being updated with component id attribute. + * @return ETrue when component id attribute of the entry has been added or changed. + */ + TBool UpdateComponentIdL( TApaAppInfo& appInfo, + CCaInnerEntry& aEntry ) const; + + /** + * Schedule appscanner run. + * Self complete active object. + */ + void ScheduleScan(); private: // data RApaLsSession iApaLsSession; ///< AppArc session. Own. CApaAppListNotifier* iNotifier; ///< Change notifier. Own. - CCaInstallNotifier* iInstallNotifier;///< Install notifier. Own. + CCaInstallNotifier* iInstallNotifier; ///< Install notifier. Own. CCaSrvMmcHistory* iMmcHistory; ///< MMC history. Own. RFs iFs; ///< File Server Session. Own. + Usif::RSoftwareComponentRegistry iSoftwareRegistry; - CCaStorageProxy& iCaStorageProxy;///< not own - CCaSrvEngUtils& iSrvEngUtils;// iInstalledPackages; + CCaStorageProxy& iCaStorageProxy; ///< Not own + CCaSrvEngUtils& iSrvEngUtils; ///< Not own + RArray iInstalledPackages; ///< Own. TInt iCollectionDownloadId; TInt iAllCollectionId; @@ -446,39 +449,4 @@ }; -/** - * Application atributes. - * Object contains uid and hidden flag - */ -class TCaAppAtributes - { - -public: - /** - * Constructor. - * @param aUid uid application. - */ - TCaAppAtributes( TUint aUid ); - - /* - * Get uid - * @return application uid - */ - TUint GetUid() const; - - /* - * Match application items - * @param item1 first item to matching. - * @param item2 second item to matching. - */ - static TBool MatchItems( const TCaAppAtributes& item1, - const TCaAppAtributes& item2 ); - -private: - // data - - TUint iUid;///< uid application - - }; - #endif /* CASRVAPPSCANNER_H_ */ diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/caappscanner/src/casrvappscanner.cpp --- a/contentstorage/casrv/caappscanner/src/casrvappscanner.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/caappscanner/src/casrvappscanner.cpp Thu May 27 13:11:12 2010 +0300 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "cadef.h" @@ -33,7 +34,9 @@ #include "caarraycleanup.inl" #include "castorageproxy.h" +#include "caarraycleanup.inl" +using namespace Usif; // ==================== LOCAL FUNCTIONS ==================== @@ -66,7 +69,7 @@ // ==================== MEMBER FUNCTIONS ==================== // --------------------------------------------------------- -// CCaSrvAppScanner::NewL +// // --------------------------------------------------------- // CCaSrvAppScanner* CCaSrvAppScanner::NewL( CCaStorageProxy& aCaStorageProxy, @@ -81,12 +84,13 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::~CCaSrvAppScanner +// // --------------------------------------------------------- // CCaSrvAppScanner::~CCaSrvAppScanner() { Cancel(); + iSoftwareRegistry.Close(); iApaLsSession.Close(); iInstalledPackages.Close(); delete iInstallNotifier; @@ -96,7 +100,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::CCaSrvAppScanner +// // --------------------------------------------------------- // CCaSrvAppScanner::CCaSrvAppScanner( CCaStorageProxy& aCaStorageProxy, @@ -108,7 +112,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::ConstructL +// // --------------------------------------------------------- // void CCaSrvAppScanner::ConstructL() @@ -117,7 +121,7 @@ TFileName path; User::LeaveIfError( iFs.PrivatePath( path ) ); TUint attribute; - if( iFs.Att( path, attribute) == KErrNotFound ) + if( iFs.Att( path, attribute ) == KErrNotFound ) { TInt mdRes = iFs.MkDirAll( path ); if ( mdRes != KErrNone ) @@ -125,10 +129,8 @@ User::Leave( mdRes ); } } - iMmcHistory = new (ELeave) CCaSrvMmcHistory(); + iMmcHistory = CCaSrvMmcHistory::NewL(); iMmcHistory->LoadL( iFs, KCaMmcHistoryFname() ); - // The notifier has its own session to apparc, instead of taking - // it as argument... :( iNotifier = CApaAppListNotifier::NewL( this, CActive::EPriorityStandard ); iInstallNotifier = CCaInstallNotifier::NewL( @@ -136,6 +138,7 @@ User::LeaveIfError( iApaLsSession.Connect() ); User::LeaveIfError( iApaLsSession.GetAllApps() ); // This is async. + User::LeaveIfError( iSoftwareRegistry.Connect() ); iApaLsSession.RegisterListPopulationCompleteObserver( iStatus ); iCollectionDownloadId = 0; iAllCollectionId = 0; @@ -143,12 +146,12 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::RunL +// // --------------------------------------------------------- // void CCaSrvAppScanner::RunL() { - User::LeaveIfError( iStatus.Int() ); // Handle errors in RunL. + User::LeaveIfError( iStatus.Int() ); // AppArc app scan complete, we have the app list. UpdateApplicationEntriesL(); InstallationNotifyL(); @@ -156,7 +159,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::DoCancel +// // --------------------------------------------------------- // void CCaSrvAppScanner::DoCancel() @@ -165,43 +168,42 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::RunError +// // --------------------------------------------------------- // TInt CCaSrvAppScanner::RunError( TInt /*aError*/) { // Ignore the error (what else could we do?). - // When next AppArc update occurs, we will run again. + // When next update occurs, we will run again. return KErrNone; } // --------------------------------------------------------- -// CCaSrvAppScanner::UpdateApplicationItemL +// // --------------------------------------------------------- // void CCaSrvAppScanner::UpdateApplicationEntryL( RPointerArray& aCaEntries, - const TCaAppAtributes& aApaItem, TUint aMmcId ) + TUint aAppUid, TUint aMmcId ) { - TInt appuid = aApaItem.GetUid(); RPointerArray resultArray; CleanupResetAndDestroyPushL( resultArray ); - GetCaAppEntriesL( appuid, resultArray ); + GetCaAppEntriesL( aAppUid, resultArray ); // This app is not in the storage, add it now. // We don't add hidden items, there are too many of them! // do not display Menu app if( !resultArray.Count() ) { - AddAppEntryL( appuid, aMmcId ); + AddAppEntryL( aAppUid, aMmcId ); }//if // "removable", "missing" and "visible" flags update for( TInt j = 0; j < resultArray.Count(); j++ ) { - //we need to handle first run of appscanner, - //there might be some incorrect data in content xml file - //if this will have impact on performance we may run this methods only at start up + //We need to handle first run of appscanner, + //there might be some incorrect data. If this will have impact + //on performance we may run this methods only at start up. UpdateAppEntryL( resultArray[j], aMmcId ); TInt index = aCaEntries.Find( resultArray[j], @@ -216,7 +218,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::UpdateAppEntryL +// // --------------------------------------------------------- // void CCaSrvAppScanner::UpdateAppEntryL( CCaInnerEntry* aEntry, TUint aMmcId ) @@ -225,9 +227,9 @@ TBool missingVisibleFlagChanged = HandleMissingVisibleFlagsUpdate( aEntry ); toUpdate = missingVisibleFlagChanged || toUpdate; - toUpdate = HandleLockDeleteFlagUpdateL( aEntry ) || toUpdate; + toUpdate = HandleRemovableVisibleFlagsUpdateL( aEntry ) || toUpdate; toUpdate = SetApaAppInfoL( aEntry ) || toUpdate; - + if( iInstalledPackages.Find( aEntry->GetUid() ) != KErrNotFound ) { AddEntryToDownloadedCollectionL( aEntry->GetId() ); @@ -246,6 +248,142 @@ RemoveFromInstalledPackages( aEntry->GetUid() ); } } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +TBool CCaSrvAppScanner::HandleMmcAttrUpdateL( + CCaInnerEntry* aItem, TUint aMmcId ) + { + TBool toUpdate( ETrue ); + if( IsInMmcL( TUid::Uid( aItem->GetUid() ) ) ) + { + //app is instaled on mmc - KCaAttrMmcId attribute update + RBuf uidString; + uidString.CleanupClosePushL(); + uidString.CreateL(KUidChars); + uidString.Format( KHexFormat, aMmcId ); + aItem->AddAttributeL( KCaAttrMmcId, uidString ); + CleanupStack::PopAndDestroy( &uidString ); + } + else if ( IsInMassStorageL( TUid::Uid( aItem->GetUid() ) ) ) + { + //its app installed on mass storage, we need to leave it + //in case of connecting usb in mass storage mode + aItem->AddAttributeL( KCaAttrMmcId, KCaMassStorage ); + } + else + { + RBuf attrVal; + attrVal.CleanupClosePushL(); + attrVal.CreateL( KCaMaxAttrValueLen ); + if( aItem->FindAttribute( KCaAttrMmcId, attrVal ) ) + { + aItem->RemoveAttributeL( KCaAttrMmcId ); + } + else + { + toUpdate = EFalse; + } + CleanupStack::PopAndDestroy( &attrVal ); + //its installed on c: drive - remove attribute + } + return toUpdate; + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CCaSrvAppScanner::InstallationNotifyL() + { + for( TInt i = iInstalledPackages.Count() - 1; i >= 0; i-- ) + { + NotifyL( iInstalledPackages[i] ); + iInstalledPackages.Remove( i ); + } + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CCaSrvAppScanner::UpdateApplicationEntriesL() + { + TUint currentMmcId = UpdateMmcHistoryL(); + // get all Content arsenal enties with type application + RPointerArray resultArray; + CleanupResetAndDestroyPushL( resultArray ); + GetCaAppEntriesL( resultArray ); + HandleHsAppEntryL( resultArray ); + RemoveSatAppL( resultArray ); + + RArray appUids; + CleanupClosePushL( appUids ); + GetApaItemsL( appUids ); + RemoveApp( appUids, KSatUid.iUid ); + RemoveApp( appUids, KHsAppUid.iUid ); + + //for every item in apaAndCrItems array + for( TInt i = 0; i < appUids.Count(); i++ ) + { + // if there was leave for any item we ignore it + // and proceed to the next one + TRAP_IGNORE(UpdateApplicationEntryL( + resultArray, appUids[i], currentMmcId)); + } + // Here the big list with items that refer to missing apps. + HandleMissingItemsL( resultArray ); + CleanupStack::PopAndDestroy( &appUids ); + CleanupStack::PopAndDestroy( &resultArray ); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +TBool CCaSrvAppScanner::HandleRemovableVisibleFlagsUpdateL( + CCaInnerEntry* aItem ) + { + TBool toChange( EFalse ); + if( ( aItem->GetFlags() & EVisible ) && IsInRomL( aItem->GetUid() ) ) + { + if( ( aItem->GetFlags() & ERemovable ) != 0 ) + { + aItem->SetFlags( aItem->GetFlags() & ~ERemovable ); + toChange = ETrue; + } + } + else + { + if( ( aItem->GetFlags() & ERemovable ) == 0 ) + { + aItem->SetFlags( aItem->GetFlags() | ERemovable ); + toChange = ETrue; + } + } + return toChange; + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +TBool CCaSrvAppScanner::HandleMissingVisibleFlagsUpdate( + CCaInnerEntry* aItem ) + { + TBool ret( EFalse ); + if( aItem->GetFlags() & EMissing || + !( aItem->GetFlags() & EVisible ) ) + { + //application found so we unset "missing" and set "visible" flags + aItem->SetFlags( aItem->GetFlags() & ~EMissing | EVisible ); + ret = ETrue; + } + return ret; + } + // --------------------------------------------------------- // // --------------------------------------------------------- @@ -277,144 +415,12 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::HandleMmcAttrUpdateL -// --------------------------------------------------------- // -TBool CCaSrvAppScanner::HandleMmcAttrUpdateL( - CCaInnerEntry* aItem, TUint aMmcId ) - { - TBool toUpdate( ETrue ); - if( IsInMmcL( TUid::Uid( aItem->GetUid() ) ) ) - { - //app is instaled on mmc - KCaAttrMmcId attribute update - TBuf uidString; - uidString.Format( KHexFormat, aMmcId ); - aItem->AddAttributeL( KCaAttrMmcId, uidString ); - } - else if ( IsInMassStorageL( TUid::Uid( aItem->GetUid() ) ) ) - { - //its app installed on mass storage, we need to leave it - //in case of connecting usb in mass storage mode - aItem->AddAttributeL( KCaAttrMmcId, KCaMassStorage ); - } - else - { - RBuf attrVal; - attrVal.CleanupClosePushL(); - attrVal.CreateL( KCaMaxAttrValueLen ); - if( aItem->FindAttribute( KCaAttrMmcId, attrVal ) ) - { - aItem->RemoveAttributeL( KCaAttrMmcId ); - } - else - { - toUpdate = EFalse; - } - CleanupStack::PopAndDestroy( &attrVal ); - //its installed on c: drive - remove attribute - } - return toUpdate; - } - -// --------------------------------------------------------- -// CCaSrvAppScanner::UpdateApplicationItemsL -// --------------------------------------------------------- -// -void CCaSrvAppScanner::InstallationNotifyL() - { - for( TInt i = iInstalledPackages.Count() - 1; i >= 0; i-- ) - { - NotifyL( iInstalledPackages[i] ); - iInstalledPackages.Remove( i ); - } - } - -// --------------------------------------------------------- -// CCaSrvAppScanner::UpdateApplicationItemsL // --------------------------------------------------------- // -void CCaSrvAppScanner::UpdateApplicationEntriesL() - { - TUint currentMmcId = UpdateMmcHistoryL(); - // get all Content arsenal enties with type application - RPointerArray resultArray; - CleanupResetAndDestroyPushL( resultArray ); - GetCaAppEntriesL( resultArray ); - HandleHsAppEntryL( resultArray ); - RemoveSatAppL( resultArray ); - - RArray apaItems; - CleanupClosePushL( apaItems ); - GetApaItemsL( apaItems ); - RemoveApp( apaItems, KSatUid.iUid ); - RemoveApp( apaItems, KHsAppUid.iUid ); - - //for every item in apaAndCrItems array - for( TInt i = 0; i < apaItems.Count(); i++ ) - { - // if there was leave for any item we ignore it - // and proceed to the next one - TRAP_IGNORE(UpdateApplicationEntryL( - resultArray, apaItems[i], currentMmcId)); - } - // Here the big list cwith items that refer to missing apps. - HandleMissingItemsL( resultArray ); - CleanupStack::PopAndDestroy( &apaItems ); - CleanupStack::PopAndDestroy( &resultArray ); - } - -// --------------------------------------------------------- -// CCaSrvAppScanner::HandleLockDeleteFlagUpdateL -// --------------------------------------------------------- -// -TBool CCaSrvAppScanner::HandleLockDeleteFlagUpdateL( CCaInnerEntry* aItem ) +void CCaSrvAppScanner::RemoveApp( RArray& aArray, TInt32 aUid ) { - TBool toChange( EFalse ); - TBool isVisible = ( ( aItem->GetFlags() & EVisible ) != 0 ); - if( isVisible && IsInRomL( aItem->GetUid() ) ) - { - if( ( aItem->GetFlags() & ERemovable ) != 0 ) - { - aItem->SetFlags( aItem->GetFlags() & ~ERemovable ); - toChange = ETrue; - } - } - else - { - if( ( aItem->GetFlags() & ERemovable ) == 0 ) - { - aItem->SetFlags( aItem->GetFlags() | ERemovable ); - toChange = ETrue; - } - } - return toChange; - } - -// --------------------------------------------------------- -// CCaSrvAppScanner::HandleMissingFlagUpdateL -// --------------------------------------------------------- -// -TBool CCaSrvAppScanner::HandleMissingVisibleFlagsUpdate( CCaInnerEntry* aItem ) - { - TBool ret( EFalse ); - if( aItem->GetFlags() & EMissing || - !( aItem->GetFlags() & EVisible ) ) - { - //application found so we unset "missing" and set "visible" flags - aItem->SetFlags( aItem->GetFlags() & ~EMissing | EVisible ); - ret = ETrue; - } - return ret; - } - -// --------------------------------------------------------- -// CCaSrvAppScanner::RemoveApp -// --------------------------------------------------------- -// -void CCaSrvAppScanner::RemoveApp( RArray& aArray, TInt32 aUid ) - { - TCaAppAtributes app( aUid ); - TInt id = aArray.Find( app, TCaAppAtributes::MatchItems ); + TInt id = aArray.Find( aUid ); if( id != KErrNotFound ) { aArray.Remove( id ); @@ -422,7 +428,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::RemoveSatApp +// // --------------------------------------------------------- // void CCaSrvAppScanner::RemoveSatAppL( RPointerArray& aArray ) @@ -440,10 +446,11 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::HandleHsAppEntryL +// // --------------------------------------------------------- // -void CCaSrvAppScanner::HandleHsAppEntryL( RPointerArray& aArray ) +void CCaSrvAppScanner::HandleHsAppEntryL( + RPointerArray& aArray ) { CCaInnerEntry* appEntry = CCaInnerEntry::NewLC(); appEntry->SetUid( KHsAppUid.iUid ); @@ -476,12 +483,12 @@ // --------------------------------------------------------- -// CCaSrvAppScanner::GetApaItemsL +// // --------------------------------------------------------- // -void CCaSrvAppScanner::GetApaItemsL( RArray& aArray ) +void CCaSrvAppScanner::GetApaItemsL( RArray& aArray ) { - TApaAppInfo* appInfo = new(ELeave) TApaAppInfo(); + TApaAppInfo* appInfo = new ( ELeave ) TApaAppInfo(); CleanupStack::PushL(appInfo); TApaAppCapabilityBuf appCap; @@ -495,22 +502,22 @@ // "Hidden" status according to AppArc. if( !appCap().iAppIsHidden ) { - TCaAppAtributes appAtributes( appInfo->iUid.iUid ); - aArray.AppendL( appAtributes ); + aArray.AppendL( appInfo->iUid.iUid ); } } CleanupStack::PopAndDestroy(appInfo); } // --------------------------------------------------------- -// CCaSrvAppScanner::GetMcsItemsL +// // --------------------------------------------------------- // void CCaSrvAppScanner::GetCaAppEntriesL( RPointerArray& aArray ) { CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC(); - CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 ); + CDesC16ArrayFlat* appType = + new ( ELeave ) CDesC16ArrayFlat( KGranularityOne ); CleanupStack::PushL( appType ); appType->AppendL( KCaTypeApp ); allAppQuery->SetEntryTypeNames( appType ); @@ -520,7 +527,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::GetMcsItemsL +// // --------------------------------------------------------- // TInt CCaSrvAppScanner::GetCollectionDownloadIdL() @@ -530,7 +537,8 @@ RPointerArray resultArray; CleanupResetAndDestroyPushL( resultArray ); CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC(); - CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 ); + CDesC16ArrayFlat* appType = + new ( ELeave ) CDesC16ArrayFlat( KGranularityOne ); CleanupStack::PushL( appType ); appType->AppendL( KCaTypeCollectionDownload ); allAppQuery->SetEntryTypeNames( appType ); @@ -547,7 +555,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::GetAllCollectionIdL +// // --------------------------------------------------------- // TInt CCaSrvAppScanner::GetAllCollectionIdL() @@ -556,7 +564,7 @@ { CCaInnerQuery *getAllCollectionIdQuery = CCaInnerQuery::NewLC(); CDesC16ArrayFlat *typenameArray = new(ELeave) CDesC16ArrayFlat( - KDefaultGranularity ); + KGranularityOne ); CleanupStack::PushL( typenameArray ); typenameArray->AppendL( KCaTypeMenuCollections ); getAllCollectionIdQuery->SetEntryTypeNames( typenameArray ); @@ -577,7 +585,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::GetMcsItemsL +// // --------------------------------------------------------- // void CCaSrvAppScanner::GetCaAppEntriesL( TInt aUid, @@ -590,7 +598,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::HandleAppListEvent +// // --------------------------------------------------------- // void CCaSrvAppScanner::HandleAppListEvent( TInt /*aEvent*/) @@ -604,7 +612,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::HandleInstallNotifyL +// // --------------------------------------------------------- // void CCaSrvAppScanner::HandleInstallNotifyL( TInt aUid ) @@ -614,8 +622,8 @@ CleanupClosePushL( uids ); Swi::RSisRegistrySession iSisRegSession; + CleanupClosePushL( iSisRegSession ); User::LeaveIfError( iSisRegSession.Connect() ); - CleanupClosePushL( iSisRegSession ); // Open sis package entry related to aUid Swi::RSisRegistryEntry packageEntry; @@ -626,7 +634,7 @@ // Get packageEntry's embedded sis' RPointerArray embedded; - CleanupClosePushL( embedded ); + CleanupResetAndDestroyPushL( embedded ); packageEntry.EmbeddedPackagesL( embedded ); if( embedded.Count() ) { @@ -642,7 +650,6 @@ // of changes in apps included in packageEntry NotifyL( packageEntry ); } - embedded.ResetAndDestroy(); CleanupStack::PopAndDestroy( &embedded ); CleanupStack::PopAndDestroy( &packageEntry ); } @@ -651,7 +658,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::NotifyL +// // --------------------------------------------------------- // void CCaSrvAppScanner::NotifyL( Swi::RSisRegistryEntry & aPackageEntry ) @@ -672,7 +679,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::NotifyL +// // --------------------------------------------------------- // void CCaSrvAppScanner::NotifyL( TInt aAppUid ) @@ -682,20 +689,22 @@ CleanupResetAndDestroyPushL( resultArray ); GetCaAppEntriesL( aAppUid, resultArray ); if( resultArray.Count() && ( resultArray[0]->GetFlags() & EVisible ) ) - {//TODO: this only for icons. This functionality should be change + {//TODO: this only for icons. This functionality should be change iCaStorageProxy.AddL( resultArray[0] ); } CleanupStack::PopAndDestroy( &resultArray ); } // --------------------------------------------------------- -// CCaSrvAppScanner::AddEntryToDownloadedCollectionL +// // --------------------------------------------------------- // void CCaSrvAppScanner::AddEntryToDownloadedCollectionL( TInt aEntryId ) { - TCaOperationParams params = { TCaOperationParams::EPrepend, GetCollectionDownloadIdL(), 0 // not used - }; + TCaOperationParams params; + params.iOperationType = TCaOperationParams::EPrepend; + params.iGroupId = GetCollectionDownloadIdL(); + params.iBeforeEntryId = 0; // Not used. RArray entryIds; CleanupClosePushL( entryIds ); @@ -706,7 +715,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::AddEntryToPredefinedCollectionL +// // --------------------------------------------------------- // void CCaSrvAppScanner::AddEntryToPredefinedCollectionL( @@ -731,10 +740,10 @@ RArray entryIds; CleanupClosePushL( entryIds ); - TInt entryId = aEntry->GetId(); - entryIds.AppendL( entryId ); + entryIds.AppendL( aEntry->GetId() ); TCaOperationParams organizeParams; organizeParams.iBeforeEntryId = 0; + organizeParams.iOperationType = TCaOperationParams::EAppend; if( resultArrayItems.Count() ) { @@ -755,14 +764,12 @@ if( aUpdate ) { - organizeParams.iOperationType = TCaOperationParams::EAppend; iCaStorageProxy.OrganizeL( entryIds, organizeParams ); } } if( !aUpdate ) { - organizeParams.iOperationType = TCaOperationParams::EAppend; iCaStorageProxy.OrganizeL( entryIds, organizeParams ); } @@ -773,7 +780,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::CreatePredefinedCollectionL +// // --------------------------------------------------------- // TInt CCaSrvAppScanner::CreatePredefinedCollectionL( const TDesC& aGroupName ) @@ -783,9 +790,7 @@ innerEntry->SetEntryTypeNameL( KCaTypeCollection ); innerEntry->SetRole( CCaInnerQuery::Group ); innerEntry->AddAttributeL( KCaAppGroupName, aGroupName ); - innerEntry->SetFlags( EVisible ); - innerEntry->SetFlags( innerEntry->GetFlags() | ERemovable ); - _LIT( KCollectionIconFileName, "qtg_large_applications_user"); + innerEntry->SetFlags( EVisible | ERemovable ); innerEntry->SetIconDataL( KCollectionIconFileName, KNullDesC, KNullDesC ); iCaStorageProxy.AddL( innerEntry ); @@ -797,7 +802,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::AddCollectionToAllCollectionL +// // --------------------------------------------------------- // void CCaSrvAppScanner::AddCollectionToAllCollectionL( TInt aCollectionId ) @@ -817,13 +822,15 @@ // --------------------------------------------------------- -// CCaSrvAppScanner::RemoveToDownloadedCollectionL +// // --------------------------------------------------------- // void CCaSrvAppScanner::RemoveEntryFromDownloadedL( TInt aEntryId ) { - TCaOperationParams params = { TCaOperationParams::ERemove, GetCollectionDownloadIdL(), 0 // not used - }; + TCaOperationParams params; + params.iOperationType = TCaOperationParams::ERemove; + params.iGroupId = GetCollectionDownloadIdL(); + params.iBeforeEntryId = 0; // Not Used RArray entryIds; CleanupClosePushL( entryIds ); @@ -834,7 +841,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::ScheduleScan +// // --------------------------------------------------------- // void CCaSrvAppScanner::ScheduleScan() @@ -849,7 +856,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::AddAppItemL +// // --------------------------------------------------------- // void CCaSrvAppScanner::AddAppEntryL( TUint aUid, TUint aCurrentMmcId ) @@ -863,7 +870,7 @@ appEntry->SetRole( EItemEntryRole ); SetApaAppInfoL( appEntry ); - HandleLockDeleteFlagUpdateL( appEntry ); + HandleRemovableVisibleFlagsUpdateL( appEntry ); HandleMmcAttrUpdateL( appEntry, aCurrentMmcId ); iCaStorageProxy.AddL( appEntry ); @@ -873,14 +880,14 @@ if( iInstalledPackages.Find( aUid ) != KErrNotFound ) { AddEntryToDownloadedCollectionL( appEntry->GetId() ); + RemoveFromInstalledPackages( aUid ); } - RemoveFromInstalledPackages( aUid ); CleanupStack::PopAndDestroy( appEntry ); } // --------------------------------------------------------- -// CCaSrvAppScanner::RemoveFromInstalledPackages +// // --------------------------------------------------------- // void CCaSrvAppScanner::RemoveFromInstalledPackages( TUint aUid ) @@ -893,58 +900,77 @@ } // --------------------------------------------------------------------------- -// CCaSrvAppScanner::IsMidletL -// Checks if given app is midlet by reading the apptype uid (2nd uid) +// // --------------------------------------------------------------------------- // TBool CCaSrvAppScanner::SetApaAppInfoL( CCaInnerEntry* aEntry ) { TBool changed( EFalse ); - TApaAppInfo info; - if( KErrNone == iSrvEngUtils.GetAppInfo( *aEntry, info ) ) + TApaAppInfo* info = new ( ELeave ) TApaAppInfo(); + CleanupStack::PushL(info); + if( KErrNone == iSrvEngUtils.GetAppInfo( *aEntry, *info ) ) { RBuf attrVal; attrVal.CleanupClosePushL(); attrVal.CreateL( KCaMaxAttrValueLen ); aEntry->FindAttribute( KCaAttrLongName, attrVal ); - if( attrVal.Compare( info.iCaption ) != KErrNone - || aEntry->GetText().Compare( info.iCaption ) + if( attrVal.Compare( info->iCaption ) != KErrNone + || aEntry->GetText().Compare( info->iCaption ) != KErrNone ) { - aEntry->SetTextL( info.iCaption ); - aEntry->AddAttributeL( KCaAttrLongName, info.iCaption ); + aEntry->SetTextL( info->iCaption ); + aEntry->AddAttributeL( KCaAttrLongName, info->iCaption ); changed = ETrue; } + + + if ( UpdateComponentIdL( *info, *aEntry ) ) + { + changed = ETrue; + } + CleanupStack::PopAndDestroy( &attrVal ); - // check if its java app and add attr for entrys + + // check if its java app and add attr for entries TUid appTypeUid; - if( KErrNone == iApaLsSession.GetAppType( appTypeUid, info.iUid ) ) + if( KErrNone == iApaLsSession.GetAppType( appTypeUid, info->iUid ) ) { if( appTypeUid == KMidletApplicationTypeUid ) { - aEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueJava ); - aEntry->AddAttributeL( KCaAttrAppSettingsPlugin, KCaAttrJavaAppSettingsPluginValue ); + aEntry->AddAttributeL( + KCaAttrAppType, + KCaAttrAppTypeValueJava ); + aEntry->AddAttributeL( + KCaAttrAppSettingsPlugin, + KCaAttrJavaAppSettingsPluginValue ); } else if (appTypeUid == KCWRTApplicationTypeUid) { - aEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueCWRT ); - aEntry->AddAttributeL( KCaAttrAppWidgetUri, KCaAttrAppWidgetUriCWRTValue ); + aEntry->AddAttributeL( + KCaAttrAppType, + KCaAttrAppTypeValueCWRT ); + aEntry->AddAttributeL( + KCaAttrAppWidgetUri, + KCaAttrAppWidgetUriCWRTValue ); // web id should be taken from SCR when supported RWidgetRegistryClientSession wrtSession; CleanupClosePushL(wrtSession); User::LeaveIfError( wrtSession.Connect()); TFileName bundleId; - wrtSession.GetWidgetBundleId(info.iUid, bundleId); - aEntry->AddAttributeL( KCaAttrAppWidgetParamWebAppId, bundleId ); + wrtSession.GetWidgetBundleId(info->iUid, bundleId); + aEntry->AddAttributeL( + KCaAttrAppWidgetParamWebAppId, + bundleId ); CleanupStack::PopAndDestroy(&wrtSession); } } } + CleanupStack::PopAndDestroy( info ); return changed; } // --------------------------------------------------------- -// CCaSrvAppScanner::HandleMissingItemsL +// // --------------------------------------------------------- // void CCaSrvAppScanner::HandleMissingItemsL( @@ -952,7 +978,6 @@ { for( TInt i = 0; i < aCaEntries.Count(); i++ ) { - const TInt id = aCaEntries[i]->GetId(); RBuf attrVal; attrVal.CleanupClosePushL(); attrVal.CreateL( KCaMaxAttrValueLen ); @@ -985,7 +1010,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::RemoveAppL +// // --------------------------------------------------------- // void CCaSrvAppScanner::RemoveAppL( CCaInnerEntry* aAppEntry ) @@ -1018,13 +1043,17 @@ { if( aEntry->GetFlags() & EVisible ) { - aEntry->SetFlags( aEntry->GetFlags() & ~EVisible & ~EMissing & ~EUsed ); + aEntry->SetFlags( + aEntry->GetFlags() & + ~EVisible & + ~EMissing & + ~EUsed ); iCaStorageProxy.AddL( aEntry, EFalse, EItemDisappeared ); } } // --------------------------------------------------------- -// CCaSrvAppScanner::UpdateMmcHistoryL +// // --------------------------------------------------------- // TUint CCaSrvAppScanner::UpdateMmcHistoryL() @@ -1039,7 +1068,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::CurrentMmcId +// // --------------------------------------------------------- // TUint CCaSrvAppScanner::CurrentMmcId() const @@ -1047,8 +1076,7 @@ // Get mmc id. Errors are ignored. TUint mmcId = 0; TInt mmcDrive; - TInt err; - err = DriveInfo::GetDefaultDrive( + TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ); if( !err ) { @@ -1063,16 +1091,17 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::IsFileInDrive +// // --------------------------------------------------------- // TBool CCaSrvAppScanner::IsFileInDrive( - const TDesC& aFileName, - const DriveInfo::TDefaultDrives& aDefaultDrive ) const + const TDesC& aFileName, + const DriveInfo::TDefaultDrives& aDefaultDrive ) const + { + TBool retVal( EFalse ); + if ( aFileName.Length()>0 ) { - if ( aFileName.Length() ) - { - TInt mmcDrive; + TInt mmcDrive; TInt err = DriveInfo::GetDefaultDrive( aDefaultDrive, mmcDrive ); if( !err ) { @@ -1080,15 +1109,15 @@ err = RFs::CharToDrive( aFileName[0], fileDrive ); if( !err && fileDrive == mmcDrive ) { - return ETrue; + retVal = ETrue; } } } - return EFalse; + return retVal; } // --------------------------------------------------------- -// CCaSrvAppScanner::IsAppInDriveL +// // --------------------------------------------------------- // TBool CCaSrvAppScanner::IsAppInDriveL( @@ -1096,7 +1125,7 @@ const DriveInfo::TDefaultDrives& aDefaultDrive ) const { TBool ret( EFalse ); - TApaAppInfo* appInfo = new( ELeave ) TApaAppInfo(); + TApaAppInfo* appInfo = new ( ELeave ) TApaAppInfo(); TInt err = iApaLsSession.GetAppInfo( *appInfo, aUid ); if( !err && IsFileInDrive( appInfo->iFullName, aDefaultDrive ) ) { @@ -1107,7 +1136,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::IsInMmcL +// // --------------------------------------------------------- // TBool CCaSrvAppScanner::IsInMmcL( const TUid aUid ) const @@ -1116,7 +1145,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::IsInMassStorageL +// // --------------------------------------------------------- // TBool CCaSrvAppScanner::IsInMassStorageL( const TUid aUid ) const @@ -1125,7 +1154,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::IsInRomL +// // --------------------------------------------------------- // TBool CCaSrvAppScanner::IsInRomL( TInt aUid ) @@ -1134,7 +1163,7 @@ } // --------------------------------------------------------- -// CCaSrvAppScanner::IsDriveInUse +// // --------------------------------------------------------- // TBool CCaSrvAppScanner::IsDriveInUse( @@ -1157,6 +1186,10 @@ return inUse; } +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// void CCaSrvAppScanner::MakeNotEmptyCollectionsVisibleL() { RPointerArray resultArray; @@ -1182,6 +1215,10 @@ CleanupStack::PopAndDestroy( &resultArray ); } +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// void CCaSrvAppScanner::MakeCollectionVisibleIfHasVisibleEntryL( CCaInnerEntry* aEntry ) { @@ -1205,34 +1242,60 @@ CleanupStack::PopAndDestroy( &resultEntriesArray ); } - -// ==================== MEMBER FUNCTIONS ==================== - -// --------------------------------------------------------- -// TAppAtributes::TAppAtributes -// --------------------------------------------------------- -// -TCaAppAtributes::TCaAppAtributes( TUint aUid ) - { - iUid = aUid; - } - -// --------------------------------------------------------- -// TAppAtributes::GetUid // --------------------------------------------------------- // -TUint TCaAppAtributes::GetUid() const +// ---------------------------------------------------------// +TBool CCaSrvAppScanner::UpdateComponentIdL( TApaAppInfo& appInfo, + CCaInnerEntry& aEntry ) const { - return iUid; - } + TBool updated( EFalse ); + + CComponentFilter* const fileNameFilter = CComponentFilter::NewLC(); + + fileNameFilter->SetFileL( appInfo.iFullName ); -// --------------------------------------------------------- -// TAppAtributes::MatchItems -// --------------------------------------------------------- -// -TBool TCaAppAtributes::MatchItems( const TCaAppAtributes& item1, - const TCaAppAtributes& item2 ) + RArray componentIds; + CleanupClosePushL( componentIds ); + iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter ); + + if ( componentIds.Count() == 0 ) { - return item1.GetUid() == item2.GetUid(); + CComponentFilter* const uidFilter = CComponentFilter::NewLC(); + uidFilter->AddPropertyL(_L("Uid"), aEntry.GetUid()); + iSoftwareRegistry.GetComponentIdsL( componentIds, uidFilter ); + CleanupStack::PopAndDestroy( uidFilter ); } + + if ( componentIds.Count() == 1 ) + { + RBuf newComponentId; + newComponentId.CleanupClosePushL(); + newComponentId.CreateL( sizeof(TComponentId) + 1 ); + newComponentId.AppendNum( componentIds[0] ); + + RBuf oldComponentId; + oldComponentId.CleanupClosePushL(); + oldComponentId.CreateL( KCaMaxAttrValueLen ); + + const TBool componentIdAttributeFound = + aEntry.FindAttribute( KCaComponentId, oldComponentId ); + + if ( !componentIdAttributeFound + || oldComponentId.Compare( newComponentId ) != 0 ) + { + // 'add' or 'update' the component id attribute value + aEntry.AddAttributeL( KCaComponentId, + newComponentId ); + + updated = ETrue; + } + + CleanupStack::PopAndDestroy( &oldComponentId ); + CleanupStack::PopAndDestroy( &newComponentId ); + } + CleanupStack::PopAndDestroy( &componentIds ); + CleanupStack::PopAndDestroy( fileNameFilter ); + + return updated; + } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/calocalizerscanner/inc/calocalizerscannerproxy.h --- a/contentstorage/casrv/calocalizerscanner/inc/calocalizerscannerproxy.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/calocalizerscanner/inc/calocalizerscannerproxy.h Thu May 27 13:11:12 2010 +0300 @@ -21,6 +21,7 @@ // INCLUDES #include #include + #include "hbtextresolversymbian.h" #include "castorage_global.h" @@ -36,11 +37,7 @@ */ class CCaLocalizerScannerProxy : public CBase { - - public: - - /** * Two-phased constructor. */ @@ -55,7 +52,11 @@ * Destructor. */ ~CCaLocalizerScannerProxy( ); - + + /** + * Get localization rows and updates database + */ + void UpdateLocalNamesL( ); private: @@ -69,30 +70,39 @@ */ void ConstructL( ); -private: - /** - * Get localization rows and updates database - */ - void UpdateLocalNamesL( ); - /** * Gets localization rows from database as table of CCaLocalizationEntries * @param aLocals pointers to localization entries */ void GetLocalizationRowsL( RPointerArray& aLocals ); + /** + * Gets localized names from translation files + * @param aLocEntry localization entry + * @return localized name + */ + HBufC* GetLocalizedNameLC( const CCaLocalizationEntry* aLocEntry ); + + /** + * Gets entry text from the storage + * @param aEntries array containing entries + * @param aId entry id + * @return entry text + */ const TDesC& GetEntryText( - RPointerArray aEntries, TInt aId ); + const RPointerArray& aEntries, TInt aId ); + +private: + /* * Not own */ CCaStorageProxy* iStorageProxy; /* - * Owned + * Recent translation file name */ - HbTextResolverSymbian* iResolver; - + RBuf iRecentQmFile; }; #endif // CALOCALSCANNERPROXY_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp --- a/contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp Thu May 27 13:11:12 2010 +0300 @@ -67,13 +67,8 @@ // void CCaLocalizerScannerProxy::ConstructL() { - TBuf filenameDsc; - iStorageProxy->DbPropertyL( KCaDbPropQMfile, filenameDsc ); - iResolver = new (ELeave) HbTextResolverSymbian; - iResolver->Init(filenameDsc, KPathLoc); + iRecentQmFile.CreateL( KCaMaxAttrLenght ); UpdateLocalNamesL(); - delete iResolver; - iResolver = NULL; } // --------------------------------------------------------------------------- @@ -95,10 +90,7 @@ // CCaLocalizerScannerProxy::~CCaLocalizerScannerProxy() { - if (iResolver) - { - delete iResolver; - } + iRecentQmFile.Close(); } // --------------------------------------------------------------------------- @@ -126,13 +118,12 @@ CleanupResetAndDestroyPushL( entries ); RArray ids; CleanupClosePushL( ids ); - + //gets all localizations GetLocalizationRowsL( locals ); - TInt locCount = locals.Count(); - for( TInt idx = 0; idx < locCount; idx++ ) + for( TInt i = 0; i < locCount; i++ ) { - ids.Append( locals[idx]->GetRowId() ); + ids.Append( locals[i]->GetRowId() ); } CCaInnerQuery* query = CCaInnerQuery::NewLC(); query->SetIdsL( ids ); @@ -142,19 +133,14 @@ HBufC16* localizedName; for( TInt i = 0; i < locCount; i++ ) { - localizedName = iResolver->LoadLC( locals[i]->GetStringId() ); + localizedName = GetLocalizedNameLC( locals[i] ); + if( localizedName->Compare( GetEntryText( entries, locals[i]->GetRowId() ) ) ) // translation different than text { locals[i]->SetLocalizedStringL( *localizedName ); iStorageProxy->LocalizeEntryL( *( locals[i] ) ); - } - else if( !localizedName->Compare(KNullDesC) ) - // no translation, string id as text - { - locals[i]->SetLocalizedStringL( locals[i]->GetStringId() ); - iStorageProxy->LocalizeEntryL( *( locals[i] ) ); } CleanupStack::PopAndDestroy( localizedName ); } @@ -166,11 +152,29 @@ // --------------------------------------------------------------------------- -// CCaLocalizerScannerProxy::LocalGetEntryById +// +// --------------------------------------------------------------------------- +// +HBufC* CCaLocalizerScannerProxy::GetLocalizedNameLC( + const CCaLocalizationEntry* aLocEntry) + { + if( iRecentQmFile.Compare( aLocEntry->GetQmFilename() ) ) + { + HbTextResolverSymbian::Init( aLocEntry->GetQmFilename(), KPathLoc ); + // keeping last qm filename to avoid another initialization + iRecentQmFile.Close(); + iRecentQmFile.Create( aLocEntry->GetQmFilename().Length() ); + iRecentQmFile.Copy( aLocEntry->GetQmFilename() ); + } + return HbTextResolverSymbian::LoadLC( aLocEntry->GetStringId() ); + } + +// --------------------------------------------------------------------------- +// // --------------------------------------------------------------------------- // const TDesC& CCaLocalizerScannerProxy::GetEntryText( - RPointerArray aEntries, TInt aId ) + const RPointerArray& aEntries, TInt aId ) { TInt entriesCount = aEntries.Count(); for( TInt i=0; i < entriesCount; i++ ) diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/casrvmgr/bwins/casrvmanageru.def --- a/contentstorage/casrv/casrvmgr/bwins/casrvmanageru.def Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/casrvmgr/bwins/casrvmanageru.def Thu May 27 13:11:12 2010 +0300 @@ -1,3 +1,4 @@ EXPORTS ?NewL@CCaSrvManager@@SAPAV1@AAVCCaStorageProxy@@PAVCCaSrvEngUtils@@@Z @ 1 NONAME ; class CCaSrvManager * CCaSrvManager::NewL(class CCaStorageProxy &, class CCaSrvEngUtils *) + ?LoadOperationErrorCodeL@CCaSrvManager@@QAEHXZ @ 2 NONAME ; int CCaSrvManager::LoadOperationErrorCodeL(void) diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/casrvmgr/eabi/casrvmanageru.def --- a/contentstorage/casrv/casrvmgr/eabi/casrvmanageru.def Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/casrvmgr/eabi/casrvmanageru.def Thu May 27 13:11:12 2010 +0300 @@ -1,3 +1,4 @@ EXPORTS _ZN13CCaSrvManager4NewLER15CCaStorageProxyP14CCaSrvEngUtils @ 1 NONAME + _ZN13CCaSrvManager23LoadOperationErrorCodeLEv @ 2 NONAME diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/casrvmgr/inc/casrvmanager.h --- a/contentstorage/casrv/casrvmgr/inc/casrvmanager.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/casrvmgr/inc/casrvmanager.h Thu May 27 13:11:12 2010 +0300 @@ -59,6 +59,12 @@ static CCaSrvManager* NewLC( CCaStorageProxy& aCaStorageProxy, CCaSrvEngUtils* aUtils = NULL ); + /** + * Load operation error code + * @return error code for load plugins operation + */ + IMPORT_C TInt LoadOperationErrorCodeL(); + private: /** @@ -93,6 +99,11 @@ * Reference to the Storage Proxy, Storage Utils. */ TPluginParams* iPluginParams; + + /** + * Error code for load plugins operation + */ + TInt iErrorCode; }; #endif // C_MM_EXTENSION_MANAGER_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/casrvmgr/src/casrvmanager.cpp --- a/contentstorage/casrv/casrvmgr/src/casrvmanager.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/casrvmgr/src/casrvmanager.cpp Thu May 27 13:11:12 2010 +0300 @@ -85,6 +85,15 @@ } // --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CCaSrvManager::LoadOperationErrorCodeL() + { + return iErrorCode; + } + +// --------------------------------------------------------------------------- // CASpaPluginManager::LoadPluginsL // Load plugins implementations // --------------------------------------------------------------------------- @@ -106,7 +115,12 @@ { // Slice off first sub-section in the data section TUid current_plugin = infoArray[i]->ImplementationUid(); - plug = CCaSrvPlugin::NewL( current_plugin, iPluginParams ); + TRAPD(err, plug = CCaSrvPlugin::NewL( current_plugin, iPluginParams )); + if( KErrNone==iErrorCode ) + { + // remember error code only if it wasn't set yet + iErrorCode = err; + } CleanupStack::PushL( plug ); TInt32 key = current_plugin.iUid; iPluginMap.InsertL( key, plug ); @@ -116,4 +130,5 @@ CleanupStack::PopAndDestroy( &infoArray ); } + // End of file diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/causifscanner/inc/causifscanner.h --- a/contentstorage/casrv/causifscanner/inc/causifscanner.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/causifscanner/inc/causifscanner.h Thu May 27 13:11:12 2010 +0300 @@ -19,7 +19,6 @@ #define CAUSIFSCANNER_H #include -#include #include #include @@ -29,6 +28,14 @@ class CCaStorageProxy; class CCaInnerEntry; +class CCaInstallNotifier; +class CCaMmcWatcher; +class TPluginParams; + +namespace Usif + { + class CComponentEntry; + } using namespace Usif; @@ -55,14 +62,8 @@ */ ~CCaUsifScanner(); - /** - * Installs application. - * @param aFileName File name to be installed. - */ - // void InstallL( const TDesC& aFileName ); - public: - // from MCaInstallListener + // From MCaInstallListener. /** * Handle Install/Uninstall Event. @@ -71,6 +72,9 @@ */ void HandleInstallNotifyL( TInt aUid ); +public: + // From MMmcWatcherCallback. + /** * MmcChangeL is called when the MMC is removed or inserted. */ @@ -90,17 +94,6 @@ void ConstructL(); /** - * Copy constructor. - */ - CCaUsifScanner( const CCaUsifScanner & ); - - /** - * Operator "=". Assigns new object. - * - */ - CCaUsifScanner& operator =( const CCaUsifScanner & ); - - /** * Creates AppLib's entry from Usif's entry * @param aEntry Usif entry obtained from Sif database. * @param aCaEntry AppLib entry to be filled from Usif entry. @@ -136,7 +129,7 @@ * @param aEntry Entry data to be checked if exists. * @retval Returns array index if exists, otherwise KErrNotFound. */ - TInt PackageExistL( RPointerArray& aArray, + TInt PackageExists( RPointerArray& aArray, const CComponentEntry* aEntry ); /** diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/causifscanner/src/causifscanner.cpp --- a/contentstorage/casrv/causifscanner/src/causifscanner.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/causifscanner/src/causifscanner.cpp Thu May 27 13:11:12 2010 +0300 @@ -18,9 +18,6 @@ #include #include #include -#include -#include -#include #include "causifscanner.h" #include "cainnerentry.h" @@ -83,12 +80,12 @@ // CCaUsifScanner::~CCaUsifScanner() { + iSoftwareRegistry.Close(); delete iMmcWatcher; - delete iSystemInstallNotifier; + iFs.Close(); + delete iJavaInstallNotifier; delete iUsifUninstallNotifier; - delete iJavaInstallNotifier; - iFs.Close(); - iSoftwareRegistry.Close(); + delete iSystemInstallNotifier; } // --------------------------------------------------------------------------- @@ -198,12 +195,12 @@ CleanupResetAndDestroyPushL( resultUsifArray ); GetUsifPackageEntriesL( resultUsifArray ); - for( TInt idx(0); idx < resultUsifArray.Count(); idx++ ) + for( TInt i(0); i < resultUsifArray.Count(); i++ ) { - if( PackageExistL( entries, resultUsifArray[idx] ) == KErrNotFound ) + if( PackageExists( entries, resultUsifArray[i] ) == KErrNotFound ) { CCaInnerEntry *caEntry = CCaInnerEntry::NewLC(); - CreateCaEntryFromEntryL( resultUsifArray[idx], caEntry ); + CreateCaEntryFromEntryL( resultUsifArray[i], caEntry ); iStorageProxy.AddL( caEntry ); CleanupStack::PopAndDestroy( caEntry ); } @@ -242,7 +239,8 @@ RPointerArray& aArray ) { CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC(); - CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 ); + CDesC16ArrayFlat* appType = + new ( ELeave ) CDesC16ArrayFlat( KGranularityOne ); CleanupStack::PushL( appType ); appType->AppendL( KCaTypePackage ); allAppQuery->SetEntryTypeNames( appType ); @@ -270,8 +268,7 @@ // Iterate over the matching components //The ownership is transferred to the calling client. - CComponentEntry* entry = scrView.NextComponentL(); - while( entry ) + while( CComponentEntry* entry = scrView.NextComponentL() ) { CleanupStack::PushL( entry ); if( iSoftwareRegistry.IsComponentPresentL( entry->ComponentId() ) ) @@ -283,7 +280,6 @@ { CleanupStack::PopAndDestroy( entry ); } - entry = scrView.NextComponentL(); } CleanupStack::PopAndDestroy( &scrView ); CleanupStack::PopAndDestroy( filter ); @@ -293,24 +289,24 @@ // // --------------------------------------------------------------------------- // -TInt CCaUsifScanner::PackageExistL( RPointerArray& aArray, +TInt CCaUsifScanner::PackageExists( RPointerArray& aArray, const CComponentEntry* aEntry ) { - for( TInt idx( 0 ); idx < aArray.Count(); idx++ ) + TInt retVal( KErrNotFound ); + for( TInt i( 0 ); i < aArray.Count(); i++ ) { TBuf compIdDes; - if( aArray[idx]->FindAttribute( KCaAttrComponentId, compIdDes ) ) + if( aArray[i]->FindAttribute( KCaAttrComponentId, compIdDes ) ) { TLex lex( compIdDes ); TUint uint( 0 ); - User::LeaveIfError( lex.Val( uint ) ); - if( aEntry->ComponentId() == uint ) + if( lex.Val( uint ) == KErrNone && aEntry->ComponentId() == uint ) { - return idx; + retVal = i; } } } - return KErrNotFound; + return retVal; } // --------------------------------------------------------------------------- @@ -321,10 +317,10 @@ RPointerArray& aCaArray, const RPointerArray< CComponentEntry>& aUsifArray ) { - for( TInt idx( aCaArray.Count() - 1 ); idx >= 0; idx-- ) + for( TInt i( aCaArray.Count() - 1 ); i >= 0; i-- ) { TBuf compIdDes; - if( aCaArray[idx]->FindAttribute( KCaAttrComponentId, compIdDes ) ) + if( aCaArray[i]->FindAttribute( KCaAttrComponentId, compIdDes ) ) { TLex lex( compIdDes ); TUint uint( 0 ); @@ -335,8 +331,8 @@ if( aUsifArray[k]->ComponentId() == uint && iSoftwareRegistry.IsComponentPresentL( uint ) ) { - delete aCaArray[idx]; - aCaArray.Remove( idx ); + delete aCaArray[i]; + aCaArray.Remove( i ); break; } } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/cawidgetscanner/group/cawidgetscanner.mmp --- a/contentstorage/casrv/cawidgetscanner/group/cawidgetscanner.mmp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/cawidgetscanner/group/cawidgetscanner.mmp Thu May 27 13:11:12 2010 +0300 @@ -52,12 +52,13 @@ LIBRARY euser.lib LIBRARY efsrv.lib -LIBRARY bafl.lib +LIBRARY bafl.lib LIBRARY ecom.lib LIBRARY cautils.lib LIBRARY camenu.lib LIBRARY platformenv.lib LIBRARY charconv.lib LIBRARY xmlengineDOM.lib +LIBRARY scrclient.lib // End of file diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/cawidgetscanner/inc/cawidgetdescription.h --- a/contentstorage/casrv/cawidgetscanner/inc/cawidgetdescription.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/cawidgetscanner/inc/cawidgetdescription.h Thu May 27 13:11:12 2010 +0300 @@ -148,7 +148,7 @@ * @return CA entry id */ TPtrC GetMmcId( ) const; - + /* * Library getter * @return widget library @@ -230,7 +230,18 @@ * @return Service xml filename */ TPtrC GetServiceXml() const; - + + /* + * Set manifest file path name. + * @param aServiceXml Manifest file path name. + */ + void SetManifestFilePathNameL(const TDesC& aManifestFilePathName); + + /* + * Get manifest file path name. + * @return Manifest file path name. + */ + TPtrC GetManifestFilePathName() const; private: /* @@ -321,6 +332,10 @@ * Service fw xml file */ RBuf iServiceXml; + /* + * Manifest file path name. + */ + RBuf iManifestFilePathName; }; typedef RPointerArray RWidgetArray; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/cawidgetscanner/inc/cawidgetstoragehandler.h --- a/contentstorage/casrv/cawidgetscanner/inc/cawidgetstoragehandler.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/cawidgetscanner/inc/cawidgetstoragehandler.h Thu May 27 13:11:12 2010 +0300 @@ -24,8 +24,10 @@ // INCLUDES #include +#include #include "cawidgetdescription.h" #include "castorage_global.h" + // CONSTANTS // FORWARD DECLARATIONS @@ -129,6 +131,16 @@ */ TBool MassStorageNotInUse(); + /** + * Adds or updates component id attribute in entry based on SCR provided data + * @param aPackageUid uid of the package which the widget represented by aEntry + * is delivered with + * @param aEntry widget entry being updated with component id attribute. + */ + void UpdateComponentIdL( const TDesC& aManifestFilePathName, + CCaInnerEntry& aEntry ) const; + + private: // Data @@ -151,8 +163,9 @@ * Indexes updated during last add operation. Own. */ RArray iUpdatedIndexes; + - + Usif::RSoftwareComponentRegistry iSoftwareRegistry; }; #endif // C_WIDGETSTORAGEHANDLER_H diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp --- a/contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp Thu May 27 13:11:12 2010 +0300 @@ -142,6 +142,7 @@ iModificationTime.Close(); iMmcId.Close(); iServiceXml.Close(); + iManifestFilePathName.Close(); } // ---------------------------------------------------------------------------- @@ -551,4 +552,24 @@ { return iServiceXml; } + +/* + * Set manifest file path name + * @param aManifestFilePt + */ +void CCaWidgetDescription::SetManifestFilePathNameL( + const TDesC& aManifestFilePathName ) + { + iManifestFilePathName.Close(); + iManifestFilePathName.CreateL( aManifestFilePathName ); + } + +/* + * Get service fw xml filename + * @return Service xml filename + */ +TPtrC CCaWidgetDescription::GetManifestFilePathName() const + { + return iManifestFilePathName; + } // End of File diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp --- a/contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp Thu May 27 13:11:12 2010 +0300 @@ -230,7 +230,7 @@ iWidgetDescriptor = CCaWidgetDescription::NewL(); iWidgetDescriptor->SetPackageUidL(aPackageUid); iWidgetDescriptor->SetVisible(ETrue); - + iWidgetDescriptor->SetManifestFilePathNameL( aFilePath ); SetMmcIdL( iWidgetDescriptor ); @@ -323,6 +323,7 @@ SetVisibilityL( aElement, widget ); SetIconUriL( aElement, aPackageUid, widget); widget->SetPackageUidL( aPackageUid ); + widget->SetManifestFilePathNameL( aFilePath ); SetMmcIdL( widget ); TTime modificationTime; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp --- a/contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp Thu May 27 13:11:12 2010 +0300 @@ -17,6 +17,7 @@ // INCLUDE FILES #include +#include #include "widgetscannerutils.h" #include "cawidgetstoragehandler.h" #include "cadef.h" @@ -25,6 +26,8 @@ #include "castorageproxy.h" #include "caarraycleanup.inl" +using namespace Usif; + // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- @@ -47,6 +50,7 @@ // void CCaWidgetStorageHandler::ConstructL() { + User::LeaveIfError( iSoftwareRegistry.Connect() ); } // ----------------------------------------------------------------------------- @@ -83,6 +87,7 @@ // CCaWidgetStorageHandler::~CCaWidgetStorageHandler() { + iSoftwareRegistry.Close(); iWidgets.ResetAndDestroy(); iUpdatedIndexes.Close(); } @@ -105,6 +110,7 @@ void CCaWidgetStorageHandler::AddL( const CCaWidgetDescription* aWidget ) { CCaInnerEntry* entry = aWidget->GetEntryLC(); + UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry ); iStorage->AddL( entry ); if( entry->GetFlags() & ERemovable ) { @@ -121,6 +127,7 @@ TUint aEntryId ) { CCaInnerEntry* entry = aWidget->GetEntryLC(); + UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry ); entry->SetId( aEntryId ); if( !aWidget->IsMissing() && aWidget->IsUsed() ) { @@ -331,4 +338,52 @@ return massStorageNotInUse; } +// ---------------------------------------------------------------------------- +// +// ---------------------------------------------------------------------------- +// + +void CCaWidgetStorageHandler::UpdateComponentIdL( + const TDesC& aManifestFilePathName, + CCaInnerEntry& aEntry ) const + { + RArray componentIds; + CleanupClosePushL( componentIds ); + + CComponentFilter* const fileNameFilter = CComponentFilter::NewLC(); + fileNameFilter->SetFileL( aManifestFilePathName ); + iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter ); + + CleanupStack::PopAndDestroy( fileNameFilter ); + + if ( componentIds.Count() == 1 ) + { + RBuf newComponentId; + newComponentId.CleanupClosePushL(); + newComponentId.CreateL( sizeof(TComponentId) + 1 ); + newComponentId.AppendNum( componentIds[0] ); + + RBuf oldComponentId; + oldComponentId.CleanupClosePushL(); + oldComponentId.CreateL( KCaMaxAttrValueLen ); + + const TBool componentIdAttributeFound = + aEntry.FindAttribute( KCaComponentId, oldComponentId ); + + if ( !componentIdAttributeFound + || oldComponentId.Compare( newComponentId ) != 0 ) + { + // 'add' or 'update' the component id attribute value + aEntry.AddAttributeL( KCaComponentId, + newComponentId ); + } + + CleanupStack::PopAndDestroy( &oldComponentId ); + CleanupStack::PopAndDestroy( &newComponentId ); + } + + CleanupStack::PopAndDestroy( &componentIds ); + } + + // End of File diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/conf/castoragedb.confml --- a/contentstorage/castorage/conf/castoragedb.confml Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/conf/castoragedb.confml Thu May 27 13:11:12 2010 +0300 @@ -1,56 +1,76 @@  - - + + - - - - - + + Collection name. It is only identifier. Localized name should be used too. + + + Group name. Identify collection where application with predefined group name should be added after installation. Should be the same as not localized name. + + + Lock operator collection and content - user can not delete operator collection, prevent renaming collection and even content. Not possible by user to add new content to locked collection + + + + + Localized Collection name. Localized names are taken from contentstorage_*.ts file( for example contentstorage_en_GB.ts ). If text hasn't been found in ts file this one wouldn't be translated. Leave empty field if collection name sholdn't be localized. + + + Collection Icon filename. Optional. + + + Collection Icon skin id. Optional. + - + + Type of entry. Must. - + + + + Name. In case of applications and homescreen widgets this is only information field( Names are taken from system ). + + + Application uid. Uid of application in decimal format. Must for application type. + - - - + + Url. Must for url type. + + + + HS Widget Uri. Must for hs widget type. + + + Icon filename. Optional. + + + Icon skin id. Optional. + + Collection where entry will be added. - + - FavoritesFavorites4qtg_large_applications_user - OfficeOffice4txt_applib_dblist_officeqtg_large_applications_user - MultimediaMultimedia4qtg_large_applications_user - UtilsUtils4qtg_large_applications_user - GamesGames4txt_applib_dblist_gamesqtg_large_applications_user - applicationcalendar268458241 - applicationCamera270501242 - applicationContacts537014009 - applicationEmail537023930 - applicationFM Radio270530934 - applicationInternet222222222 - applicationMaps222222222 - applicationMessaging537001593 - applicationMusic270564450 - applicationPhotos (camera)536913858 - applicationSettings268458220 - applicationVideos (video camera)222222222 - applicationcalendar268458241 - applicationPhonebook537014009 - applicationThemes268458546 - applicationPaint Cursor537001564 - applicationVideoplayer537006590 - applicationControlPanel537026521 - applicationBluetooth268458321 - applicationSW update537001519 - applicationeshell270498535 - applicationConn. mgr.270501072 + FavoritesFavorites4qtg_large_applications_user + applicationcalendar268458241 + applicationCamera270501242 + applicationContacts537014009 + applicationEmail537023930 + applicationFM Radio270530934 + applicationInternet222222222 + applicationMaps222222222 + applicationMessaging537001593 + applicationMusic270564450 + applicationPhotos (camera)536913858 + applicationSettings268458220 + applicationVideos (video camera)222222222 diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/conf/castoragedb_templates/castoragedb_variant.sql --- a/contentstorage/castorage/conf/castoragedb_templates/castoragedb_variant.sql Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/conf/castoragedb_templates/castoragedb_variant.sql Thu May 27 13:11:12 2010 +0300 @@ -6,24 +6,28 @@ {%- set GroupName = feat_tree.CaStorageDbSetting.Collections.GroupName._value[col] or '' -%} {%- set Flags = feat_tree.CaStorageDbSetting.Collections.Flags._value[col] or '' -%} {%- set LocName = feat_tree.CaStorageDbSetting.Collections.LocName._value[col] or ''-%} - {%- set Icon = feat_tree.CaStorageDbSetting.Collections.Icon._value[col] or '' -%} -INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, FLAGS {% if LocName -%}, COL_LOCNAME{%- endif %}{% if Icon -%}, ICON{%- endif %}) -VALUES ( '{{Name}}', '{{GroupName}}', {{Flags}} {% if LocName -%}, "{{LocName}}"{%- endif %}{% if Icon -%}, "{{Icon}}"{%- endif %}); + {%- set IconFileName = feat_tree.CaStorageDbSetting.Collections.IconFileName._value[col] or '' -%} + {%- set IconSkinId = feat_tree.CaStorageDbSetting.Collections.IconSkinId._value[col] or '' -%} +INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, FLAGS {% if LocName -%}, COL_LOCNAME{%- endif %}{% if IconFileName -%}, ICON_FILENAME{%- endif %}{% if IconSkinId -%}, ICON_SKIN_ID{%- endif %}) +VALUES ( '{{Name}}', '{{GroupName}}', {{Flags}} {% if LocName -%}, "{{LocName}}"{%- endif %}{% if IconFileName -%}, "{{IconFileName}}"{%- endif %}{% if IconSkinId -%}, "{{IconSkinId}}"{%- endif %}); {% endfor %} {% for index in range(feat_tree.CaStorageDbSetting.Items._value|length) -%} {%- set Type = feat_tree.CaStorageDbSetting.Items.Type._value[index] or '' -%} {%- set Name = feat_tree.CaStorageDbSetting.Items.Name._value[index] or '' -%} - {%- set Icon = feat_tree.CaStorageDbSetting.Items.Icon._value[index] or '' -%} - {%- set Destination = feat_tree.CaStorageDbSetting.Items.Destination._value[index] or '' -%} + {%- set IconFileName = feat_tree.CaStorageDbSetting.Items.IconFileName._value[index] or '' -%} + {%- set IconSkinId = feat_tree.CaStorageDbSetting.Items.IconSkinId._value[index] or '' -%} + {%- set DestinationUid = feat_tree.CaStorageDbSetting.Items.DestinationUid._value[index] or '' -%} + {%- set DestinationUrl = feat_tree.CaStorageDbSetting.Items.DestinationUrl._value[index] or '' -%} + {%- set DestinationWidgetUri = feat_tree.CaStorageDbSetting.Items.DestinationWidgetUri._value[index] or '' -%} {%- set Collection = feat_tree.CaStorageDbSetting.Items.Col_Name._value[index] or '' -%} -{% if Type == "application" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("{{Type}}", '{{Name}}', {{Destination}}, '{{Collection}}' );{%- endif %} -{% if Type == "url" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, ICON, COLLECTION_NAME) - VALUES ("{{Type}}", '{{Name}}', "{{Destination}}", "{{Icon}}", '{{Collection}}' ); {%- endif %} -{% if Type == "widget" -%} INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON, URI, COLLECTION_NAME ) - VALUES ("{{Type}}", '{{Name}}', "{{Icon}}", "{{Destination}}", '{{Collection}}' ); {%- endif %} +{% if Type == "application" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("{{Type}}", '{{Name}}', {{DestinationUid}}, '{{Collection}}' );{%- endif %} +{% if Type == "url" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, ICON_FILENAME, ICON_SKIN_ID, COLLECTION_NAME) + VALUES ("{{Type}}", '{{Name}}', "{{DestinationUrl}}", "{{IconFileName}}", "{{IconSkinId}}", '{{Collection}}' ); {%- endif %} +{% if Type == "widget" -%} INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON_FILENAME, ICON_SKIN_ID, URI, COLLECTION_NAME ) + VALUES ("{{Type}}", '{{Name}}', "{{IconFileName}}", "{{IconSkinId}}", "{{DestinationWidgetUri}}", '{{Collection}}' ); {%- endif %} {% endfor %} SELECT "castoragedb_variant - END" AS " "; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/data/castorage.db Binary file contentstorage/castorage/data/castorage.db has changed diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/data/castoragedb_create.sql --- a/contentstorage/castorage/data/castoragedb_create.sql Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/data/castoragedb_create.sql Thu May 27 13:11:12 2010 +0300 @@ -45,7 +45,7 @@ CREATE TABLE CA_ICON( ICON_ID INTEGER PRIMARY KEY , IC_FILENAME TEXT, IC_SKIN_ID TEXT, - IC_APP_ID TEXT, + IC_APP_ID TEXT, UNIQUE( IC_FILENAME, IC_SKIN_ID, IC_APP_ID ) ); SELECT "CREATE TABLE CA_LAUNCH" AS " "; @@ -71,6 +71,7 @@ LT_TABLE_NAME TEXT , LT_ATTRIBUTE_NAME TEXT , LT_STRING_ID TEXT , + LT_QMFILENAME TEXT, LT_ROW_ID INTEGER ); SELECT "CREATE TABLE CA_DB_PROPERTIES" AS " "; @@ -80,6 +81,15 @@ DB_VALUE TEXT ); +SELECT "INSERT INITIAL DATA TO CA_DB_PROPERTIES" AS " "; + +SELECT "------------------------------------" AS " "; +INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) +VALUES ( 'Version', '00001' ); +INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) +VALUES ( 'Language', '' ); +INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) +VALUES ( 'QMfile', 'contentstorage_' ); -- CREATE VIEW COLLECTION SELECT "------------------------------------" AS " "; @@ -90,24 +100,27 @@ "" AS "COLLECTION_NAME", "" AS "COL_LOCNAME", "" AS "COL_APP_GROUP_NAME", - "" AS "ICON", + "" AS "ICON_FILENAME", + "" AS "ICON_SKIN_ID", "" AS "FLAGS"; SELECT " CREATE TRIGGER collection_insert" AS " "; CREATE TRIGGER collection_insert INSTEAD OF INSERT ON COLLECTION BEGIN -- INSERT ICON - INSERT INTO CA_ICON (IC_FILENAME) - VALUES ( new.ICON); + INSERT INTO CA_ICON (IC_FILENAME, IC_SKIN_ID) + VALUES ( new.ICON_FILENAME, new.ICON_SKIN_ID); -- DELETE IF ICON IS NULL OR IF IT IS DUPLICATE DELETE FROM CA_ICON WHERE ICON_ID = last_insert_rowid() AND - (IC_FILENAME IS NULL OR (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON AND ICON_ID <> last_insert_rowid()) IS NOT NULL); + ( (IC_FILENAME IS NULL AND IC_SKIN_ID IS NULL) OR + (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON_FILENAME AND ICON_ID <> last_insert_rowid()) IS NOT NULL OR + (SELECT ICON_ID FROM CA_ICON WHERE IC_SKIN_ID = new.ICON_SKIN_ID AND ICON_ID <> last_insert_rowid()) IS NOT NULL); -- INSERT ENTRY INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_FLAGS, EN_ICON_ID ) - VALUES ( new.COLLECTION_NAME , 2, "collection", new.FLAGS, (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON )); + VALUES ( new.COLLECTION_NAME , 2, "collection", new.FLAGS, (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON_FILENAME OR IC_SKIN_ID = new.ICON_SKIN_ID )); -- LOCALIZATION - INSERT INTO CA_LOCALIZATION_TEXT ( LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_ROW_ID ) - VALUES ( 'CA_ENTRY', 'EN_TEXT', new.COL_LOCNAME, ( SELECT last_insert_rowid() ) ); + INSERT INTO CA_LOCALIZATION_TEXT ( LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_QMFILENAME, LT_ROW_ID ) + VALUES ( 'CA_ENTRY', 'EN_TEXT', new.COL_LOCNAME, ( SELECT DB_VALUE FROM CA_DB_PROPERTIES WHERE DB_PROPERTY = "QMfile" ), ( SELECT last_insert_rowid() ) ); DELETE FROM CA_LOCALIZATION_TEXT WHERE LT_STRING_ID IS NULL AND LOC_TEXT_ID = last_insert_rowid() ; -- RELATION TO MAIN COLLECTION (ADD TO GROUP: ) INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION) @@ -127,7 +140,8 @@ AS SELECT "" AS "ITEM_TYPE", "" AS "ITEM_NAME", - "" AS "ICON", + "" AS "ICON_FILENAME", + "" AS "ICON_SKIN_ID", "" AS "ITEM_DEST", "" AS "COLLECTION_NAME"; @@ -140,7 +154,7 @@ -- RELATION TO MAIN COLLECTION (ADD TO GROUP: ) INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION) VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME) , - (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME), + (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_UID = new.ITEM_DEST), (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME)) ); END; @@ -148,19 +162,21 @@ CREATE TRIGGER item_to_collection_insert_url INSTEAD OF INSERT ON ITEM_TO_COLLECTION WHEN new.ITEM_TYPE="url" BEGIN -- INSERT ICON - INSERT OR IGNORE INTO CA_ICON (IC_FILENAME) - VALUES ( new.ICON); + INSERT OR IGNORE INTO CA_ICON (IC_FILENAME, IC_SKIN_ID) + VALUES ( new.ICON_FILENAME, new.ICON_SKIN_ID); DELETE FROM CA_ICON WHERE ICON_ID = last_insert_rowid() AND - (IC_FILENAME IS NULL OR (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON AND ICON_ID <> last_insert_rowid()) IS NOT NULL); + ( (IC_FILENAME IS NULL AND IC_SKIN_ID IS NULL) OR + (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON_FILENAME AND ICON_ID <> last_insert_rowid()) IS NOT NULL OR + (SELECT ICON_ID FROM CA_ICON WHERE IC_SKIN_ID = new.ICON_SKIN_ID AND ICON_ID <> last_insert_rowid()) IS NOT NULL); -- INSERT ENTRY INSERT OR IGNORE INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID ) - VALUES ( new.ITEM_NAME, 1, "url", (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON )); + VALUES ( new.ITEM_NAME, 1, "url", (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON_FILENAME OR IC_SKIN_ID = new.ICON_SKIN_ID )); INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE ) VALUES ( ( SELECT last_insert_rowid() ) ,"url",new.ITEM_DEST); -- RELATION TO MAIN COLLECTION (ADD TO GROUP: ) INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION) VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME) , - (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME), + (SELECT ENTRY_ID FROM CA_ENTRY WHERE (EN_TEXT = new.ITEM_NAME AND EN_TYPE_NAME = new.ITEM_TYPE )), (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME)) ); END; @@ -173,7 +189,8 @@ AS SELECT "" AS "ITEM_TYPE", "" AS "ITEM_NAME", - "" AS "ICON", + "" AS "ICON_FILENAME", + "" AS "ICON_SKIN_ID", "" AS "PACKAGE_UID", "" AS "LIBRARY", "" AS "LONG_NAME", @@ -184,13 +201,15 @@ CREATE TRIGGER item_to_collection_insert_widget INSTEAD OF INSERT ON WIDGET_TO_COLLECTION WHEN new.ITEM_TYPE="widget" BEGIN -- INSERT ICON - INSERT OR IGNORE INTO CA_ICON (IC_FILENAME) - VALUES ( new.ICON); + INSERT OR IGNORE INTO CA_ICON (IC_FILENAME, IC_SKIN_ID) + VALUES ( new.ICON_FILENAME, new.ICON_SKIN_ID); DELETE FROM CA_ICON WHERE ICON_ID = last_insert_rowid() AND - (IC_FILENAME IS NULL OR (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON AND ICON_ID <> last_insert_rowid()) IS NOT NULL); + ( (IC_FILENAME IS NULL AND IC_SKIN_ID IS NULL) OR + (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON_FILENAME AND ICON_ID <> last_insert_rowid()) IS NOT NULL OR + (SELECT ICON_ID FROM CA_ICON WHERE IC_SKIN_ID = new.ICON_SKIN_ID AND ICON_ID <> last_insert_rowid()) IS NOT NULL); -- INSERT ENTRY INSERT OR IGNORE INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID ) - VALUES ( new.ITEM_NAME, 1, "widget", (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON )); + VALUES ( new.ITEM_NAME, 1, "widget", (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON_FILENAME OR IC_SKIN_ID = new.ICON_SKIN_ID )); -- INSERT ATTRIBUTES INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE ) VALUES ( ( SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME ) ,"packageuid",new.PACKAGE_UID); @@ -203,19 +222,11 @@ -- RELATION TO MAIN COLLECTION (ADD TO GROUP: ) INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION) VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME) , - (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME), + (SELECT ENTRY_ID FROM CA_ENTRY WHERE (EN_TEXT = new.ITEM_NAME AND EN_TYPE_NAME = new.ITEM_TYPE)), (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME)) ); END; -SELECT "INSERT INITIAL DATA TO CA_DB_PROPERTIES" AS " "; -SELECT "------------------------------------" AS " "; -INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) -VALUES ( 'Version', '00001' ); -INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) -VALUES ( 'Language', '' ); -INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) -VALUES ( 'QMfile', 'contentstorage_' ); -- insert neccessary items SELECT "INSERT menucollections ENTRY" AS " "; @@ -236,8 +247,8 @@ INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE ) VALUES ( last_insert_rowid(), "appgroup_name", " Downloaded" ); -INSERT INTO CA_LOCALIZATION_TEXT ( LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_ROW_ID ) -VALUES ( 'CA_ENTRY', 'EN_TEXT', "txt_applib_dblist_downloaded", ( SELECT last_insert_rowid() ) ); +INSERT INTO CA_LOCALIZATION_TEXT ( LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_QMFILENAME, LT_ROW_ID ) +VALUES ( 'CA_ENTRY', 'EN_TEXT', "txt_applib_dblist_downloaded",( SELECT DB_VALUE FROM CA_DB_PROPERTIES WHERE DB_PROPERTY = "QMfile" ), ( SELECT last_insert_rowid() ) ); INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION) VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TYPE_NAME = "menucollections") , diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/data/castoragedb_variant.sql --- a/contentstorage/castorage/data/castoragedb_variant.sql Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/data/castoragedb_variant.sql Thu May 27 13:11:12 2010 +0300 @@ -4,33 +4,32 @@ -- insert additional items -INSERT INTO COLLECTION (COLLECTION_NAME, COL_LOCNAME, COL_APP_GROUP_NAME ,ICON, FLAGS) VALUES ( 'Office', "txt_applib_dblist_office", 'Office', "qtg_large_applications_user", 4 ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'calendar', 268458241, 'Office' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'Phonebook', 537014009, 'Office' ); - -INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME ,ICON, FLAGS) VALUES ( 'Multimedia', 'Multimedia' , "qtg_large_applications_user", 4 ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'Themes', 268458546, 'Multimedia' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'Paint Cursor', 537001564, 'Multimedia' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'Videoplayer', 537006590, 'Multimedia' ); +INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, ICON_FILENAME, FLAGS) VALUES ( 'Favorites', 'Favorites', "qtg_large_applications_user", 4 ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'calendar', 268458241, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Camera', 270501242, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Contacts', 537014009, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Email', 537023930, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'FM Radio', 270530934, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Internet', 222222222, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Maps', 222222222, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Messaging', 537001593, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Music', 270564450, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Photos (camera)', 536913858, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Settings', 268458220, 'Favorites' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) + VALUES ("application", 'Videos (video camera)', 222222222, 'Favorites' ); -INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME ,ICON, FLAGS) VALUES ( 'Utils', 'Utils', "qtg_large_applications_user", 4 ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'ControlPanel', 537026521, 'Utils' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'Bluetooth', 268458321, 'Utils' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'SW update', 537001519, 'Utils' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'eshell', 270498535, 'Utils' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME) - VALUES ("application", 'Conn. mgr.', 270501072, 'Utils' ); - -INSERT INTO COLLECTION (COLLECTION_NAME, COL_LOCNAME, COL_APP_GROUP_NAME ,ICON) VALUES ( 'Games', "txt_applib_dblist_games", 'Games',"qtg_large_applications_user", 4 ); SELECT "castoragedb_variant - END" AS " "; SELECT "------------------------------------" AS " "; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/data/castoragedb_variant_test.bat --- a/contentstorage/castorage/data/castoragedb_variant_test.bat Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/data/castoragedb_variant_test.bat Thu May 27 13:11:12 2010 +0300 @@ -18,4 +18,5 @@ del castorage.db sqlite3 castorage.db ".read castoragedb_create.sql" sqlite3 castorage.db ".genfkey --exec" +sqlite3 castorage.db ".read castoragedb_variant.sql" sqlite3 castorage.db ".read castoragedb_variant_test.sql" diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/data/castoragedb_variant_test.sql --- a/contentstorage/castorage/data/castoragedb_variant_test.sql Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/data/castoragedb_variant_test.sql Thu May 27 13:11:12 2010 +0300 @@ -1,21 +1,22 @@ -- ONLY IF YOU SURE THAT WANT DEFAULT CONTENT -.read castoragedb_variant.sql + -SELECT "castoragedb_variant test - BEGIN" AS " "; +SELECT "castoragedb_variant_test - BEGIN" AS " "; -- insert collection -INSERT INTO COLLECTION (COLLECTION_NAME, ICON) VALUES ( 'Test Apps', "qtg_large_applications_user" ); +INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, ICON_FILENAME, FLAGS) VALUES ( 'Test Apps', 'Test Apps', "qtg_large_applications_user", 4 ); -- insert example urls - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON, ITEM_DEST, COLLECTION_NAME) + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON_FILENAME, ITEM_DEST, COLLECTION_NAME) VALUES ("url", 'Facebook', 'c:\data\Images\kqticaicons\facebook.png', "http://www.facebook.com/", 'Test Apps' ); - INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON,ITEM_DEST, COLLECTION_NAME) - VALUES ("url", 'Google', 'c:\data\Images\kqticaicons\google.png', "http://www.google.com/", 'Test Apps' ); + INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON_FILENAME, ITEM_DEST, COLLECTION_NAME, ICON_SKIN_ID) + VALUES ("url", 'Google', 'c:\data\Images\kqticaicons\google.png', "http://www.google.com/", 'Test Apps', '4' ); -- insert example widgets - INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME,ICON, PACKAGE_UID, LIBRARY, LONG_NAME, URI, COLLECTION_NAME) - VALUES ("widget", 'Clock', 'Z:\private\20022F35\import\widgetregistry\20022F6C\tclock.png', '20022f6c', 'Z:\private\20022F35\import\widgetregistry\20022F6C\hsclockwidgetplugin', 'Clock', 'hsclockwidgetplugin', 'Test Apps' ); + INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON_FILENAME, ICON_SKIN_ID, PACKAGE_UID, LIBRARY, LONG_NAME, URI, COLLECTION_NAME) + VALUES ("widget", 'Clock', 'Z:\private\20022F35\import\widgetregistry\20022F6C\tclock.png', '4' , '20022f6c', 'Z:\private\20022F35\import\widgetregistry\20022F6C\hsclockwidgetplugin', 'Clock', 'hsclockwidgetplugin', 'Test Apps' ); -SELECT "castoragedb_variant test - END" AS " "; \ No newline at end of file +SELECT "castoragedb_variant_test - END" AS " "; + diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/inc/casqlcommands.h --- a/contentstorage/castorage/inc/casqlcommands.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/inc/casqlcommands.h Thu May 27 13:11:12 2010 +0300 @@ -60,6 +60,9 @@ (AT_ENTRY_ID, AT_NAME,AT_VALUE) \ VALUES ( :AT_ENTRY_ID, :AT_NAME, :AT_VALUE )" ); +_LIT( KSQLAddLocalization, "INSERT INTO CA_LOCALIZATION_TEXT \ +(LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_QMFILENAME, LT_ROW_ID) \ +VALUES ( :LT_TABLE, :LT_ATTRIBUTE, :LT_STRING, :LT_QMFILENAME, :LT_ROW_ID )" ); //update Data _LIT( KSQLUpdateEntry, "UPDATE CA_ENTRY SET " ); @@ -107,6 +110,12 @@ _LIT( KSQLUpdateProperty, "UPDATE CA_DB_PROPERTIES \ SET DB_VALUE = :DB_VALUE WHERE DB_PROPERTY = :DB_PROPERTY "); +// Update localization table entry + +_LIT( KSQLUpdateLocalization, "UPDATE CA_LOCALIZATION_TEXT SET \ + LT_STRING_ID = :LT_STRING , LT_QMFILENAME = :LT_QMFILENAME \ + WHERE LT_TABLE_NAME = :LT_TABLE AND LT_ATTRIBUTE_NAME = :LT_ATTRIBUTE \ + AND LT_ROW_ID = :LT_ROW_ID" ); //Delete Data _LIT( KSQLDeleteLaunch, "DELETE FROM CA_LAUNCH \ @@ -128,13 +137,17 @@ //Get Data +_LIT( KSQLGetLocalizations, "SELECT LOC_TEXT_ID, LT_TABLE_NAME, \ +LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_QMFILENAME, LT_ROW_ID \ +FROM CA_LOCALIZATION_TEXT ORDER BY LT_QMFILENAME" ); + +_LIT( KSQLGetLocalization, "SELECT LOC_TEXT_ID, LT_TABLE_NAME, \ +LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_QMFILENAME, LT_ROW_ID \ +FROM CA_LOCALIZATION_TEXT WHERE LT_TABLE_NAME = :LT_TABLE \ +AND LT_ATTRIBUTE_NAME = :LT_ATTRIBUTE AND LT_ROW_ID = :LT_ROW_ID" ); + //Get all entries from group by Parent_Id // %S string of where for flags; - -_LIT( KSQLGetLocalizations, "SELECT LOC_TEXT_ID, LT_TABLE_NAME, \ -LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_ROW_ID \ -FROM CA_LOCALIZATION_TEXT" ); - _LIT( KSQLGetListByEntryIds, "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, \ EN_ROLE, EN_TYPE_NAME, EN_ICON_ID, EN_CREATION_TIME, EN_UID, EN_FLAGS, \ IC_FILENAME,IC_SKIN_ID,IC_APP_ID \ @@ -312,6 +325,7 @@ _LIT( KSQLLocTable, ":LT_TABLE" ); _LIT( KSQLLocAttribute, ":LT_ATTRIBUTE" ); _LIT( KSQLLocString, ":LT_STRING" ); +_LIT( KSQLLocQmFilename, ":LT_QMFILENAME" ); _LIT( KSQLLocRowId, ":LT_ROW_ID" ); // columns @@ -348,6 +362,8 @@ _LIT( KColumnLocTableName, "LT_TABLE_NAME" ); _LIT( KColumnLocAttrName, "LT_ATTRIBUTE_NAME" ); _LIT( KColumnLocStringId, "LT_STRING_ID" ); +_LIT( KColumnQmFile, "LT_QMFILENAME" ); + _LIT( KColumnLocRowId, "LT_ROW_ID" ); _LIT( KColumnDbProperty, "DB_PROPERTY" ); diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/inc/casqlitestorage.h --- a/contentstorage/castorage/inc/casqlitestorage.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/inc/casqlitestorage.h Thu May 27 13:11:12 2010 +0300 @@ -75,6 +75,29 @@ void LocalizeEntryL( CCaLocalizationEntry& aLocalization ); /** + * Adds or updates localization row in the localization table + * + * @param aLocalization localization information about entry. + */ + void AddLocalizationL( const CCaLocalizationEntry& aLocalization ); + + /** + * Checks if entry already exists in localization table + * + * @param aLocalization localization information about entry. + */ + TBool LocalizationEntryPresentL(const CCaLocalizationEntry& aLocalization); + + /** + * Updates localization row in the localization table + * + * @param aLocalization localization information about entry. + * @param aStatement SQL statement + */ + void ExecuteLocalizationStatementL(const CCaLocalizationEntry& aLocalization, + const TDesC& aStatement); + + /** * Fetches data from database. * * @param aMap Filtering and sorting criteria diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/inc/casqlquery.h --- a/contentstorage/castorage/inc/casqlquery.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/inc/casqlquery.h Thu May 27 13:11:12 2010 +0300 @@ -141,6 +141,22 @@ void BindValuesForAddL( const CCaInnerEntry* aEntry ); /** + * Binds values for an get localization entry + * + * @param aLocalization The entry from which to get data for bindings. + */ + void BindValuesForGetLocalizationEntryL( + const CCaLocalizationEntry& aLocalization); + + /** + * Binds values for an add and update localization entry + * + * @param aLocalization The entry from which to get data for bindings. + */ + void BindValuesForLocalizationEntryL( + const CCaLocalizationEntry& aLocalization); + + /** * Binds values for an add operation. * * @param aQuery The query from which to get data for bindings. @@ -271,6 +287,13 @@ /** * Executes a statement. * + * @return ETrue if any data was found + */ + TBool ExecuteEntryPresentL( ); + + /** + * Executes a statement. + * * @param[out] aId id of single data the query statement queries for. * @return Entry count. */ diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/inc/casqlquerycreator.h --- a/contentstorage/castorage/inc/casqlquerycreator.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/inc/casqlquerycreator.h Thu May 27 13:11:12 2010 +0300 @@ -24,6 +24,7 @@ // CLASS DECLARATION +class CCaLocalizationEntry; class CCaSqlQuery; class CCaInnerEntry; class CCaInnerQuery; @@ -144,18 +145,13 @@ CCaSqlQuery* aQuery, const TDesC& aSqlQueryText ); /** - * Creates an sql query to get a list of of localizations entries. + * Creates an sql query to add, update or get data from localization table. * - * @param aQuery The result query. + * @param aSqlQuery The result query. + * @param aStatement statement */ - static void CreateGetLocalizationsQueryL( CCaSqlQuery* aQuery ); - - /** - * Creates an sql query to update db entry with localization. - * - * @param aQuery The result query. - */ - static void CreateLocalizeEntryQueryL( CCaSqlQuery* aQuery ); + static void CreateLocalizationTableQueryL(CCaSqlQuery* aSqlQuery, + const TDesC& aStatement); /** * Creates an sql query to custom sort order. diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/inc/castorage.h --- a/contentstorage/castorage/inc/castorage.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/inc/castorage.h Thu May 27 13:11:12 2010 +0300 @@ -40,6 +40,13 @@ virtual void LocalizeEntryL( CCaLocalizationEntry& aLocalization ) = 0; /** + * Adds localization row to the localization table + * + * @param aLocalization localization information about entry. + */ + virtual void AddLocalizationL( const CCaLocalizationEntry& aLocalization ) = 0; + + /** * Fetches data from database * * @param aResultContainer container for localizations information. diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/src/casqlitestorage.cpp --- a/contentstorage/castorage/src/casqlitestorage.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/src/casqlitestorage.cpp Thu May 27 13:11:12 2010 +0300 @@ -207,23 +207,81 @@ } } +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// void CCaSqLiteStorage::LocalizeEntryL( CCaLocalizationEntry& aLocalization ) { CCaSqlQuery* sqlLocalizeEntryQuery = CCaSqlQuery::NewLC( iSqlDb ); - CaSqlQueryCreator::CreateLocalizeEntryQueryL( sqlLocalizeEntryQuery ); + CaSqlQueryCreator::CreateLocalizationTableQueryL(sqlLocalizeEntryQuery, + KSQLLocalizeEntry); sqlLocalizeEntryQuery->PrepareL(); sqlLocalizeEntryQuery->BindValuesForLocalizeL( aLocalization ); sqlLocalizeEntryQuery->ExecuteL( ); CleanupStack::PopAndDestroy( sqlLocalizeEntryQuery ); } +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CCaSqLiteStorage::AddLocalizationL( + const CCaLocalizationEntry& aLocalization) + { + if (LocalizationEntryPresentL(aLocalization)) + { + ExecuteLocalizationStatementL(aLocalization, KSQLUpdateLocalization); + } + else + { + ExecuteLocalizationStatementL(aLocalization, KSQLAddLocalization); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +TBool CCaSqLiteStorage::LocalizationEntryPresentL( + const CCaLocalizationEntry& aLocalization) + { + TBool result(EFalse); + CCaSqlQuery* sqlQuery = CCaSqlQuery::NewLC( iSqlDb ); + CaSqlQueryCreator::CreateLocalizationTableQueryL(sqlQuery, + KSQLGetLocalization); + sqlQuery->PrepareL(); + sqlQuery->BindValuesForGetLocalizationEntryL( aLocalization ); + result = sqlQuery->ExecuteEntryPresentL( ); + CleanupStack::PopAndDestroy( sqlQuery ); + return result; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CCaSqLiteStorage::ExecuteLocalizationStatementL( + const CCaLocalizationEntry& aLocalization, const TDesC& aStatement) + { + CCaSqlQuery* sqlQuery = CCaSqlQuery::NewLC( iSqlDb ); + CaSqlQueryCreator::CreateLocalizationTableQueryL(sqlQuery,aStatement ); + sqlQuery->PrepareL(); + sqlQuery->BindValuesForLocalizationEntryL( aLocalization ); + sqlQuery->ExecuteL( ); + CleanupStack::PopAndDestroy( sqlQuery ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// void CCaSqLiteStorage::GetLocalizationsL( RPointerArray& aResultContainer ) { CCaSqlQuery* sqlGetLocalizationsQuery = CCaSqlQuery::NewLC( iSqlDb ); - CaSqlQueryCreator::CreateGetLocalizationsQueryL( - sqlGetLocalizationsQuery ); - + CaSqlQueryCreator::CreateLocalizationTableQueryL( + sqlGetLocalizationsQuery, KSQLGetLocalizations ); sqlGetLocalizationsQuery->PrepareL(); sqlGetLocalizationsQuery->ExecuteLocalizationsL( aResultContainer ); CleanupStack::PopAndDestroy( sqlGetLocalizationsQuery ); @@ -245,7 +303,6 @@ sqlGetEntriesIdsQuery->ExecuteL( aResultIdArray, CCaSqlQuery::EEntryTable ); CleanupStack::PopAndDestroy( sqlGetEntriesIdsQuery ); - } // --------------------------------------------------------------------------- diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/src/casqlquery.cpp --- a/contentstorage/castorage/src/casqlquery.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/src/casqlquery.cpp Thu May 27 13:11:12 2010 +0300 @@ -413,6 +413,41 @@ // // --------------------------------------------------------------------------- // +void CCaSqlQuery::BindValuesForGetLocalizationEntryL( + const CCaLocalizationEntry& aLocalization) + { + BindIntL( iStatement.ParameterIndex( KSQLLocRowId ), + aLocalization.GetRowId() ); + BindTextL( iStatement.ParameterIndex( KSQLLocTable ), + aLocalization.GetTableName() ); + BindTextL( iStatement.ParameterIndex( KSQLLocAttribute ), + aLocalization.GetAttributeName() ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CCaSqlQuery::BindValuesForLocalizationEntryL( + const CCaLocalizationEntry& aLocalization) + { + BindIntL( iStatement.ParameterIndex( KSQLLocRowId ), + aLocalization.GetRowId() ); + BindTextL( iStatement.ParameterIndex( KSQLLocTable ), + aLocalization.GetTableName() ); + BindTextL( iStatement.ParameterIndex( KSQLLocAttribute ), + aLocalization.GetAttributeName() ); + BindTextL( iStatement.ParameterIndex( KSQLLocQmFilename ), + aLocalization.GetQmFilename() ); + BindTextL( iStatement.ParameterIndex( KSQLLocString ), + aLocalization.GetStringId() ); + } + + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// void CCaSqlQuery::BindValuesForGetEntriesL( const CCaInnerQuery* aQuery ) { if( aQuery->GetIds().Count() > 0 ) @@ -609,6 +644,19 @@ // // --------------------------------------------------------------------------- // +TBool CCaSqlQuery::ExecuteEntryPresentL( ) + { + if( iStatement.Next() == KSqlAtRow ) + { + return ETrue; + } + return EFalse; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// TInt CCaSqlQuery::ExecuteL( TInt& aId ) { if( iStatement.Next() == KSqlAtRow ) @@ -743,6 +791,13 @@ tableName ) ); + TPtrC qmFilename; + User::LeaveIfError( + iStatement.ColumnText( + ColumnIndexL( iStatement, KColumnQmFile ), + qmFilename ) + ); + TPtrC attribute; User::LeaveIfError( iStatement.ColumnText( @@ -763,6 +818,7 @@ result->SetStringIdL( stringId ); result->SetRowId( rowId ); result->SetTableNameL( tableName ); + result->SetQmFilenameL( qmFilename ); aResultInput.AppendL( result ); CleanupStack::Pop( result ); diff -r 4bc7b118b3df -r 397d00875918 contentstorage/castorage/src/casqlquerycreator.cpp --- a/contentstorage/castorage/src/casqlquerycreator.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/castorage/src/casqlquerycreator.cpp Thu May 27 13:11:12 2010 +0300 @@ -574,31 +574,14 @@ // // --------------------------------------------------------------------------- // -void CaSqlQueryCreator::CreateLocalizeEntryQueryL( CCaSqlQuery* aSqlQuery ) +void CaSqlQueryCreator::CreateLocalizationTableQueryL( CCaSqlQuery* aSqlQuery, + const TDesC& aStatement) { - DEBUG(("_CA_:CASqlQueryCreator::CreateLocalizeEntryQueryL")); - RBuf query; - - query.CleanupClosePushL(); - query.CreateL( KSQLLocalizeEntry().Length() ); - query.Append( KSQLLocalizeEntry ); - - aSqlQuery->SetQueryL( query ); - CleanupStack::PopAndDestroy( &query ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CaSqlQueryCreator::CreateGetLocalizationsQueryL( CCaSqlQuery* aSqlQuery ) - { - DEBUG(("_CA_:CASqlQueryCreator::CreateGetLocalizationsQueryL")); + DEBUG(("_CA_:CASqlQueryCreator::CreateLocalizationTableQueryL")); RBuf query; query.CleanupClosePushL(); - query.CreateL( KSQLGetLocalizations().Length() ); - query.Append( KSQLGetLocalizations ); - + query.CreateL( aStatement.Length() ); + query.Append( aStatement ); aSqlQuery->SetQueryL( query ); CleanupStack::PopAndDestroy( &query ); } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cautils/inc/calocalizationentry.h --- a/contentstorage/cautils/inc/calocalizationentry.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/cautils/inc/calocalizationentry.h Thu May 27 13:11:12 2010 +0300 @@ -80,9 +80,20 @@ * Gets LocalizedString * @return LocalizedString */ - IMPORT_C const RBuf& GetLocalizedString( ) const; + IMPORT_C const RBuf& GetLocalizedString() const; + /** + * Gets GetQmFilename + * @return GetQmFilename + */ + IMPORT_C const RBuf& GetQmFilename() const; + // SETTERS + + /** + */ + IMPORT_C void SetQmFilenameL( const TDesC& aQmFilename ); + /** */ @@ -119,6 +130,7 @@ IMPORT_C void SetLocalizedStringL( const TDesC& aLocalName ); + /* * * Externalizes object to the stream * @param aStream a write stream @@ -183,6 +195,12 @@ * Own. */ RBuf iLocalName; + + /* + * Translated string. + * Own. + */ + RBuf iQmFilename; }; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/cautils/src/calocalizationentry.cpp --- a/contentstorage/cautils/src/calocalizationentry.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/cautils/src/calocalizationentry.cpp Thu May 27 13:11:12 2010 +0300 @@ -27,10 +27,11 @@ CCaLocalizationEntry::~CCaLocalizationEntry( ) { - iTableName.Close( ); - iAttribName.Close( ); - iStringId.Close( ); - iLocalName.Close( ); + iTableName.Close(); + iAttribName.Close(); + iStringId.Close(); + iLocalName.Close(); + iQmFilename.Close(); } // --------------------------------------------------------------------------- @@ -188,6 +189,24 @@ // // --------------------------------------------------------------------------- // +EXPORT_C const RBuf& CCaLocalizationEntry::GetQmFilename( ) const + { + return iQmFilename; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +EXPORT_C void CCaLocalizationEntry::SetQmFilenameL( const TDesC& aQmFilename ) + { + iQmFilename.Close( ); + iQmFilename.CreateL( aQmFilename ); + } +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// EXPORT_C const RBuf& CCaLocalizationEntry::GetLocalizedString( ) const { return iLocalName; diff -r 4bc7b118b3df -r 397d00875918 contentstorage/contentstorage.pro --- a/contentstorage/contentstorage.pro Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/contentstorage.pro Thu May 27 13:11:12 2010 +0300 @@ -23,4 +23,5 @@ SUBDIRS += cahandler } SUBDIRS += caclient +SUBDIRS += casoftwareregistry CONFIG += ordered diff -r 4bc7b118b3df -r 397d00875918 contentstorage/eabi/camenuu.def --- a/contentstorage/eabi/camenuu.def Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/eabi/camenuu.def Thu May 27 13:11:12 2010 +0300 @@ -23,4 +23,6 @@ _ZNK14CCaSrvEngUtils13GetApaAppInfoE4TUidR11TApaAppInfo @ 22 NONAME _ZTI15CCaStorageProxy @ 23 NONAME _ZTV15CCaStorageProxy @ 24 NONAME + _ZN16CCaSrvMmcHistory4NewLEv @ 25 NONAME + _ZN15CCaStorageProxy16AddLocalizationLERK20CCaLocalizationEntry @ 26 NONAME diff -r 4bc7b118b3df -r 397d00875918 contentstorage/eabi/cautilsu.def --- a/contentstorage/eabi/cautilsu.def Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/eabi/cautilsu.def Thu May 27 13:11:12 2010 +0300 @@ -96,4 +96,6 @@ _ZNK22CCaInnerNotifierFilter12GetTypeNamesEv @ 95 NONAME _ZNK22CCaInnerNotifierFilter15GetNotifierTypeEv @ 96 NONAME _ZNK22CCaInnerNotifierFilter6GetIdsEv @ 97 NONAME + _ZN20CCaLocalizationEntry14SetQmFilenameLERK7TDesC16 @ 98 NONAME + _ZNK20CCaLocalizationEntry13GetQmFilenameEv @ 99 NONAME diff -r 4bc7b118b3df -r 397d00875918 contentstorage/extinc/casathandler.h --- a/contentstorage/extinc/casathandler.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/extinc/casathandler.h Thu May 27 13:11:12 2010 +0300 @@ -20,7 +20,7 @@ #include -#include +#include #include #ifdef SIM_ATK_SERVICE_API_V1 #include // MCL diff -r 4bc7b118b3df -r 397d00875918 contentstorage/group/group.pro --- a/contentstorage/group/group.pro Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/group/group.pro Thu May 27 13:11:12 2010 +0300 @@ -20,8 +20,8 @@ BLD_INF_RULES.prj_exports += \ "../castorage/conf/castoragedb.confml APP_LAYER_CONFML(castoragedb.confml)" \ "../castorage/conf/castoragedb.implml APP_LAYER_CONFML(castoragedb.implml)" \ - "../castorage/data/castoragedb_create.sql APP_LAYER_CONFML(castoragedb_templates/castoragedb_create.sql)" \ - "../castorage/conf/castoragedb_templates/castoragedb_variant.sql APP_LAYER_CONFML(castoragedb_templates/castoragedb_variant.sql)" \ + "../castorage/data/castoragedb_create.sql APP_LAYER_CONFML(../implml/castoragedb_templates/castoragedb_create.sql)" \ + "../castorage/conf/castoragedb_templates/castoragedb_variant.sql APP_LAYER_CONFML(../implml/castoragedb_templates/castoragedb_variant.sql)" \ "$${LITERAL_HASH}ifndef CONTENT_ARSENAL_STORAGE_UT" \ "../castorage/data/castorage.db z:/private/20022F90/castorage.db" \ "$${LITERAL_HASH}else " \ diff -r 4bc7b118b3df -r 397d00875918 contentstorage/inc/cadef.h --- a/contentstorage/inc/cadef.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/inc/cadef.h Thu May 27 13:11:12 2010 +0300 @@ -12,7 +12,7 @@ * Contributors: * * Description: Definition of different constants - * Version : %version: ou1s60ui#10.1.14 % << Don't touch! Updated by Synergy at check-out. + * Version : %version: 10.1.16 % << Don't touch! Updated by Synergy at check-out. * */ @@ -97,6 +97,8 @@ _LIT( KCaAppGroupName, "appgroup_name" ); +_LIT( KCollectionIconFileName, "qtg_large_applications_user"); + const TInt KGranularityOne = 1; const TInt KUidChars = 10; const TInt KDefaultGranularity = 5; @@ -146,6 +148,7 @@ // Menu clients always need to check that the necessary attributes are present. // _LIT( KCaAttrLongName, "long_name" ); ///< Long name. +_LIT( KCaComponentId, "component_id" ); ///< Long name. // Built-in types and attributes. // diff -r 4bc7b118b3df -r 397d00875918 contentstorage/srvinc/casrvmmchistory.h --- a/contentstorage/srvinc/casrvmmchistory.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/srvinc/casrvmmchistory.h Thu May 27 13:11:12 2010 +0300 @@ -36,19 +36,15 @@ // construction /** + * Creates an instance of CCaSrvMmcHistory. + * @return a pointer to CCaSrvMmcHistory insctance. + */ + IMPORT_C static CCaSrvMmcHistory* NewL(); + + /** * Destructor. */ - virtual ~CCaSrvMmcHistory() - { - iMmcList.Close(); - } - - /** - * Constructor. - */ - CCaSrvMmcHistory() - { - } + virtual ~CCaSrvMmcHistory(); public: // new methods @@ -84,6 +80,17 @@ IMPORT_C TInt Find( TUint aMmc ); // Find mmc in history. private: + /** + * Constructor. + */ + CCaSrvMmcHistory(); + + /** + * Second phase symbian constructor. + */ + void ConstructL(); + +private: // data RArray iMmcList; ///< ID history list. Own. diff -r 4bc7b118b3df -r 397d00875918 contentstorage/srvinc/castorageproxy.h --- a/contentstorage/srvinc/castorageproxy.h Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/srvinc/castorageproxy.h Thu May 27 13:11:12 2010 +0300 @@ -60,6 +60,13 @@ IMPORT_C void LocalizeEntryL( CCaLocalizationEntry& aLocalization ); /** + * Add localization row to the storage + * + * @param aLocalization entry containing localization row to be added + */ + IMPORT_C void AddLocalizationL(const CCaLocalizationEntry& aLocalization); + + /** * Fetches localization data from database * * @param aResultContainer Target for results. diff -r 4bc7b118b3df -r 397d00875918 contentstorage/srvsrc/casrv.cpp --- a/contentstorage/srvsrc/casrv.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/srvsrc/casrv.cpp Thu May 27 13:11:12 2010 +0300 @@ -154,12 +154,14 @@ iSessionCount = 0; iStorageProxy = CCaStorageProxy::NewL(); iSrvEngUtils = CCaSrvEngUtils::NewL(); - TRAPD( err, iSrvManager = CCaSrvManager::NewL( - *iStorageProxy, iSrvEngUtils ) ); - if( KSqlErrNotDb <= err && err <= KSqlErrGeneral ) + iSrvManager = CCaSrvManager::NewL(*iStorageProxy, iSrvEngUtils); + TInt errCode = iSrvManager->LoadOperationErrorCodeL(); + if( KSqlErrNotDb <= errCode && errCode <= KSqlErrGeneral ) { //problem in loading one of plugins, probably data base is corrupted //lets load it from ROM and try again + delete iSrvManager; + iSrvManager = NULL; iStorageProxy->LoadDataBaseFromRomL(); iSrvManager = CCaSrvManager::NewL( *iStorageProxy, iSrvEngUtils ); } diff -r 4bc7b118b3df -r 397d00875918 contentstorage/srvsrc/casrvmmchistory.cpp --- a/contentstorage/srvsrc/casrvmmchistory.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/srvsrc/casrvmmchistory.cpp Thu May 27 13:11:12 2010 +0300 @@ -26,7 +26,45 @@ // ==================== MEMBER FUNCTIONS ==================== // --------------------------------------------------------- -// CMenuSrvMmcHistory::LoadL +// +// --------------------------------------------------------- +// +CCaSrvMmcHistory::CCaSrvMmcHistory() + { + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CCaSrvMmcHistory::ConstructL() + { + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +EXPORT_C CCaSrvMmcHistory* CCaSrvMmcHistory::NewL() + { + CCaSrvMmcHistory* self = new (ELeave) CCaSrvMmcHistory(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +CCaSrvMmcHistory::~CCaSrvMmcHistory() + { + iMmcList.Close(); + } + +// --------------------------------------------------------- +// // --------------------------------------------------------- // EXPORT_C void CCaSrvMmcHistory::LoadL( RFs& aFs, const TDesC& aFname ) diff -r 4bc7b118b3df -r 397d00875918 contentstorage/srvsrc/castorageproxy.cpp --- a/contentstorage/srvsrc/castorageproxy.cpp Fri May 14 16:10:06 2010 +0300 +++ b/contentstorage/srvsrc/castorageproxy.cpp Thu May 27 13:11:12 2010 +0300 @@ -272,6 +272,16 @@ // // --------------------------------------------------------------------------- // +EXPORT_C void CCaStorageProxy::AddLocalizationL( + const CCaLocalizationEntry& aLocalization) + { + iStorage->AddLocalizationL(aLocalization); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// EXPORT_C void CCaStorageProxy::DbPropertyL( const TDesC& aProperty, TDes& aPropertyValue ) { diff -r 4bc7b118b3df -r 397d00875918 homescreensrv.pro --- a/homescreensrv.pro Fri May 14 16:10:06 2010 +0300 +++ b/homescreensrv.pro Thu May 27 13:11:12 2010 +0300 @@ -22,6 +22,7 @@ homescreensrv_plat \ tsrc symbian:SUBDIRS += activityfw +symbian:SUBDIRS += tstaskmonitor symbian:SUBDIRS += hsappkeyhandler diff -r 4bc7b118b3df -r 397d00875918 homescreensrv_plat/contentstorage_api/casoftwareregistry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreensrv_plat/contentstorage_api/casoftwareregistry.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: ?Description + * + */ + +#ifndef CA_SOFTWARE_REGISTRY_H +#define CA_SOFTWARE_REGISTRY_H + +#include +#include +#include +#include + +#include "caclient_global.h" + +//FORWARD DECLARATIONS +class CaSoftwareRegistryPrivate; + +/** + * Class provides Usif specific services + */ +class CACLIENT_EXPORT CaSoftwareRegistry: public QObject +{ + +Q_OBJECT + + explicit CaSoftwareRegistry(QObject *parent = 0); + + ~CaSoftwareRegistry(); + +public: + + static QSharedPointer create(); + + typedef QHash DetailMap; + + DetailMap entryDetails(int componentId) const; + + static QString componentNameKey(); + static QString componentVersionKey(); + static QString componentVendorKey(); + static QString componentDriveInfoKey(); + static QString componentSizeKey(); + static QString componentTypeKey(); +private: + /** + * Pointer to a private implementation. + */ + CaSoftwareRegistryPrivate *const m_d; + + /** + * The static pointer to the instance of CaSoftwareRegistry. + */ + static QWeakPointer m_instance; + + friend class CaSoftwareRegistryPrivate; + friend class QtSharedPointer::ExternalRefCount; + + Q_DISABLE_COPY(CaSoftwareRegistry) + +}; + +#endif // CA_SOFTWARE_REGISTRY_H diff -r 4bc7b118b3df -r 397d00875918 homescreensrv_plat/contentstorage_api/contentstorage_api.pri --- a/homescreensrv_plat/contentstorage_api/contentstorage_api.pri Fri May 14 16:10:06 2010 +0300 +++ b/homescreensrv_plat/contentstorage_api/contentstorage_api.pri Thu May 27 13:11:12 2010 +0300 @@ -24,4 +24,5 @@ contentstorage_api/caquery.h \ contentstorage_api/caservice.h \ contentstorage_api/caitemmodel.h \ - contentstorage_api/camenuiconutility.h \ No newline at end of file + contentstorage_api/camenuiconutility.h \ + contentstorage_api/casoftwareregistry.h \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 homescreensrv_plat/homescreen_information_api/inc/homescreendomainpskeys.h --- a/homescreensrv_plat/homescreen_information_api/inc/homescreendomainpskeys.h Fri May 14 16:10:06 2010 +0300 +++ b/homescreensrv_plat/homescreen_information_api/inc/homescreendomainpskeys.h Thu May 27 13:11:12 2010 +0300 @@ -31,6 +31,7 @@ */ const char HsStatePSKeySubPath[] = "state"; +#ifdef Q_OS_SYMBIAN /** * Home Screen P&S category Uid for pure Symbian usage. */ @@ -38,10 +39,11 @@ /** * P&S Key to represent the state of the Home Screen for pure Symbian usage. - * This property is updated when Home screen state is changed. Valid values + * This property is updated when Home screen state is changed. Valid values * are defined by the enum EPSHsState. */ const TUint KHsCategoryStateKey = 0x1; +#endif //Q_OS_SYMBIAN /** * Home screen state. diff -r 4bc7b118b3df -r 397d00875918 rom/homescreensrv_core.iby --- a/rom/homescreensrv_core.iby Fri May 14 16:10:06 2010 +0300 +++ b/rom/homescreensrv_core.iby Thu May 27 13:11:12 2010 +0300 @@ -42,6 +42,7 @@ file=ABI_DIR\BUILD_DIR\castorage.dll SHARED_LIB_DIR\castorage.dll file=ABI_DIR\BUILD_DIR\MenuInterface.dll SHARED_LIB_DIR\MenuInterface.dll file=ABI_DIR\BUILD_DIR\casrvmanager.dll SHARED_LIB_DIR\casrvmanager.dll +file=ABI_DIR\BUILD_DIR\casoftwareregistry.dll SHARED_LIB_DIR\casoftwareregistry.dll ECOM_PLUGIN( casatmonitor.dll, casatmonitor.rsc ) ECOM_PLUGIN( caappscanner.dll, caappscanner.rsc ) ECOM_PLUGIN( cawidgetscanner.dll, cawidgetscanner.rsc ) diff -r 4bc7b118b3df -r 397d00875918 sis/homescreensrv.pkg --- a/sis/homescreensrv.pkg Fri May 14 16:10:06 2010 +0300 +++ b/sis/homescreensrv.pkg Thu May 27 13:11:12 2010 +0300 @@ -138,6 +138,7 @@ "/epoc32/release/armv5/urel/caextendedmenu.dll" - "c:/sys/bin/caextendedmenu.dll" "/epoc32/release/armv5/urel/casathandler.dll" - "c:/sys/bin/casathandler.dll" "/epoc32/release/armv5/urel/castorage.dll" - "c:/sys/bin/castorage.dll" +"/epoc32/release/armv5/urel/casoftwareregistry.dll" - "c:/sys/bin/casoftwareregistry.dll" "/epoc32/release/armv5/urel/castockhandlerplugins.dll" - "c:/sys/bin/castockhandlerplugins.dll" "/epoc32/data/z/private/20022F90/castorage.db" - "c:/private/20022F90/castorage.db" "/epoc32/data/z/resource/plugins/castockhandlerplugins.rsc"-"c:/resource/plugins/castockhandlerplugins.rsc" diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/client.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/client.pri Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,61 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +INCLUDEPATH += $$PWD/inc + +HEADERS += $$PWD/inc/tstaskmonitor_global.h \ + $$PWD/inc/tstaskmonitor.h \ + $$PWD/inc/tstask.h \ + +SOURCES += $$PWD/src/tstaskmonitor.cpp \ + +symbian { + INCLUDEPATH += $$PWD/s60/inc \ + $$PWD/../inc \ + $$PWD/../utils/inc \ + + HEADERS += $$PWD/s60/inc/tstaskmonitorobserver.h \ + $$PWD/s60/inc/tstaskmonitorclient.h \ + $$PWD/s60/inc/tstaskmonitorclientimpl.h \ + $$PWD/s60/inc/tstaskmonitorsession.h \ + $$PWD/../utils/inc/tsfswentry.h \ + $$PWD/../utils/inc/tsutils.h \ + $$PWD/s60/inc/tstaskmonitor_p.h \ + $$PWD/s60/inc/tsapplicationtask.h \ + + SOURCES += $$PWD/s60/src/tstaskmonitorclient.cpp \ + $$PWD/s60/src/tstaskmonitorclientimpl.cpp \ + $$PWD/s60/src/tstaskmonitorsession.cpp \ + $$PWD/../utils/src/tsfswentry.cpp \ + $$PWD/s60/src/tstaskmonitor_p.cpp \ + $$PWD/s60/src/tstask.cpp \ + $$PWD/s60/src/tsapplicationtask.cpp \ + + LIBS += -lxqutils \ + -lestor \ + -lfbscli + +} else { + INCLUDEPATH += $$PWD/stub/inc \ + + HEADERS += $$PWD/stub/inc/tstaskmonitor_p.h \ + $$PWD/stub/inc/tsfswentry.h \ + + SOURCES += $$PWD/stub/src/tstaskmonitor_p.cpp \ + $$PWD/stub/src/tstask.cpp \ + $$PWD/stub/src/tsfswentry.cpp \ + +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/client.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/client.pro Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,43 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = lib +TARGET = tstaskmonitorclient + +CONFIG += dll + +DEFINES += TSTASKMONITOR_LIB + +symbian { + dll.sources = tstaskmonitorclient.dll + dll.path = $$SHARED_LIB_DIR + DEPLOYMENT += dll + + BLD_INF_RULES.prj_exports += "s60\inc\tstaskmonitorclient.h" \ + "s60\inc\tstaskmonitorobserver.h" \ + "inc\tstaskmonitor.h" \ + "inc\tstask.h" \ + "inc\tstaskmonitor_global.h" \ + + TARGET.UID3 = 0x200267AF + TARGET.CAPABILITY = ALL -TCB + TARGET.EPOCALLOWDLLDATA = 1 + + # temporary, remove when API is stable enough + MMP_RULES += EXPORTUNFROZEN +} + +include(client.pri) diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/inc/tstask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/inc/tstask.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASK_H +#define TSTASK_H + +#include +#include + +#include "tstaskmonitor_global.h" + +class CTsFswEntry; + +class TsTask +{ + +public: + TsTask(CTsFswEntry* entry); + TSTASKMONITOR_EXPORT virtual ~TsTask(); + + TSTASKMONITOR_EXPORT virtual void open() = 0; + TSTASKMONITOR_EXPORT virtual void close() = 0; + + TSTASKMONITOR_EXPORT bool isClosable() const; + TSTASKMONITOR_EXPORT QPixmap icon() const; + TSTASKMONITOR_EXPORT QString name() const; + +protected: + CTsFswEntry* mEntry; + +}; + +#endif //TSTASK_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/inc/tstaskmonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/inc/tstaskmonitor.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITOR_H +#define TSTASKMONITOR_H + +#include +#include + +#include "tstaskmonitor_global.h" +#include "tstask.h" + +class TsTaskMonitorPrivate; + +class TSTASKMONITOR_EXPORT TsTaskMonitor : public QObject +{ + Q_OBJECT + +public: + TsTaskMonitor(QObject *parent = 0); + ~TsTaskMonitor(); + QList< QSharedPointer > taskList(); + +signals: + void taskListChanged(); + +private: + TsTaskMonitorPrivate *d_ptr; + friend class TsTaskMonitorPrivate; +}; + +#endif //TSTASKMONITOR_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/inc/tstaskmonitor_global.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/inc/tstaskmonitor_global.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITOR_GLOBAL_H +#define TSTASKMONITOR_GLOBAL_H + +#include + +#ifdef TSTASKMONITOR_LIB + #define TSTASKMONITOR_EXPORT Q_DECL_EXPORT +#else + #ifdef TSTASKMONITOR_TEST + #define TSTASKMONITOR_EXPORT + #else + #define TSTASKMONITOR_EXPORT Q_DECL_IMPORT + #endif +#endif + +#endif //TSTASKMONITOR_GLOBAL_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/inc/tsapplicationtask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/inc/tsapplicationtask.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSAPPLICATIONTASK_H +#define TSAPPLICATIONTASK_H + +#include "tstask.h" + +class TsApplicationTask : public TsTask +{ + +public: + TsApplicationTask(CTsFswEntry* entry); + + virtual void open(); + virtual void close(); + +}; + +#endif //TSAPPLICATIONTASK_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/inc/tstaskmonitor_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/inc/tstaskmonitor_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITOR_P_H +#define TSTASKMONITOR_P_H + +#include "tstaskmonitorobserver.h" + +#include +#include + +class TsTask; +class TsTaskMonitor; +class CTsTaskMonitorClient; + +class TsTaskMonitorPrivate : public MTsTaskMonitorObserver +{ +public: + TsTaskMonitorPrivate(TsTaskMonitor *q); + virtual ~TsTaskMonitorPrivate(); + +public: + QList< QSharedPointer > taskList(); + +public: + virtual void HandleRunningAppChange(); + +private: + TsTaskMonitor *q_ptr; + CTsTaskMonitorClient *mClient; + +}; + +#endif //TSTASKMONITOR_P_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/inc/tstaskmonitorclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/inc/tstaskmonitorclient.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITORCLIENT_H +#define TSTASKMONITORCLIENT_H + +#include + +#include "tsfswentry.h" + +class MTsTaskMonitorObserver; +class CTsTaskMonitorClientImpl; + +NONSHARABLE_CLASS( CTsTaskMonitorClient ) : public CBase +{ +public: + IMPORT_C static CTsTaskMonitorClient* NewL(); + IMPORT_C static CTsTaskMonitorClient* NewLC(); + IMPORT_C ~CTsTaskMonitorClient(); + +public: + void TaskListL(RTsFswArray& tasks); + void Subscribe(MTsTaskMonitorObserver& aObserver); + void CancelSubscribe(); + +private: + CTsTaskMonitorClient(); + void ConstructL(); + +private: + CTsTaskMonitorClientImpl* iImpl; +}; + +#endif // TSTASKMONITORCLIENT_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/inc/tstaskmonitorclientimpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/inc/tstaskmonitorclientimpl.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITORCLIENTIMPL_H +#define TSTASKMONITORCLIENTIMPL_H + +#include + +#include "tsfswentry.h" +#include "tstaskmonitorsession.h" + +class MTsTaskMonitorObserver; + +NONSHARABLE_CLASS( CTsTaskMonitorClientImpl ) : public CActive +{ +public: + static CTsTaskMonitorClientImpl* NewL(); + static CTsTaskMonitorClientImpl* NewLC(); + ~CTsTaskMonitorClientImpl(); + +public: + void TaskListL(RTsFswArray& tasks); + + void Subscribe(MTsTaskMonitorObserver& aObserver); + void CancelSubscribe(); + +private: + void RunL(); + void DoCancel(); + +private: + CTsTaskMonitorClientImpl(); + void ConstructL(); + + RTsTaskMonitorSession iSession; + MTsTaskMonitorObserver* iObserver; // not owned +}; + +#endif // TSTASKMONITORCLIENTIMPL_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/inc/tstaskmonitorobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/inc/tstaskmonitorobserver.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Client API + * +*/ + +#ifndef TSTASKMONITOROBSERVER_H +#define TSTASKMONITOROBSERVER_H + +#include + +/** + * Observer interface for getting notifications about fast swap content changes. + */ +class MTsTaskMonitorObserver + { +public: + /** + * Called when there is a change in the fast swap content. + * The data can be queried via CTsTaskMonitorClient::TaskListL + */ + virtual void HandleRunningAppChange() = 0; + }; + +#endif //TSTASKMONITOROBSERVER_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/inc/tstaskmonitorsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/inc/tstaskmonitorsession.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITORSESSION_H +#define TSTASKMONITORSESSION_H + +#include + +#include "tsfswentry.h" + +NONSHARABLE_CLASS( RTsTaskMonitorSession ) : public RSessionBase +{ +public: + TInt Connect(); + + void TaskListL(RTsFswArray& tasks); + void Subscribe(TRequestStatus& aStatus); + void CancelSubscribe(); + +private: + TInt StartServer(); +}; + +#endif // TSTASKMONITORSESSION_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/src/tsapplicationtask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/src/tsapplicationtask.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "tsapplicationtask.h" + +#include +#include +#include + +#include "tsfswentry.h" + +TsApplicationTask::TsApplicationTask(CTsFswEntry* entry) : TsTask(entry) +{ +} + +void TsApplicationTask::open() +{ + TApaTaskList taskList(CEikonEnv::Static()->WsSession()); + TApaTask task = taskList.FindApp(mEntry->AppUid()); + task.BringToForeground(); +} + +void TsApplicationTask::close() +{ + RWsSession wsSession; + if (wsSession.Connect() == KErrNone) { + CleanupClosePushL(wsSession); + + TWsEvent event; + event.SetTimeNow(); + event.SetType(KAknShutOrHideApp); + wsSession.SendEventToWindowGroup(mEntry->WgId(), event); + + CleanupStack::PopAndDestroy(&wsSession); + } +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/src/tstask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/src/tstask.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "tstask.h" + +#include + +#include "tsfswentry.h" + +TsTask::TsTask(CTsFswEntry* entry) : mEntry(entry) +{ +} + +TsTask::~TsTask() +{ + delete mEntry; +} + +bool TsTask::isClosable() const +{ + return mEntry->CloseableApp(); +} + +QPixmap TsTask::icon() const +{ + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(mEntry->AppIconBitmap()); + QPixmap mask = QPixmap::fromSymbianCFbsBitmap(mEntry->AppIconMask()); + // @todo QPixmap::setAlphaChannel() is deprecated, change to code using QPainter + pixmap.setAlphaChannel(mask); + return pixmap; +} + +QString TsTask::name() const +{ + return XQConversions::s60DescToQString(mEntry->AppName()); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/src/tstaskmonitor_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/src/tstaskmonitor_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "tstaskmonitor_p.h" +#include "tstaskmonitor.h" + +#include "tstaskmonitorclient.h" +#include "tsapplicationtask.h" + +#include "tsutils.h" +using TaskSwitcher::CleanupResetAndDestroyPushL; + +TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q) : q_ptr(q), mClient(0) +{ + QT_TRAP_THROWING(mClient = CTsTaskMonitorClient::NewL()); + mClient->Subscribe(*this); +} + +TsTaskMonitorPrivate::~TsTaskMonitorPrivate() +{ + mClient->CancelSubscribe(); +} + +QList< QSharedPointer > TsTaskMonitorPrivate::taskList() +{ + QList< QSharedPointer > tasks; + + QT_TRAP_THROWING ( + RPointerArray entries; + CleanupResetAndDestroyPushL(entries); + mClient->TaskListL(entries); + + // TsTask claims ownership of CTsFswEntry, so we have to remove entries from + // entries array after adding task to tasks array to prevent double delete of + // CTsFswEntry objects in case of leave (for example due to OOM) in the middle + // of the loop below. + while (entries.Count()) { + CTsFswEntry *firstEntry = entries[0]; + CleanupStack::PushL(firstEntry); + entries.Remove(0); + + // @todo switch by entry type + QT_TRYCATCH_LEAVING(tasks.append(QSharedPointer(new TsApplicationTask(firstEntry)))); + + CleanupStack::Pop(firstEntry); + } + + CleanupStack::PopAndDestroy(&entries); + ); + + return tasks; +} + +void TsTaskMonitorPrivate::HandleRunningAppChange() +{ + emit q_ptr->taskListChanged(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/src/tstaskmonitorclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/src/tstaskmonitorclient.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +#include "tstaskmonitorclient.h" +#include "tstaskmonitorclientimpl.h" + +EXPORT_C CTsTaskMonitorClient *CTsTaskMonitorClient::NewL() +{ + CTsTaskMonitorClient* self = NewLC(); + CleanupStack::Pop(self); + return self; +} + +EXPORT_C CTsTaskMonitorClient *CTsTaskMonitorClient::NewLC() +{ + CTsTaskMonitorClient* self = new (ELeave) CTsTaskMonitorClient; + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +void CTsTaskMonitorClient::ConstructL() +{ + iImpl = CTsTaskMonitorClientImpl::NewL(); +} + +CTsTaskMonitorClient::CTsTaskMonitorClient() +{ +} + +EXPORT_C CTsTaskMonitorClient::~CTsTaskMonitorClient() +{ + delete iImpl; +} + +void CTsTaskMonitorClient::TaskListL(RTsFswArray& tasks) +{ + iImpl->TaskListL(tasks); +} + +void CTsTaskMonitorClient::Subscribe(MTsTaskMonitorObserver& aObserver) +{ + iImpl->Subscribe(aObserver); +} + +void CTsTaskMonitorClient::CancelSubscribe() +{ + iImpl->CancelSubscribe(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/src/tstaskmonitorclientimpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/src/tstaskmonitorclientimpl.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +#include "tsfswentry.h" +#include "tstaskmonitorclientimpl.h" +#include "tstaskmonitorobserver.h" + +CTsTaskMonitorClientImpl* CTsTaskMonitorClientImpl::NewL() +{ + CTsTaskMonitorClientImpl* self = NewLC(); + CleanupStack::Pop(self); + return self; +} + +CTsTaskMonitorClientImpl* CTsTaskMonitorClientImpl::NewLC() +{ + CTsTaskMonitorClientImpl* self = new (ELeave) CTsTaskMonitorClientImpl; + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +CTsTaskMonitorClientImpl::CTsTaskMonitorClientImpl() : CActive(CActive::EPriorityStandard) +{ + CActiveScheduler::Add(this); +} + +CTsTaskMonitorClientImpl::~CTsTaskMonitorClientImpl() +{ + Cancel(); + iSession.Close(); +} + +void CTsTaskMonitorClientImpl::ConstructL() +{ + User::LeaveIfError(iSession.Connect()); +} + +void CTsTaskMonitorClientImpl::TaskListL(RTsFswArray& tasks) +{ + iSession.TaskListL(tasks); +} + +void CTsTaskMonitorClientImpl::Subscribe(MTsTaskMonitorObserver& aObserver) +{ + Cancel(); + iObserver = &aObserver; + iSession.Subscribe(iStatus); + SetActive(); +} + +void CTsTaskMonitorClientImpl::CancelSubscribe() +{ + Cancel(); +} + +void CTsTaskMonitorClientImpl::RunL() +{ + if (iStatus == KErrNone && iObserver) { + iSession.Subscribe(iStatus); + SetActive(); + iObserver->HandleRunningAppChange(); + } +} + +void CTsTaskMonitorClientImpl::DoCancel() +{ + iSession.CancelSubscribe(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/s60/src/tstaskmonitorsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/s60/src/tstaskmonitorsession.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include + +#include "tstaskmonitorsession.h" +#include "tstaskmonitorglobals.h" + +void RTsTaskMonitorSession::TaskListL(RTsFswArray& tasks) +{ + for (;;) { + TPckgBuf dataSize; + User::LeaveIfError(SendReceive(GetRunningAppInfo, TIpcArgs(&dataSize))); + HBufC8* data = HBufC8::NewLC(dataSize()); + TPtr8 dataPointer(data->Des()); + TInt err = SendReceive(FlushData, TIpcArgs(&dataPointer, dataSize())); + if (err == KErrNone) { + RDesReadStream dataStream(dataPointer); + CleanupClosePushL(dataStream); + CTsFswEntry::InternalizeArrayL(dataStream, tasks); + CleanupStack::PopAndDestroy(&dataStream); + } else if (err != KErrCorrupt) { + User::Leave(err); + } + CleanupStack::PopAndDestroy(data); + if (err == KErrNone) { + break; + } + // If result was KErrCorrupt then the size received from GetRunningAppInfo is + // not valid anymore so restart the whole procedure. + } +} + +TInt RTsTaskMonitorSession::StartServer() +{ + RProcess server; + if (TInt error = server.Create(KRunningAppServerName, KNullDesC, TUidType(KNullUid, KNullUid, KRunningAppServerUid))) { + return error; + } + + TRequestStatus status; + server.Rendezvous(status); + if (status != KRequestPending) { + server.Kill(0); + } else { + server.Resume(); + } + + User::WaitForRequest(status); + TInt error = (EExitPanic == server.ExitType()) ? KErrGeneral : status.Int(); + if (KErrCancel == error) { + error = KErrNone; + } + server.Close(); + + return error; +} + +TInt RTsTaskMonitorSession::Connect() +{ + TInt retry = 4; + TInt error(KErrNone); + do { + error = CreateSession(KRunningAppServerName, TVersion(0, 0, 0)); + if (KErrNotFound != error && KErrServerTerminated != error) { + retry = 0; + } else { + error = StartServer(); + if (KErrNone != error && KErrAlreadyExists != error) { + retry = 0; + error = CreateSession(KRunningAppServerName, TVersion(0, 0, 0)); + } + } + } while (--retry > 0); + return error; +} + +void RTsTaskMonitorSession::Subscribe(TRequestStatus& aStatus) +{ + SendReceive(SubscribeRunningAppChanges, aStatus); +} + +void RTsTaskMonitorSession::CancelSubscribe() +{ + SendReceive(CancelSubscribeRunningAppChanges); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/src/tstaskmonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/src/tstaskmonitor.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "tstaskmonitor.h" +#include "tstaskmonitor_p.h" + +#include "tstask.h" + +TsTaskMonitor::TsTaskMonitor(QObject *parent) : QObject(parent), d_ptr(0) +{ + d_ptr = new TsTaskMonitorPrivate(this); +} + +TsTaskMonitor::~TsTaskMonitor() +{ + delete d_ptr; +} + +QList< QSharedPointer > TsTaskMonitor::taskList() +{ + return d_ptr->taskList(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/stub/inc/tsfswentry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/stub/inc/tsfswentry.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSFSWENTRY_H +#define TSFSWENTRY_H + +class CTsFswEntry +{ +public: + CTsFswEntry(); +}; + +#endif //TSFSWENTRY_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/stub/inc/tstaskmonitor_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/stub/inc/tstaskmonitor_p.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef TSTASKMONITOR_P_H +#define TSTASKMONITOR_P_H + +#include +#include + +#include "tstask.h" + +class TsTaskMonitor; + +class TsTaskMonitorPrivate +{ +public: + TsTaskMonitorPrivate(TsTaskMonitor *q); + +public: + QList< QSharedPointer > taskList(); + +}; + +#endif //TSTASKMONITOR_P_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/stub/src/tsfswentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/stub/src/tsfswentry.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "tsfswentry.h" + +CTsFswEntry::CTsFswEntry() +{ +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/stub/src/tstask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/stub/src/tstask.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "tstask.h" +#include "tsfswentry.h" + +TsTask::TsTask(CTsFswEntry* entry) : mEntry(entry) +{ +} + +TsTask::~TsTask() +{ + delete mEntry; +} + +bool TsTask::isClosable() const +{ + return false; +} + +QPixmap TsTask::icon() const +{ + return QPixmap(); +} + +QString TsTask::name() const +{ + return QString(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/client/stub/src/tstaskmonitor_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/client/stub/src/tstaskmonitor_p.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "tstaskmonitor_p.h" + +TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q) +{ + Q_UNUSED(q); +} + +QList< QSharedPointer > TsTaskMonitorPrivate::taskList() +{ + return QList< QSharedPointer >(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/inc/tstaskmonitorglobals.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/inc/tstaskmonitorglobals.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef RUNNINGAPPGLOBALS_H +#define RUNNINGAPPGLOBALS_H + +#include + +_LIT(KRunningAppServerName, "hsrunningappmonitor"); +const TUid KRunningAppServerUid = {0x200267B0}; +const TInt KRequestDataSizeOffset(0); +const TInt KRequestDataBufferOffset(0); + +enum RunningAppCmd { + GetRunningAppInfo =0, + SubscribeRunningAppChanges, + UpdateScreenshot, + FlushData, + CancelSubscribeRunningAppChanges, +}; + +enum UpdatePriority { + Low = 0, + Normal, + High +}; +#endif //RUNNINGAPPGLOBALS_H + diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/rom.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/rom.pri Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,20 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " +BLD_INF_RULES.prj_exports += "rom/tstaskmonitor_core.iby CORE_APP_LAYER_IBY_EXPORT_PATH(tstaskmonitor_core.iby)" +BLD_INF_RULES.prj_exports += "./sis/stubs/taskmonitor_stub.sis /epoc32/release/winscw/udeb/z/system/install/taskmonitor_stub.sis" +BLD_INF_RULES.prj_exports += "./sis/stubs/taskmonitor_stub.sis /epoc32/data/z/system/install/taskmonitor_stub.sis" diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/rom/tstaskmonitor_core.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/rom/tstaskmonitor_core.iby Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef __TSTASKMONITOR_CORE_IBY__ +#define __TSTASKMONITOR_CORE_IBY__ + +file=ABI_DIR\BUILD_DIR\tstaskmonitorclient.dll SHARED_LIB_DIR\tstaskmonitorclient.dll +file=ABI_DIR\BUILD_DIR\hsrunningappmonitor.exe PROGRAMS_DIR\hsrunningappmonitor.exe + +// stub sis +data=ZSYSTEM/install/taskmonitor_stub.sis system/install/taskmonitor_stub.sis + +#endif //__TSTASKMONITOR_CORE_IBY__ diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/group/bld.inf Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +hsrunningappmonitor.mmp diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/group/hsrunningappmonitor.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/group/hsrunningappmonitor.mmp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +TARGET hsrunningappmonitor.exe +TARGETTYPE exe +UID 0 0x200267B0 + +SYSTEMINCLUDE /epoc32/include + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../utils/inc +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/mw +SYSTEMINCLUDE /epoc32/include/platform/mw +SYSTEMINCLUDE /epoc32/include/platform + +SOURCEPATH ../src +SOURCE main.cpp +SOURCE hsrunningappserver.cpp +SOURCE hsrunningappsession.cpp +SOURCE hsdataobservertask.cpp +SOURCE hsdataprovidertask.cpp + +SOURCE tsrunningappstorage.cpp +SOURCE tsfswdatalist.cpp +SOURCE tsfswengine.cpp +SOURCE tsfswmonitor.cpp + +SOURCEPATH ../../utils/src +SOURCE tsfswentry.cpp + + +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY eikcore.lib +LIBRARY cone.lib +LIBRARY ws32.lib +LIBRARY efsrv.lib +LIBRARY fbscli.lib +LIBRARY avkon.lib +LIBRARY apgrfx.lib +LIBRARY flogger.lib + +LIBRARY apparc.lib +LIBRARY ws32.lib +LIBRARY apgrfx.lib +LIBRARY fbscli.lib +LIBRARY bitgdi.lib +LIBRARY aknicon.lib +LIBRARY aknskins.lib +LIBRARY egul.lib +LIBRARY featmgr.lib +LIBRARY bitmaptransforms.lib +CAPABILITY ALL -TCB +EPOCHEAPSIZE 0x100000 0x600000 // 1MB - 6MB + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/hsdataobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/hsdataobserver.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef DATAOBSERVER_H +#define DATAOBSERVER_H + +#include + +class MHsDataObserver { +public: + virtual void DataChanged() =0; +}; + +class CHsDataObserver: public CBase, + public MHsDataObserver +{ +public: + virtual void Cancel(const RMessage2& reason) =0; +}; + +class MHsDataObserverStorage +{ +public: + virtual void PushL(CHsDataObserver*) =0; + virtual void Pop(CHsDataObserver*) =0; + virtual void Cancel(const RMessage2& reason) =0; +}; + +#endif //DATAOBSERVER_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/hsdataobservertask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/hsdataobservertask.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef DATAOBSERVERTASK_H +#define DATAOBSERVERTASK_H +#include "hsdataobserver.h" +#include +class CHsDataObserverTask: public CHsDataObserver +{ +public: + ~CHsDataObserverTask(); + static void ExecuteLD(MHsDataObserverStorage& storage,const RMessage2& msg); + +private: + CHsDataObserverTask(MHsDataObserverStorage& storage, const RMessage2& msg); + void DataChanged(); + void Cancel(const RMessage2& reason); + +private: + MHsDataObserverStorage& mStorage; + const RMessage2 mMsg; + TBool mDataChanged; +}; +#endif //DATAOBSERVERTASK_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/hsdataprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/hsdataprovider.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef DATAPROVIDR_H +#define DATAPROVIDR_H + +#include + +class MHsDataProvider { +public: + virtual const TDesC8& Data() const = 0; +}; + +#endif //DATAPROVIDR_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/hsdataprovidertask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/hsdataprovidertask.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef DATAPROVIDER_H +#define DATAPROVIDER_H + +#include "hsdataprovider.h" + +class HsDataProviderTask { +public: + static void ExecuteL(const MHsDataProvider& provider, const RMessage2& msg); +}; + +#endif //DATAPROVIDER_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/hsrunningappserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/hsrunningappserver.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef RUNNINGAPPSERVER_H +#define RUNNINGAPPSERVER_H + +// INCLUDES +#include +#include + +#include "hsdataobserver.h" + +class CRunningAppStorage; +/** + * CRunningAppServer + * + */ +class CRunningAppServer : public CServer2, + public MHsDataObserver, + public MHsDataObserverStorage +{ +public: + /** + * Destructor. + */ + ~CRunningAppServer(); + + /** + * Two-phased constructor. + */ + static CRunningAppServer* NewLC(); + +public: //MHsDataObserver + void DataChanged(); + +public: //MHsDataObserverStorage + void PushL(CHsDataObserver*); + void Pop(CHsDataObserver*); + void Cancel(const RMessage2&); + +private: + /** + * Constructor for performing 1st stage construction + */ + CRunningAppServer(); + + /** + * Default constructor for performing 2nd stage construction + */ + void ConstructL(); + + /** + * Interface implementation + * @see CServer2::NewSessionL(const TVersion&, const RMessage2&) + */ + CSession2* NewSessionL(const TVersion& version, const RMessage2& message) const; +private: + RPointerArray mObservers; + CRunningAppStorage* mStorage; +}; + +#endif // RUNNINGAPPSERVER_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/hsrunningappsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/hsrunningappsession.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef RUNNINGAPPSESSION_H +#define RUNNINGAPPSESSION_H + +// INCLUDES +#include +#include +#include "hsdataobserver.h" +#include "hsdataprovider.h" +/** + * CActivitySession + * + */ +class CRunningAppSession : public CSession2 +{ +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~CRunningAppSession(); + + /** + * Two-phased constructor. + * @param fileSession - initialized file system session + * @param taskStorage - global observers storage + * @param storage - data storage + */ + static CRunningAppSession* NewL(MHsDataObserverStorage& observerStorage, + const MHsDataProvider& dataProvider); + +private: + + /** + * Constructor for performing 1st stage construction + */ + CRunningAppSession(MHsDataObserverStorage& observerStorage, + const MHsDataProvider& dataProvider); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + +private: + /** + * Implements interface + * @see void CSession2::ServiceL(const RMessage2&) + */ + void ServiceL(const RMessage2& message); + +private: + MHsDataObserverStorage& mObserverStorage; + const MHsDataProvider& mDataProvider; +}; + +#endif // RUNNINGAPPSESSION_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/tsfswdatalist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/tsfswdatalist.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,256 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Non-closeable app list class + * +*/ + + +#ifndef TSFSWDATALIST_H +#define TSFSWDATALIST_H + +#define __E32SVR_H__ +#include +#include + +#include +#include +#include +#include +#include +#include "tsfswentry.h" +#include "tsfswobservers.h" + +class CTsFswEngine; +class CTsFswIconCache; +class CApaWindowGroupName; +class CFbsBitmap; + +/** + * Engine's data list. + */ +NONSHARABLE_CLASS( CTsFswDataList ) : public CBase + { +public: + /** + * Two-phased constructor. + * + * @param aParent + */ + static CTsFswDataList* NewL( CTsFswEngine& aEngine ); + + /* + * Destructor + */ + ~CTsFswDataList(); + +private: + /** + * Constructor. + */ + CTsFswDataList( CTsFswEngine& aEngine ); + + /** + * Performs 2nd phase construction. + */ + void ConstructL(); + +public: + /** + * Returns a reference to the current content. + * Also performs sanity checks, e.g. associates application icons + * when no screenshot has been received. + * @return ref to content array + */ + const RTsFswArray& FswDataL(); + + /** + * Gets the window group list and reconstructs the fsw content. + * @return TBool ETrue if the content iData has been modified + */ + TBool CollectTasksL(); + + + /** + * Set flag iTaskListDirty; + */ + void SetDirty(); + + /** + * Set flag iAppDataRefreshNeeded + */ + void SetAppDataRefreshNeeded(); + + + /** + * Moves entry on given window app/widget id to + * the first position on conten data list + */ + void MoveEntryAtStart( TInt aAppId, TBool aWidget ); + + + /** + * Finds out the app uid for the given window group id. + * @param aWgId a valid window group id + * @param aUid requested uid + * @return error code + */ + TInt AppUidForWgId( TInt aWgId, TUid& aUid ); + + /** + * Finds out the app uid for the given window group id. + * @param aWgId a valid window group id + * @return application uid + */ + TUid AppUidForWgIdL( TInt aWgId ); + + /** + * Checks if given uid is on hidden list + * @param aUid uid to be checked + * @return ETrue if aUid is on hidden list + */ + TBool IsHiddenUid( TUid aUid ); + +private: + /** + * Adds running apps to the list. + * @param aAppsList array to add to + */ + void CollectAppsL( RTsFswArray& aAppsList ); + + /** + * Called from CollectTasksL for each entry in the task list. + * @param aWgId window group id + * @param aAppUid application uid + * @param aWgName window group name or NULL + * @param aNewList list to add to + * @param aIsWidget true if the entry corresponds to a web widget + * @return TBool ETrue if it was really a new entry in the list + */ + TBool AddEntryL( TInt aWgId, + const TUid& aAppUid, + CApaWindowGroupName* aWgName, + RTsFswArray& aNewList, + TBool aIsWidget ); + + /** + * Checks if there is an entry for same app in the content list. + * If yes then it takes some of the data for the entry that + * will correspond to the same app in the refreshed content list. + * In case of widget, update window group field in content list. + * @param aEntry new entry in content list + * @param aAppUid application uid + * @param aChanged ref to change-flag, set to ETrue if it is sure + * that the new content list will be different from the previous one + * @param aNewList ref to new content list + * @return ETrue if app was found + */ + TBool ConsiderOldDataL( CTsFswEntry& aEntry, + const TUid& aAppUid, + TBool& aChanged, + RTsFswArray& aNewList ); + + /** + * Adds running widgets to the list. + * @param aWidgetsList array to add to + */ + void CollectWidgetsL( RTsFswArray& aWidgetsList ); + + /** + * Returns the parent's wg id or KErrNotFound. + * @param aWgId a valid window group id + * @return parent wg id or KErrNotFound if there is no parent + */ + TInt FindParentWgId( TInt aWgId ); + + /** + * Returns the most top parent's wg id or KErrNotFound. + * @param aWgId a valid window group id + * @return parent wg id or KErrNotFound if there is no parent + */ + TInt FindMostTopParentWgId( TInt aWgId ); + + /** + * Finds out the application name. + * @param aWindowName window group name or NULL + * @param aAppUId application uid + * @param aWgId window group id + * @return application name, ownership transferred to caller + */ + HBufC* FindAppNameLC( CApaWindowGroupName* aWindowName, + const TUid& aAppUid, + TInt aWgId ); + + + /** + * Fit existing class contained data list into give one. + * Data is being changed with application type consideration that is based + * on aConsiderWidgets param. + * Function removes or add entries into data depend on given list. + * @param aListToFit list with actual data + * @param aConsiderWidgets application type + * @return ETrue if change occours on data list, EFalse otherwise + */ + TBool FitDataToListL( RTsFswArray& aListToFit, TBool aConsiderWidgets ); + + /** + * Checks if there is an entry for same app in the given list. + * @param aEntry entry + * @param aNewList ref to list + * @return ETrue if app was found + */ + TBool CheckIfExists( const CTsFswEntry& aEntry, + const RTsFswArray& aNewList ) const; + + /** + * Retrieves the bitmap/mask for the icon of the given app. + * @param aAppUid application uid + * @param aBitmap bitmap ptr, ownership transferred to caller, or NULL + * @param aMask mask ptr, ownership transferred to caller, or NULL + */ + void GetAppIconL( const TUid& aAppUid, + CFbsBitmap*& aBitmap, CFbsBitmap*& aMask ); + + +private: + CTsFswEngine& iEngine; + + RTsFswArray iData; // current fsw content, i.e. the task list + + // window server session + RWsSession iWsSession; + + // apparc session + RApaLsSession iAppArcSession; + + + + + // when true CollectTasksL will call GetAllApps etc. + // which is slow and need not be done normally, except + // during startup and perhaps when new applications are installed + TBool iAppDataRefreshNeeded; + + // Dirty flag, indicates that iData is not up-to-date because + // there were no subscribed clients during a previous possible + // change of the task list. + TBool iTaskListDirty; + + // if ETrue application order has been changed + TBool iOrderChanged; + + // list of hidden uids + RArray iHiddenUids; + }; + +#endif //TSFSWDATALIST_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/tsfswengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/tsfswengine.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,178 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task monitor engine + * +*/ + + +#ifndef TSFSWENGINE_H +#define TSFSWENGINE_H + +#define __E32SVR_H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tsfswentry.h" +#include "tsfswobservers.h" +#include "hsdataprovider.h" +#include "hsdataobserver.h" + +class MTsFswEngineObserver; +class CTsFastSwapPreviewProvider; +class CApaWindowGroupName; +class CBitmapRotator; +class CTsRotationTask; +class CTSCpsNotifier; + +class CTsFswDataList; + +// descriptor big enough to store hex repr of 32-bit integer plus 0x prefix +typedef TBuf<10> TAppUidHexString; + +/** + * Engine for fast swap server. + * Performs task monitoring, notifications about wg changes are + * received from the appui. + */ +NONSHARABLE_CLASS( CTsFswEngine ) : public CBase, + public MTsFswTaskListObserver + + { + enum TTsFswFgAppType + { + /** + * Means that even when the foreground app has another app embedded + * into it the uid of the container application will be returned. + */ + EUseStandaloneUid, + /** + * Means that if the foreground app has another app embedded + * into it then the returned uid will be the uid of the embedded + * app. + */ + EUseEmbeddedUid + }; + +public: + /** + * Creates a new instance. + * @param aObserver ref to observer + */ + static CTsFswEngine* NewL( MHsDataObserver& aObserver ); + + /** + * @copydoc NewL + */ + static CTsFswEngine* NewLC( MHsDataObserver& aObserver ); + + /** + * Destructor. + */ + ~CTsFswEngine(); + + /** + * Returns a reference to the current content. + * Also performs sanity checks, e.g. associates application icons + * when no screenshot has been received. + * @return ref to content array + */ + const RTsFswArray& FswDataL(); + + + + +private: + + // from MTsFswTaskListObserver + void UpdateTaskList(); + + + +private: + /** + * Constructor. + */ + CTsFswEngine( MHsDataObserver& aObserver ); + + /** + * Performs 2nd phase construction. + */ + void ConstructL(); + + /** + * Gets the window group list and reconstructs the fsw content. + * @return TBool ETrue if the list has been modified + */ + TBool CollectTasksL(); + + + /** + * Callback for the iUpdateStarter timer. + * Calls CollectTasksL and notifies the observer if the task list + * has really been modified. + */ + static TInt UpdateStarterCallback( TAny* aParam ); + + /** + * Returns the uid of the foreground app or KNullUid. + * Will never return hidden apps, only those which can + * also be seen in the array returned by FswDataL. + * + * In case of embedded apps the behaviour is controlled + * by aType: it will return either the uid of the embedded + * application or the container app. + * + * @param aType @see CTsFswClient::TTsFswFgAppType + */ + TUid ForegroundAppUidL( TInt aType ); + + /** + * Gets and publishes the foreground app uid to CFW. + */ + void PublishFgAppUidL(); + +private: + // data + MHsDataObserver& iObserver; + + // window server session + RWsSession iWsSession; + + // apparc session + RApaLsSession iAppArcSession; + + // timer to defer content refresh + CPeriodic* iUpdateStarter; + + + // window group ids returned by last WindowGroupList call + RArray iWgIds; + + TUid iFgAppUid; + + + CTsFswDataList* iDataList;//own + + }; + +#endif diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/tsfswmonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/tsfswmonitor.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Monitor for server + * +*/ + + +#ifndef TSFSWMONITOR_H +#define TSFSWMONITOR_H +#define __E32SVR_H__ + +#include +#include +#include + +class MTsFswTaskListObserver; +class MTsFswResourceObserver; + +/** + * Monitor for the fsw server. + * Reimplements HandleWsEventL from base class to get notifications about + * window group changes. + */ +class CTsFswMonitor : public CActive + { +public: + ~CTsFswMonitor(); + + + +static CTsFswMonitor* NewL(MTsFswTaskListObserver& aTaskListObserver); +static CTsFswMonitor* NewLC(MTsFswTaskListObserver& aTaskListObserver); + +protected: + CTsFswMonitor(MTsFswTaskListObserver& aTaskListObserver); + void ConstructL(); + + // from CActive + void RunL(); + TInt RunError( TInt aError ); + void DoCancel(); + + +private: + void Subscribe(); + void ConstractObserverL(); +private: + MTsFswTaskListObserver* iTaskListObserver; // not own + + // window server session + RWsSession iWsSession; + /** + * Window group. + */ + RWindowGroup iWg; + }; + +#endif //TSFSWMONITOR_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/tsfswobservers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/tsfswobservers.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer interfaces to get notifications from appui and from engine + * +*/ + + +#ifndef TSFSWOBSERVERS_H +#define TSFSWOBSERVERS_H + +/** + * Interface to get notifications from appui when window groups + * have changed. + */ +class MTsFswTaskListObserver + { +public: + /** + * Function called by AppUi to notify about possible + * changes in task list + */ + virtual void UpdateTaskList() = 0; + }; +#endif diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/inc/tsrunningappstorage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/inc/tsrunningappstorage.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef RUNNINGAPPSTORAGE_H +#define RUNNINGAPPSTORAGE_H + +// INCLUDES +#include +#include + +#include "hsdataobserver.h" +#include "hsdataprovider.h" + +class CTsFswEngine; +class CTsFswMonitor; +/** + * CRunningAppServer + * + */ +class CRunningAppStorage : public CBase, + public MHsDataProvider, + public MHsDataObserver + +{ +public: + /** + * Destructor. + */ + ~CRunningAppStorage(); + + /** + * Two-phased constructor. + */ + static CRunningAppStorage* NewL(MHsDataObserver& observer); + +public: //MHsDataObserver + const TDesC8& Data() const; + + //MHsDataChangeProvider + void DataChanged(); + +private: + /** + * Constructor for performing 1st stage construction + */ + CRunningAppStorage(MHsDataObserver& observer); + + /** + * Default constructor for performing 2nd stage construction + */ + void ConstructL(); + + void DataChangedL(); + +private: + MHsDataObserver& mObserver; + RBuf8 mData; + + CTsFswEngine* mEngine; + CTsFswMonitor* mMonitor; + +}; + +#endif // RUNNINGAPPSERVER_H diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/server.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/server.pro Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,20 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = subdirs + +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"group/bld.inf\"" + diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/hsdataobservertask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/hsdataobservertask.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "hsdataobservertask.h" +#include "tstaskmonitorglobals.h" +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CHsDataObserverTask::CHsDataObserverTask(MHsDataObserverStorage& storage, + const RMessage2& msg) +: + mStorage(storage), + mMsg(msg) +{ + // No implementation required +} + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CHsDataObserverTask::~CHsDataObserverTask() +{ + if (EFalse == mMsg.IsNull()) { + mMsg.Complete(mDataChanged ? KErrNone : KErrCancel); + } +} +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CHsDataObserverTask::ExecuteLD(MHsDataObserverStorage& storage,const RMessage2& msg) +{ + CHsDataObserver *self = new (ELeave)CHsDataObserverTask(storage, msg); + CleanupStack::PushL(self); + storage.PushL(self); + CleanupStack::Pop(self); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CHsDataObserverTask::DataChanged() +{ + mDataChanged = ETrue; + mStorage.Pop(this); + delete this; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CHsDataObserverTask::Cancel(const RMessage2& reason) +{ + if (CancelSubscribeRunningAppChanges == reason.Function() && + mMsg.Session() == reason.Session()) { + mStorage.Pop(this); + delete this; + } +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/hsdataprovidertask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/hsdataprovidertask.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "hsdataprovidertask.h" +#include "tstaskmonitorglobals.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void HsDataProviderTask::ExecuteL(const MHsDataProvider& provider, const RMessage2& msg) +{ + switch (msg.Function()) { + case GetRunningAppInfo: + msg.WriteL(KRequestDataSizeOffset, TPckgBuf(provider.Data().Length())); + msg.Complete(KErrNone); + break; + + case FlushData: + if (provider.Data().Length() > msg.GetDesMaxLengthL(KRequestDataBufferOffset)) { + User::Leave(KErrCorrupt); + } + msg.WriteL(KRequestDataBufferOffset, provider.Data()); + msg.Complete(KErrNone); + break; + } +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/hsrunningappserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/hsrunningappserver.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "tstaskmonitorglobals.h" +#include "hsrunningappserver.h" +#include "hsrunningappsession.h" +#include "tsrunningappstorage.h" + +_LIT(KErrObserverExists, "Observer already exists"); +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppServer::CRunningAppServer() +: +CServer2(EPriorityStandard) +{ + // No implementation required +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppServer::~CRunningAppServer() +{ + delete mStorage; + mObservers.ResetAndDestroy(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppServer* CRunningAppServer::NewLC() +{ + CRunningAppServer* self = new (ELeave) CRunningAppServer(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppServer::ConstructL() +{ + StartL(KRunningAppServerName); + mStorage = CRunningAppStorage::NewL(*this); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CSession2* CRunningAppServer::NewSessionL(const TVersion &, const RMessage2&) const +{ + return CRunningAppSession::NewL(*const_cast(this), + *const_cast(this)->mStorage); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppServer::DataChanged() +{ + while (0 < mObservers.Count()) { + mObservers[0]->DataChanged(); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppServer::PushL(CHsDataObserver* observer) +{ + ( 0 <= mObservers.Find(observer)) ? + User::Panic(KErrObserverExists, KErrAlreadyExists) : + mObservers.AppendL(observer); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppServer::Pop(CHsDataObserver* observer) +{ + const TInt offset(mObservers.Find(observer)); + if(0 <= offset) { + mObservers.Remove(offset); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppServer::Cancel(const RMessage2& reason) +{ + for (TInt iter(mObservers.Count() - 1); 0 <= iter; --iter) { + mObservers[iter]->Cancel(reason); + } + reason.Complete(KErrNone); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/hsrunningappsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/hsrunningappsession.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "hsrunningappsession.h" +#include "tstaskmonitorglobals.h" + +#include "hsdataobservertask.h" +#include "hsdataprovidertask.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppSession::CRunningAppSession(MHsDataObserverStorage& observerStorage, + const MHsDataProvider& dataProvider) +: + mObserverStorage(observerStorage), + mDataProvider(dataProvider) +{ + // No implementation required +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppSession::~CRunningAppSession() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppSession* CRunningAppSession::NewL(MHsDataObserverStorage& observerStorage, + const MHsDataProvider& dataProvider) +{ + CRunningAppSession* self = new (ELeave) CRunningAppSession(observerStorage, dataProvider); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppSession::ConstructL() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppSession::ServiceL(const RMessage2& message) +{ + switch (message.Function()) { + case SubscribeRunningAppChanges: + CHsDataObserverTask::ExecuteLD(mObserverStorage, message); + break; + + case CancelSubscribeRunningAppChanges: + mObserverStorage.Cancel(message); + break; + + case GetRunningAppInfo: + case FlushData: + HsDataProviderTask::ExecuteL(mDataProvider, message); + break; + + default: + message.Complete(CServer2::EBadMessageNumber); + } +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/main.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "hsrunningappserver.h" +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +LOCAL_C void StartRunningAppServerL() +{ + CActiveScheduler* activeScheduler = new( ELeave ) CActiveScheduler; + CleanupStack::PushL( activeScheduler ); + CActiveScheduler::Install( activeScheduler ); + CServer2* serverObject = CRunningAppServer::NewLC(); + RProcess::Rendezvous( KErrNone ); + CActiveScheduler::Start(); + CleanupStack::PopAndDestroy( serverObject ); + CleanupStack::PopAndDestroy( activeScheduler ); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +LOCAL_C TInt StartRunningAppServer() +{ + __UHEAP_MARK; + TInt errNo(KErrNoMemory); + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + if (cleanupStack) { + TRAP(errNo, StartRunningAppServerL()); + delete cleanupStack; + } + __UHEAP_MARKEND; + if (KErrNone != errNo) { + RProcess::Rendezvous(errNo); + } + return errNo; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +TInt E32Main() +{ + return StartRunningAppServer(); +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/tsfswdatalist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/tsfswdatalist.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,570 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: File containing application list classes + * +*/ + + +//INCLUDES: +#define __E32SVR_H__ +#include "tsfswdatalist.h" +#include "tsfswengine.h" +#include // for CleanupResetAndDestroyPushL +#include +#include +#include +#include +#include +#include +#include // avkon +#include // fbsbitmap +#include + +// size for the created app icons +const TInt KAppIconWidth = 128; +const TInt KAppIconHeight = 128; + +//uids to be hidden +const TUid KHsApplicationUid = {0x20022F35}; +const TUid KTelephoneUid = {0x100058B3}; + +// ================= MEMBER FUNCTIONS ======================= + +// -------------------------------------------------------------------------- +// CTsFswDataList::NewL +// -------------------------------------------------------------------------- +// +CTsFswDataList* CTsFswDataList::NewL(CTsFswEngine& aEngine) + { + CTsFswDataList* self = new (ELeave) CTsFswDataList(aEngine); + CleanupStack::PushL (self ); + self->ConstructL ( ); + CleanupStack::Pop ( self ); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::CTsFswDataList +// -------------------------------------------------------------------------- +// +CTsFswDataList::CTsFswDataList(CTsFswEngine& aEngine) : + iEngine(aEngine) + { + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::~CTsFswDataList +// -------------------------------------------------------------------------- +// +CTsFswDataList::~CTsFswDataList( ) + { + iData.ResetAndDestroy(); + iAppArcSession.Close(); + iWsSession.Close(); + iHiddenUids.Close(); + RFbsSession::Disconnect(); + RAknIconSrvClient::Disconnect(); + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::ConstructL +// -------------------------------------------------------------------------- +// +void CTsFswDataList::ConstructL( ) + { + User::LeaveIfError( iWsSession.Connect() ); + User::LeaveIfError( iAppArcSession.Connect() ); + iHiddenUids.AppendL( KHsApplicationUid ); + iHiddenUids.AppendL( KTelephoneUid ); + User::LeaveIfError(RFbsSession::Connect()); + RAknIconSrvClient::Connect(); + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::FswDataL +// -------------------------------------------------------------------------- +// +const RTsFswArray& CTsFswDataList::FswDataL() + { + // check the dirty flag and refresh if needed + if ( iTaskListDirty ) + { + CollectTasksL(); + // dirty flag is cleared in the above call + } + + return iData; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::CollectTasksL +// -------------------------------------------------------------------------- +// +TBool CTsFswDataList::CollectTasksL() + { + // clear dirty flag + iTaskListDirty = EFalse; + TBool changed = EFalse; + + RTsFswArray newAppsList; + + CleanupResetAndDestroyPushL(newAppsList); + + CollectAppsL(newAppsList); + + changed |= FitDataToListL(newAppsList, EFalse); + + CleanupStack::PopAndDestroy( &newAppsList ); + + return changed; + } + + +// -------------------------------------------------------------------------- +// CTsFswDataList::SetDirty() +// -------------------------------------------------------------------------- +// +void CTsFswDataList::SetDirty() + { + iTaskListDirty = ETrue; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::SetAppDataRefreshNeeded() +// -------------------------------------------------------------------------- +// +void CTsFswDataList::SetAppDataRefreshNeeded() + { + iAppDataRefreshNeeded = ETrue; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::MoveEntryAtStart +// -------------------------------------------------------------------------- +// +void CTsFswDataList::MoveEntryAtStart(TInt aAppId, TBool /*aWidget*/) + { + TInt appId(0); + //check embeded case + + TInt wgId(0); + CApaWindowGroupName::FindByAppUid(TUid::Uid(aAppId), iWsSession, wgId); + TInt parentWgId = FindMostTopParentWgId( wgId ); + if( parentWgId != KErrNotFound ) + { + TUid appUid = TUid::Uid(0); + AppUidForWgId(parentWgId, appUid); + appId = appUid.iUid; + } + + + if( !appId ) + { + appId = aAppId; + } + + for ( TInt i = 0; i < iData.Count(); ++i ) + { + if( iData[i]->AppUid().iUid == appId ) + { + CTsFswEntry* entry = iData[i]; + iData.Remove(i); + iData.Insert(entry, 0); + iOrderChanged = ETrue; + break; + } + } + } + +// -------------------------------------------------------------------------- +// CTsFswDataList:: +// -------------------------------------------------------------------------- +// +void CTsFswDataList::CollectAppsL(RTsFswArray& aAppsList) + { + + + // update app data if needed + // (usually on startup and when new apps might have been installed) + if ( iAppDataRefreshNeeded ) + { + + iAppArcSession.GetAllApps(); + iAppDataRefreshNeeded = EFalse; + } + + // get all window groups + RArray allWgIds; + CleanupClosePushL( allWgIds ); + User::LeaveIfError( iWsSession.WindowGroupList( 0, &allWgIds ) ); + + TInt count = allWgIds.Count(); + for ( TInt i = 0; i < count; ++i ) + { + // ignore uninteresting entries (e.g. embedded apps) + if ( allWgIds[i].iParentId > 0 ) + { + continue; + } + + // get window group name + TInt wgId = allWgIds[i].iId; + CApaWindowGroupName* windowName = + CApaWindowGroupName::NewLC( iWsSession, wgId ); + TUid appUid = windowName->AppUid(); + + // ignore entries with null uid + if ( !appUid.iUid ) + { + CleanupStack::PopAndDestroy( windowName ); + continue; + } + + // add item to task list if it is not hidden + if ( !windowName->Hidden() && !IsHiddenUid(appUid) ) + { + AddEntryL(wgId, appUid, windowName, aAppsList, EFalse); + } + CleanupStack::PopAndDestroy( windowName ); + } + CleanupStack::PopAndDestroy( &allWgIds ); + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::AddEntryL +// -------------------------------------------------------------------------- +// +TBool CTsFswDataList::AddEntryL( TInt aWgId, const TUid& aAppUid, + CApaWindowGroupName* aWgName, RTsFswArray& aNewList, + TBool /*aIsWidget*/ ) + { + TBool changed = EFalse; + CTsFswEntry* entry = CTsFswEntry::NewLC(); + entry->SetWgId( aWgId ); + entry->SetAppUid( aAppUid ); + + // check if present in old list and if yes then take some of the old data + TBool found = ConsiderOldDataL( *entry, aAppUid, changed, aNewList ); + + // if not present previously then find out app name + // and check if screenshot is already available + if ( !found ) + { + // when adding a new entry to the list it is changed for sure + changed = ETrue; + HBufC* name = FindAppNameLC( aWgName, aAppUid, aWgId ); + if ( name ) + { + entry->SetAppNameL( *name ); + } + CleanupStack::PopAndDestroy( name ); + + if ( aWgName ) + { + entry->SetCloseableApp( !aWgName->IsSystem() ); + } + CFbsBitmap* iconBitmap = NULL; + CFbsBitmap* iconMask = NULL; + GetAppIconL(aAppUid, iconBitmap, iconMask); + //transfer ownership to entry + entry->SetAppIcon( iconBitmap, iconMask ); + } + + // add to new list, ownership is transferred + aNewList.AppendL( entry ); + CleanupStack::Pop( entry ); + return changed; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::ConsiderOldDataL +// -------------------------------------------------------------------------- +// +TBool CTsFswDataList::ConsiderOldDataL( CTsFswEntry& aEntry, + const TUid& aAppUid, + TBool& aChanged, + RTsFswArray& aNewList ) + { + for ( TInt entryIdx = 0, oldCount = iData.Count(); + entryIdx < oldCount; ++entryIdx ) + { + // Enough to check appuid, no need to bother with wgid as the + // screenshot handle is up-to-date or will be updated later anyway. + if ( iData[entryIdx]->AppUid() == aAppUid ) + { + iData[entryIdx]->SetWgId( aEntry.WgId()); + // if positions do not match then the list is different than before + if ( entryIdx != aNewList.Count() ) + { + aChanged = ETrue; + } + CTsFswEntry* oldEntry = iData[entryIdx]; + aEntry.SetAppNameL( oldEntry->AppName() ); + aEntry.SetCloseableApp( oldEntry->CloseableApp() ); + return ETrue; + } + } + return EFalse; + } + + +// -------------------------------------------------------------------------- +// CTsFswDataList::FindParentWgId +// -------------------------------------------------------------------------- +// +TInt CTsFswDataList::FindParentWgId( TInt aWgId ) + { + TInt parent( KErrNotFound ); + RArray allWgIds; + // Ask for window group list from RWsSession + TInt error = iWsSession.WindowGroupList( 0, &allWgIds ); + if ( !error ) + { + TInt count( allWgIds.Count() ); + for ( TInt i( 0 ); i < count; i++ ) + { + RWsSession::TWindowGroupChainInfo info = allWgIds[i]; + if ( info.iId == aWgId && info.iParentId > 0) + { + parent = info.iParentId; + break; + } + } + } + allWgIds.Close(); + return parent; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::FindMostTopParentWgId +// -------------------------------------------------------------------------- +// +TInt CTsFswDataList::FindMostTopParentWgId( TInt aWgId ) + { + TInt parent( KErrNotFound ); + parent = FindParentWgId( aWgId ); + if( parent != KErrNotFound) + { + TInt topParent = FindMostTopParentWgId(parent); + if( topParent != KErrNotFound ) + { + parent = topParent; + } + } + return parent; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::FindAppNameLC +// -------------------------------------------------------------------------- +// +HBufC* CTsFswDataList::FindAppNameLC( CApaWindowGroupName* aWindowName, + const TUid& aAppUid, + TInt aWgId ) + { + //Retrieve the app name + TApaAppInfo info; + iAppArcSession.GetAppInfo( info, aAppUid ); + TPtrC caption = info.iShortCaption; + + HBufC* tempName = 0; + if ( !caption.Length() && aWindowName ) // if not set - use thread name instead + { + if ( aWindowName->Caption().Length() ) + { + tempName = aWindowName->Caption().AllocL(); + //put on cleanupstack after the if + } + else + { + TThreadId threadId; + TInt err = iWsSession.GetWindowGroupClientThreadId( + aWgId, threadId ); + if ( err == KErrNone ) + { + RThread thread; + CleanupClosePushL( thread ); + err = thread.Open ( threadId ); + if ( err==KErrNone ) + { + tempName = thread.Name().AllocL(); // codescanner::forgottoputptroncleanupstack + // tempName put on cleanupstack after the if + } + CleanupStack::PopAndDestroy( &thread ); + } + } + } + else + { + tempName = caption.AllocL(); + //put on cleanupstack after the if + } + CleanupStack::PushL( tempName ); + return tempName; + } + + +// -------------------------------------------------------------------------- +// CTsFswDataList::FitDataToListL +// -------------------------------------------------------------------------- +// +TBool CTsFswDataList::FitDataToListL(RTsFswArray& aListToFit, + TBool /*aConsiderWidgets*/) + { + TBool changed = EFalse; + TInt listCount = aListToFit.Count(); + TInt dataCount = iData.Count(); + + + //remove items that dont't exists in newly collected list + for (TInt i = dataCount -1; i >= 0; --i) + { + if ( !CheckIfExists(*iData[i], aListToFit) ) + { + delete iData[i]; + iData.Remove(i); + changed = ETrue; + } + } + + //add new item at start + //for (TInt i = 0; i < aListToFit.Count(); ++i) + for (TInt i = aListToFit.Count()-1; i >= 0; --i) + { + if (!CheckIfExists(*aListToFit[i], iData)) + { + iData.Insert(aListToFit[i], 0); + aListToFit[i] = 0; + changed = ETrue; + } + } + changed = changed || iOrderChanged; + iOrderChanged = EFalse; + return changed; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::CheckIfExists +// -------------------------------------------------------------------------- +// +TBool CTsFswDataList::CheckIfExists(const CTsFswEntry& aEntry, + const RTsFswArray& aList) const + { + TBool exists(EFalse); + TInt dataCount = aList.Count(); + for (TInt entryIdx = 0; entryIdx < dataCount; ++entryIdx) + { + if (aList[entryIdx]->AppUid() == aEntry.AppUid()) + { + exists = ETrue; + break; + } + } + return exists; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::AppUidForWgId +// -------------------------------------------------------------------------- +// +TInt CTsFswDataList::AppUidForWgId( TInt aWgId, TUid& aUid ) + { + TRAPD(err, aUid = AppUidForWgIdL( aWgId ) ); + return err; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::AppUidForWgIdL +// -------------------------------------------------------------------------- +// +TUid CTsFswDataList::AppUidForWgIdL( TInt aWgId ) + { + CApaWindowGroupName* windowName = + CApaWindowGroupName::NewLC( iWsSession, aWgId ); + TUid appUid = windowName->AppUid(); + CleanupStack::PopAndDestroy( windowName ); + return appUid; + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::GetAppIconL +// -------------------------------------------------------------------------- +// +void CTsFswDataList::GetAppIconL( const TUid& aAppUid, + CFbsBitmap*& aBitmap, CFbsBitmap*& aMask ) + { + aBitmap = aMask = NULL; + + TSize size( KAppIconWidth, KAppIconHeight ); + CApaMaskedBitmap* apaMaskedBitmap = CApaMaskedBitmap::NewLC(); + TInt err = iAppArcSession.GetAppIcon( aAppUid, size, *apaMaskedBitmap ); + TInt iconsCount(0); + if ( err == KErrNone ) + { + err = iAppArcSession.NumberOfOwnDefinedIcons(aAppUid, iconsCount); + } + + if ( (err == KErrNone) && (iconsCount>0) ) + { + aBitmap = static_cast(apaMaskedBitmap); + TInt maskHandle = apaMaskedBitmap->Mask()->Handle(); + aMask = new (ELeave) CFbsBitmap; + aMask->Duplicate( maskHandle ); + CleanupStack::Pop( apaMaskedBitmap ); + } + else + { + CleanupStack::PopAndDestroy( apaMaskedBitmap ); + HBufC* fileNameFromApparc = NULL; + TInt err = iAppArcSession.GetAppIcon(aAppUid,fileNameFromApparc); + if ( err == KErrNone ) + { + CleanupStack::PushL(fileNameFromApparc); + CFbsBitmap *bitamp(0); + CFbsBitmap *mask(0); + TInt bitmapIndex = 0; + TInt maskIndex = 1; + // it will change bitmap ids if it is mif (checking inside) + AknIconUtils::ValidateLogicalAppIconId( *fileNameFromApparc, bitmapIndex, maskIndex ); + AknIconUtils::CreateIconLC( bitamp, mask, fileNameFromApparc->Des(), bitmapIndex, maskIndex ); + + if (AknIconUtils::IsMifFile(*fileNameFromApparc)) \ + { + AknIconUtils::DisableCompression(bitamp); + AknIconUtils::SetSize(bitamp, TSize(KAppIconWidth, KAppIconHeight), EAspectRatioPreservedAndUnusedSpaceRemoved); + // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order + CleanupStack::Pop(2); + aBitmap = bitamp; + aMask = mask; + } + else + { + CleanupStack::PopAndDestroy(2); + } + CleanupStack::PopAndDestroy(fileNameFromApparc); + } + } + } + +// -------------------------------------------------------------------------- +// CTsFswDataList::GetAppIconL +// -------------------------------------------------------------------------- +// +TBool CTsFswDataList::IsHiddenUid( TUid aUid ) + { + TInt result = iHiddenUids.Find( aUid ); + return result >= 0 ? ETrue : EFalse; + } + +// end of file diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/tsfswengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/tsfswengine.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,221 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task monitor engine + * +*/ + + +#include "tsfswengine.h" + +#include "tsfswdatalist.h" + + + + +#include +#include +#include +#include // for CleanupResetAndDestroyPushL +#include +#include +#include +#include + +// time to wait before refreshing content +const TInt KContentRefreshDelay = 50000; // 0.05 sec + + +// -------------------------------------------------------------------------- +// CTsFswEngine::NewL +// -------------------------------------------------------------------------- +// +CTsFswEngine* CTsFswEngine::NewL( MHsDataObserver& aObserver ) + { + CTsFswEngine* self = NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::NewLC +// -------------------------------------------------------------------------- +// +CTsFswEngine* CTsFswEngine::NewLC( MHsDataObserver& aObserver ) + { + CTsFswEngine* self = new ( ELeave ) CTsFswEngine( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::CTsFswEngine +// -------------------------------------------------------------------------- +// +CTsFswEngine::CTsFswEngine( MHsDataObserver& aObserver ) + :iObserver( aObserver ) + { + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::ConstructL +// -------------------------------------------------------------------------- +// +void CTsFswEngine::ConstructL() + { + User::LeaveIfError( iWsSession.Connect() ); + User::LeaveIfError( iAppArcSession.Connect() ); + + iDataList = CTsFswDataList::NewL(*this); + + // get an initial list of tasks + iDataList->SetAppDataRefreshNeeded(); + CollectTasksL(); + + iUpdateStarter = CPeriodic::NewL( CActive::EPriorityStandard ); + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::~CTsFswEngine +// -------------------------------------------------------------------------- +// +CTsFswEngine::~CTsFswEngine() + { + + delete iUpdateStarter; + + iWgIds.Close(); + + iAppArcSession.Close(); + iWsSession.Close(); + + delete iDataList; + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::FswDataL +// -------------------------------------------------------------------------- +// +const RTsFswArray& CTsFswEngine::FswDataL() + { + return iDataList->FswDataL(); + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::UpdateTaskList +// Callback from appui +// -------------------------------------------------------------------------- +// +void CTsFswEngine::UpdateTaskList() + { + // There can be many calls in a row, use a timer to prevent degrading + // device performance. + iDataList->SetDirty(); + if ( !iUpdateStarter->IsActive() ) + { + iUpdateStarter->Start( KContentRefreshDelay, 0, + TCallBack( UpdateStarterCallback, this ) ); + } + // get the foreground app uid and publish it to CFW if different than before + TRAP_IGNORE( PublishFgAppUidL() ); + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::UpdateStarterCallback +// Callback for the timer +// -------------------------------------------------------------------------- +// +TInt CTsFswEngine::UpdateStarterCallback( TAny* aParam ) + { + CTsFswEngine* self = static_cast( aParam ); + self->iUpdateStarter->Cancel(); + // get list of tasks and notify observer if there is a change in the list + TBool changed = EFalse; + TRAPD( err, changed = self->CollectTasksL() ); + if ( err == KErrNone && changed ) + { + self->iObserver.DataChanged(); + } + return 0; + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::CollectTasksL +// -------------------------------------------------------------------------- +// +TBool CTsFswEngine::CollectTasksL() + { + TBool changed = iDataList->CollectTasksL(); + return changed; + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::ForegroundAppUidL +// -------------------------------------------------------------------------- +// +TUid CTsFswEngine::ForegroundAppUidL( TInt aType ) + { + // Do not use GetFocusWindowGroup or others. + // We want to see only "real" application uids in FgApp, + // i.e. stuff that would also be shown in the task swapper + // area of Taskswitcher. + + TUid result = KNullUid; + RArray allWgIds; + CleanupClosePushL( allWgIds ); + User::LeaveIfError( iWsSession.WindowGroupList( 0, &allWgIds ) ); + TInt count = allWgIds.Count(); + for ( TInt i = 0; i < count; ++i ) + { + // Depending on aType we may not need to bother with iParentId here. + // If aType == EUseEmbeddedUid => embedded apps are treated as others. + // If aType == EUseStandaloneUid => embedded apps must be ignored. + if ( allWgIds[i].iParentId > 0 + && aType == CTsFswEngine::EUseStandaloneUid ) + { + continue; + } + + CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC( + iWsSession, allWgIds[i].iId ); + TUid newUid = wgn->AppUid(); + TBool hidden = wgn->Hidden(); + CleanupStack::PopAndDestroy( wgn ); + + if ( !hidden && newUid.iUid && !iDataList->IsHiddenUid(newUid) ) + { + result = newUid; + break; + } + } + CleanupStack::PopAndDestroy( &allWgIds ); + + return result; + } + +// -------------------------------------------------------------------------- +// CTsFswEngine::PublishFgAppUidL +// -------------------------------------------------------------------------- +// +void CTsFswEngine::PublishFgAppUidL() + { + TUid newUid = ForegroundAppUidL( CTsFswEngine::EUseEmbeddedUid ); + if ( iFgAppUid != newUid && newUid.iUid ) + { + iFgAppUid = newUid; + iDataList->MoveEntryAtStart(newUid.iUid, EFalse); + } + } + +// end of file diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/tsfswmonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/tsfswmonitor.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ws monitor implementation + * +*/ + + +#include "tsfswmonitor.h" +#include "tsfswobservers.h" + +// -------------------------------------------------------------------------- +// CTsFswMonitor::~CTsFswMonitor +// -------------------------------------------------------------------------- +// +CTsFswMonitor::~CTsFswMonitor() + { + Cancel(); + iWg.Close(); + iWsSession.Close(); + } + +// -------------------------------------------------------------------------- +// CTsFswMonitor::CTsFswMonitor +// -------------------------------------------------------------------------- +// +CTsFswMonitor::CTsFswMonitor(MTsFswTaskListObserver& aTaskListObserver) : CActive( EPriorityStandard ), + iTaskListObserver(&aTaskListObserver) + { + } + +// -------------------------------------------------------------------------- +// CTsFswMonitor::NewL +// -------------------------------------------------------------------------- +// +CTsFswMonitor* CTsFswMonitor::NewL(MTsFswTaskListObserver& aTaskListObserver) + { + CTsFswMonitor* self = NewLC(aTaskListObserver); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswMonitor::NewLC +// -------------------------------------------------------------------------- +// +CTsFswMonitor* CTsFswMonitor::NewLC(MTsFswTaskListObserver& aTaskListObserver) + { + CTsFswMonitor* self = new ( ELeave ) CTsFswMonitor(aTaskListObserver); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswMonitor::ConstructL +// -------------------------------------------------------------------------- +// +void CTsFswMonitor::ConstructL() + { + CActiveScheduler::Add( this ); + //Create window server observer + ConstractObserverL(); + Subscribe(); + } + + +// ----------------------------------------------------------------------------- +// Subscribe +// ----------------------------------------------------------------------------- +// +void CTsFswMonitor::Subscribe() + { + if( !IsActive() ) + { + iWsSession.EventReady( &iStatus ); + SetActive(); + } + } + +// ----------------------------------------------------------------------------- +// ConstractObserverL +// ----------------------------------------------------------------------------- +// +void CTsFswMonitor::ConstractObserverL() +{ + User::LeaveIfError( iWsSession.Connect() ); + iWg = RWindowGroup( iWsSession ); + User::LeaveIfError( iWg.Construct( + reinterpret_cast( &iWg ) ) ); + iWg.DisableFocusChangeEvents(); + iWg.DisableModifierChangedEvents(); + iWg.DisableOnEvents(); + iWg.DisableScreenChangeEvents(); + + //enable notifications about group lists + User::LeaveIfError( iWg.EnableGroupListChangeEvents() ); +} + +void CTsFswMonitor::RunL() +{ + User::LeaveIfError( iStatus.Int() ); + TWsEvent event; + iWsSession.GetEvent( event ); + Subscribe();//new subscribtion has to be called after picking event + if( EEventWindowGroupListChanged == event.Type() /*|| EEventFocusGroupChanged == event.Type()*/ ) + { + if ( iTaskListObserver ) + { + iTaskListObserver->UpdateTaskList(); + } + } +} + +TInt CTsFswMonitor::RunError( TInt /*aError*/ ) +{ + Subscribe(); + return KErrNone; +} + +void CTsFswMonitor::DoCancel() +{ + if( IsActive() ) + { + iWsSession.EventReadyCancel(); + } +} + +// end of file diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/src/tsrunningappstorage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/src/tsrunningappstorage.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "tsrunningappstorage.h" +#include "tsfswengine.h" +#include "tsfswmonitor.h" +#include "tsfswentry.h" +#include +#include +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppStorage::CRunningAppStorage(MHsDataObserver& observer) +: mObserver(observer) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppStorage::~CRunningAppStorage() +{ + mData.Close(); + delete mEngine; + delete mMonitor; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CRunningAppStorage* CRunningAppStorage::NewL(MHsDataObserver& observer) +{ + CRunningAppStorage * self = new (ELeave)CRunningAppStorage(observer); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppStorage::ConstructL() +{ + mEngine = CTsFswEngine::NewL(*this) ; + mMonitor = CTsFswMonitor::NewL(*mEngine); + DataChangedL(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +const TDesC8& CRunningAppStorage::Data() const +{ + return mData; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CRunningAppStorage::DataChanged() +{ + TRAPD( err, DataChangedL() ); + if ( err == KErrNone) + { + mObserver.DataChanged(); + } + + int a=8; + if( a==9) + { + CActiveScheduler::Stop(); + } +} +void CRunningAppStorage::DataChangedL() +{ + RTsFswArray taskList = mEngine->FswDataL(); + CTsFswEntry* entry = CTsFswEntry::NewLC(); + // Create a dynamic flat buffer to hold this object’s member data + + const TInt KExpandSize = 256; // "Granularity" of dynamic buffer + CBufFlat* buf = CBufFlat::NewL(KExpandSize); + CleanupStack::PushL(buf); + RBufWriteStream stream(*buf); + CleanupClosePushL(stream); + entry->ExternalizeArrayL(stream, taskList); + CleanupStack::PopAndDestroy(&stream); + mData.Close(); + mData.CreateL( buf->Size() ); + buf->Read(0, mData, buf->Size()); + + + CleanupStack::PopAndDestroy(buf); + CleanupStack::PopAndDestroy(entry); + +} diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/server/tsrc/tsrc.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/server/tsrc/tsrc.pro Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,22 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += testapp +SUBDIRS += t_tsrunningappstorage + diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/sis/stubs/createstubs.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/sis/stubs/createstubs.bat Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,17 @@ +@rem +@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: +@rem + +for %%f in (*.pkg) do makesis -s %%f diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/sis/stubs/taskmonitor_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/sis/stubs/taskmonitor_stub.pkg Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,36 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; ------------------------------------------------------------------------------ +; Taskswitcher stub SIS package file. +; Used to enable Taskswitcher to be updated from ROM with a SIS package. +; When you add new files into this stub, please remember to update +; SIS stub with "makesis -s" command. +; ------------------------------------------------------------------------------ +; +;Language - standard language definitions +&EN + +; standard SIS file header +#{"taskmonitor"},(0x200267B0),1,0,0,TYPE=SA + +;Localized Vendor Name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + +"" - "Z:\sys\bin\tstaskmonitorclient.dll" +"" - "Z:\sys\bin\hsrunningappmonitor.exe" diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/sis/stubs/taskmonitor_stub.sis Binary file tstaskmonitor/sis/stubs/taskmonitor_stub.sis has changed diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/sis/taskmonitor.SIS Binary file tstaskmonitor/sis/taskmonitor.SIS has changed diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/sis/taskmonitor.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/sis/taskmonitor.pkg Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,32 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +;Language - standard language definitions +&EN + +; standard SIS file header +#{"taskmonitor"},(0x200267B0),1,0,0,TYPE=SA, RU + +;Localized Vendor Name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + + +"/epoc32/release/armv5/urel/hsrunningappmonitor.exe" - "!:\sys\bin\hsrunningappmonitor.exe" +"/epoc32/release/armv5/urel/tstaskmonitorclient.dll"-"!:\sys\bin\tstaskmonitorclient.dll" + diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/tstaskmonitor.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/tstaskmonitor.pro Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,27 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = subdirs + +CONFIG += ordered + +symbian { + SUBDIRS += server +} + +SUBDIRS += client + +symbian:include(rom.pri) \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/utils/inc/tsfswentry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/utils/inc/tsfswentry.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task list entry + * +*/ + + +#ifndef TSFSWENTRY_H +#define TSFSWENTRY_H + +#include +#include + +class CTsFswEntry; +class RReadStream; +class RWriteStream; +class CFbsBitmap; + +typedef RPointerArray RTsFswArray; + +enum TAppType +{ + EApp = 0, + EWidget, + EJava +}; + +/** + * An entry in the task list. + */ +NONSHARABLE_CLASS( CTsFswEntry ) : public CBase + { +public: + static CTsFswEntry* NewL(); + static CTsFswEntry* NewLC(); + ~CTsFswEntry(); + + /** + * Window group id. + * In case of wrt widgets this is negative and is not a valid window group id. + * Use this when calling CloseApp or SwitchToApp. (these work with widgets too) + */ + TInt WgId() const; + + /** + * Application uid. + */ + TUid AppUid() const; + + /** + * Application type. + */ + TAppType Type() const; + + /** + * Application name. + */ + const TDesC& AppName() const; + + /** + * ETrue if the application is closeable + */ + TBool CloseableApp() const; + + /** + * Application icon bitmap + */ + CFbsBitmap* AppIconBitmap() const; + + /** + * Application icon mask. + * @see AppIconBitmapHandle + */ + CFbsBitmap* AppIconMask() const; + + + void SetWgId( TInt aWgId ); + void SetAppUid( const TUid& aUid ); + void SetAppNameL( const TDesC& aAppName ); + void SetCloseableApp( TBool aValue ); + + // takes ownership of bitmaps + void SetAppIcon( CFbsBitmap* aBitmap, CFbsBitmap* aMask ); + void ExternalizeL( RWriteStream& aStream ); + void InternalizeL( RReadStream& aStream ); + + static void ExternalizeArrayL( RWriteStream& aStream, + const RTsFswArray& aArray ); + static void InternalizeArrayL( RReadStream& aStream, + RTsFswArray& aArray ); + +private: + TInt iWgId; + TUid iAppUid; + HBufC* iAppName; + TBool iCloseableApp; + CFbsBitmap* iAppIconBitmap; + CFbsBitmap* iAppIconMask; + }; + +#endif diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/utils/inc/tsutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/utils/inc/tsutils.h Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +namespace TaskSwitcher { + template + void RPointerArrayCleanupMethod(TAny *aPtr) + { + static_cast< RPointerArray* >(aPtr)->ResetAndDestroy(); + } + + template + void CleanupResetAndDestroyPushL(RPointerArray &array) { + CleanupStack::PushL(TCleanupItem(&RPointerArrayCleanupMethod, &array)); + } +} \ No newline at end of file diff -r 4bc7b118b3df -r 397d00875918 tstaskmonitor/utils/src/tsfswentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/utils/src/tsfswentry.cpp Thu May 27 13:11:12 2010 +0300 @@ -0,0 +1,251 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task list entry + * +*/ + +#define __E32SVR_H__ +#include "tsfswentry.h" +#include +#include + +// -------------------------------------------------------------------------- +// CTsFswEntry::NewL +// -------------------------------------------------------------------------- +// +CTsFswEntry* CTsFswEntry::NewL() + { + CTsFswEntry* self = NewLC(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::NewLC +// -------------------------------------------------------------------------- +// +CTsFswEntry* CTsFswEntry::NewLC() + { + CTsFswEntry* self = new ( ELeave ) CTsFswEntry; + CleanupStack::PushL( self ); + return self; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::~CTsFswEntry +// -------------------------------------------------------------------------- +// +CTsFswEntry::~CTsFswEntry() + { + delete iAppName; + delete iAppIconBitmap; + delete iAppIconMask; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetWgId +// -------------------------------------------------------------------------- +// +void CTsFswEntry::SetWgId( TInt aWgId ) + { + iWgId = aWgId; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetAppUid +// -------------------------------------------------------------------------- +// +void CTsFswEntry::SetAppUid( const TUid& aUid ) + { + iAppUid = aUid; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetAppNameL +// -------------------------------------------------------------------------- +// +void CTsFswEntry::SetAppNameL( const TDesC& aAppName ) + { + delete iAppName; iAppName = 0; + iAppName = aAppName.AllocL(); + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetSystemApp +// -------------------------------------------------------------------------- +// +void CTsFswEntry::SetCloseableApp( TBool aValue ) + { + iCloseableApp = aValue; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetAppIconHandles +// -------------------------------------------------------------------------- +// +void CTsFswEntry::SetAppIcon( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) + { + iAppIconBitmap = aBitmap; + iAppIconMask = aMask; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::WgId +// -------------------------------------------------------------------------- +// +TInt CTsFswEntry::WgId() const + { + return iWgId; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::AppUid +// -------------------------------------------------------------------------- +// +TUid CTsFswEntry::AppUid() const + { + return iAppUid; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::AppName +// -------------------------------------------------------------------------- +// +const TDesC& CTsFswEntry::AppName() const + { + return iAppName ? *iAppName : KNullDesC(); + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::SystemApp +// -------------------------------------------------------------------------- +// +TBool CTsFswEntry::CloseableApp() const + { + return iCloseableApp; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::AppIconBitmapHandle +// -------------------------------------------------------------------------- +// +CFbsBitmap* CTsFswEntry::AppIconBitmap() const + { + return iAppIconBitmap; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::AppIconMaskHandle +// -------------------------------------------------------------------------- +// +CFbsBitmap* CTsFswEntry::AppIconMask() const + { + return iAppIconMask; + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::ExternalizeL +// -------------------------------------------------------------------------- +// +void CTsFswEntry::ExternalizeL( RWriteStream& aStream ) + { + aStream.WriteInt32L( iWgId ); + aStream.WriteInt32L( iAppUid.iUid ); + aStream << AppName(); + aStream.WriteInt32L( iCloseableApp ); + if ( iAppIconBitmap ) + { + aStream.WriteInt32L( iAppIconBitmap->Handle() ); + } + else + { + aStream.WriteInt32L( KErrNotFound ); + } + + if ( iAppIconMask ) + { + aStream.WriteInt32L( iAppIconMask->Handle() ); + } + else + { + aStream.WriteInt32L( KErrNotFound ); + } + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::InternalizeL +// -------------------------------------------------------------------------- +// +void CTsFswEntry::InternalizeL( RReadStream& aStream ) + { + iWgId = aStream.ReadInt32L(); + iAppUid = TUid::Uid( aStream.ReadInt32L() ); + delete iAppName; iAppName = NULL; + iAppName = HBufC::NewL( aStream, KMaxTInt ); + iCloseableApp = aStream.ReadInt32L(); + TInt appIconBitmapHandle = aStream.ReadInt32L(); + TInt appIconMaskHandle = aStream.ReadInt32L(); + if ( appIconBitmapHandle != KErrNotFound ) + { + iAppIconBitmap = new (ELeave) CFbsBitmap; + iAppIconBitmap->Duplicate( appIconBitmapHandle ); + } + if ( appIconMaskHandle != KErrNotFound ) + { + iAppIconMask = new (ELeave) CFbsBitmap; + iAppIconMask->Duplicate( appIconMaskHandle ); + } + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::ExternalizeArrayL +// -------------------------------------------------------------------------- +// +void CTsFswEntry::ExternalizeArrayL( RWriteStream& aStream, + const RTsFswArray& aArray ) + { + TInt count = aArray.Count(); + aStream.WriteInt32L( count ); + for ( TInt i = 0; i < count; ++i ) + { + aArray[i]->ExternalizeL( aStream ); + } + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::InternalizeArrayL +// -------------------------------------------------------------------------- +// +void CTsFswEntry::InternalizeArrayL( RReadStream& aStream, + RTsFswArray& aArray ) + { + aArray.ResetAndDestroy(); + TInt count = aStream.ReadInt32L(); for ( TInt i = 0; i < count; ++i ) + { + CTsFswEntry* entry = CTsFswEntry::NewLC(); + entry->InternalizeL( aStream ); + aArray.AppendL( entry ); + CleanupStack::Pop( entry ); + } + } + +// -------------------------------------------------------------------------- +// CTsFswEntry::Type +// -------------------------------------------------------------------------- +// +TAppType CTsFswEntry::Type() const + { + return EApp; + } +// end of file