201011
authorhgs
Wed, 24 Mar 2010 03:15:43 +0200
changeset 89 1e87eb3b400f
parent 88 7f0462e8c3da
child 90 0e41c72311af
201011
activitymanager/activitydatabase/activitydatabase.pro
activitymanager/activitydatabase/bwins/hsactivitydbclientu.def
activitymanager/activitydatabase/eabi/hsactivitydbclientu.def
activitymanager/activitydatabase/hsactivitydbclient/hsactivitydbclient.pro
activitymanager/activitydatabase/hsactivitydbclient/inc/hsactivitydbasyncrequestobserver.h
activitymanager/activitydatabase/hsactivitydbclient/inc/hsactivitydbclient.h
activitymanager/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbasyncrequest_p.h
activitymanager/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbclient_p.h
activitymanager/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbasyncrequest_p.cpp
activitymanager/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbclient_p.cpp
activitymanager/activitydatabase/hsactivitydbclient/src/hsactivitydbclient.cpp
activitymanager/activitydatabase/hsactivitydbserver/hsactivitydbserver.pro
activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivity.h
activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivityserver.h
activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivitystorage.h
activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivitystorage_p.h
activitymanager/activitydatabase/hsactivitydbserver/s60/inc/hsactivityserver_p.h
activitymanager/activitydatabase/hsactivitydbserver/s60/inc/hsactivitysession_p.h
activitymanager/activitydatabase/hsactivitydbserver/s60/src/hsactivityserver_p.cpp
activitymanager/activitydatabase/hsactivitydbserver/s60/src/hsactivitysession_p.cpp
activitymanager/activitydatabase/hsactivitydbserver/s60/src/main.cpp
activitymanager/activitydatabase/hsactivitydbserver/src/hsactivityserver.cpp
activitymanager/activitydatabase/hsactivitydbserver/src/hsactivitystorage.cpp
activitymanager/activitydatabase/hsactivitydbserver/src/hsactivitystorage_p.cpp
activitymanager/activitydatabase/hsactivitydbserver/src/main.cpp
activitymanager/activitydatabase/inc/hsactivitydbclientinterface.h
activitymanager/activitydatabase/s60/inc/hsactivityglobals.h
activitymanager/activitydatabase/s60/inc/hsserializer.h
activitymanager/activitydatabase/s60/src/hsserializer.cpp
activitymanager/activitylauncher/activitylauncher.pro
activitymanager/activitylauncher/activitylauncherview.cpp
activitymanager/activitylauncher/activitylauncherview.h
activitymanager/activitylauncher/main.cpp
activitymanager/activitymanager.pro
activitymanager/activityserviceplugin/activityclient.cpp
activitymanager/activityserviceplugin/activityclient.h
activitymanager/activityserviceplugin/activityclient_p.cpp
activitymanager/activityserviceplugin/activityclient_p.h
activitymanager/activityserviceplugin/activitydatastorage.cpp
activitymanager/activityserviceplugin/activitydatastorage.h
activitymanager/activityserviceplugin/activitymanager.cpp
activitymanager/activityserviceplugin/activitymanager.h
activitymanager/activityserviceplugin/activitymanager_p.cpp
activitymanager/activityserviceplugin/activitymanager_p.h
activitymanager/activityserviceplugin/activityserviceplugin.cpp
activitymanager/activityserviceplugin/activityserviceplugin.h
activitymanager/activityserviceplugin/activityserviceplugin.pri
activitymanager/activityserviceplugin/activityserviceplugin.pro
activitymanager/activityserviceplugin/activityserviceplugin.xml
activitymanager/activityserviceplugin/applicationlauncher.cpp
activitymanager/activityserviceplugin/applicationlauncher.h
activitymanager/activityserviceplugin/s60/activitydatabase_p.cpp
activitymanager/activityserviceplugin/s60/activitydatabase_p.h
activitymanager/activityserviceplugin/s60/activityserverclient_p.cpp
activitymanager/activityserviceplugin/s60/activityserverclient_p.h
activitymanager/activityserviceplugin/s60/applicationlauncher_p.cpp
activitymanager/activityserviceplugin/s60/applicationlauncher_p.h
activitymanager/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.cpp
activitymanager/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.pro
activitymanager/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.qrc
activitymanager/activityserviceplugin/symbianinstaller/symbianinstaller.pro
activitymanager/activityserviceplugin/win/activitydatabase_p.cpp
activitymanager/activityserviceplugin/win/activitydatabase_p.h
activitymanager/activityserviceplugin/win/applicationlauncher_p.cpp
activitymanager/activityserviceplugin/win/applicationlauncher_p.h
activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.cpp
activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.h
activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.pro
activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.qrc
activitymanager/orbitintegration/hbactivityplugin/hbactivityplugininterface.h
activitymanager/rom.pri
activitymanager/rom/activitymanager_core.iby
activitymanager/sis/activitymanager.pkg
activitymanager/sis/edit_pkg.pl
activitymanager/sis/stubs/activitymanager_stub.pkg
activitymanager/sis/stubs/activitymanager_stub.sis
activitymanager/sis/stubs/createstubs.bat
contentstorage/caclient/caclient.pro
contentstorage/caclient/inc/caclient_defines.h
contentstorage/caclient/inc/caitemmodellist.h
contentstorage/caclient/installs_win32.pri
contentstorage/caclient/s60/inc/caobjectadapter.h
contentstorage/caclient/s60/src/caobjectadapter.cpp
contentstorage/caclient/s60/src/caqtsfhandlerloader.cpp
contentstorage/caclient/src/caitemmodel.cpp
contentstorage/caclient/src/caitemmodellist.cpp
contentstorage/caclient/stub/src/caclientproxy.cpp
contentstorage/cahandler/app/inc/catasklist.h
contentstorage/cahandler/app/src/caapphandler.cpp
contentstorage/cahandler/app/src/catasklist.cpp
contentstorage/cahandler/app/src/cauninstalloperation.cpp
contentstorage/cahandler/inc/cas60handleradapter.h
contentstorage/cahandler/tapp/src/catapphandler.cpp
contentstorage/casrv/caappscanner/src/casrvappscanner.cpp
contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp
contentstorage/casrv/carunningappmonitor/src/carunningappmonitor.cpp
contentstorage/casrv/cawidgetscanner/data/cawidgetscanner.rss
contentstorage/casrv/cawidgetscanner/group/cawidgetscanner.mmp
contentstorage/casrv/cawidgetscanner/inc/cawidgetdescription.h
contentstorage/casrv/cawidgetscanner/inc/cawidgetscannerparser.h
contentstorage/casrv/cawidgetscanner/inc/widgetscannerutils.h
contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp
contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp
contentstorage/castorage/data/castorage.db
contentstorage/castorage/data/castoragedb
contentstorage/castorage/data/castoragedb_create.sql
contentstorage/castorage/data/castoragedb_variant.bat
contentstorage/castorage/data/castoragedb_variant_test.bat
contentstorage/castorage/inc/caconsts.h
contentstorage/castorage/inc/cadebug.h
contentstorage/castorage/inc/casqlcommands.h
contentstorage/castorage/src/casqlitestorage.cpp
contentstorage/castorage/src/casqlquery.cpp
contentstorage/castorage/src/casqlquerycreator.cpp
contentstorage/cautils/src/cainnerquery.cpp
contentstorage/group/group.pro
contentstorage/inc/cadef.h
contentstorage/inc/casrvdef.h
contentstorage/srvinc/cainstallnotifier.h
homescreensrv.pro
rom/homescreensrv_core.iby
sis/homescreensrv.pkg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/activitydatabase.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -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
+
+SUBDIRS += hsactivitydbclient \
+           hsactivitydbserver
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/bwins/hsactivitydbclientu.def	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,25 @@
+EXPORTS
+	?launchActivity@HsActivityDbClient@@UAEHABV?$QHash@VQString@@VQVariant@@@@@Z @ 1 NONAME ; int HsActivityDbClient::launchActivity(class QHash<class QString, class QVariant> const &)
+	?connect@HsActivityDbClient@@QAEHXZ @ 2 NONAME ; int HsActivityDbClient::connect(void)
+	?asyncRequestCompleated@HsActivityDbClient@@UAEXHHABVQString@@@Z @ 3 NONAME ; void HsActivityDbClient::asyncRequestCompleated(int, int, class QString const &)
+	?trUtf8@HsActivityDbClient@@SA?AVQString@@PBD0@Z @ 4 NONAME ; class QString HsActivityDbClient::trUtf8(char const *, char const *)
+	?applicationActivities@HsActivityDbClient@@UAEHAAV?$QList@V?$QHash@VQString@@VQVariant@@@@@@ABV?$QHash@VQString@@VQVariant@@@@@Z @ 5 NONAME ; int HsActivityDbClient::applicationActivities(class QList<class QHash<class QString, class QVariant> > &, class QHash<class QString, class QVariant> const &)
+	?qt_metacast@HsActivityDbClient@@UAEPAXPBD@Z @ 6 NONAME ; void * HsActivityDbClient::qt_metacast(char const *)
+	?qt_metacall@HsActivityDbClient@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 7 NONAME ; int HsActivityDbClient::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?waitActivity@HsActivityDbClient@@UAEHABV?$QHash@VQString@@VQVariant@@@@@Z @ 8 NONAME ; int HsActivityDbClient::waitActivity(class QHash<class QString, class QVariant> const &)
+	?activities@HsActivityDbClient@@UAEHAAV?$QList@V?$QHash@VQString@@VQVariant@@@@@@@Z @ 9 NONAME ; int HsActivityDbClient::activities(class QList<class QHash<class QString, class QVariant> > &)
+	?trUtf8@HsActivityDbClient@@SA?AVQString@@PBD0H@Z @ 10 NONAME ; class QString HsActivityDbClient::trUtf8(char const *, char const *, int)
+	??0HsActivityDbClient@@QAE@PAVQObject@@@Z @ 11 NONAME ; HsActivityDbClient::HsActivityDbClient(class QObject *)
+	?tr@HsActivityDbClient@@SA?AVQString@@PBD0@Z @ 12 NONAME ; class QString HsActivityDbClient::tr(char const *, char const *)
+	?getStaticMetaObject@HsActivityDbClient@@SAABUQMetaObject@@XZ @ 13 NONAME ; struct QMetaObject const & HsActivityDbClient::getStaticMetaObject(void)
+	??_EHsActivityDbClient@@UAE@I@Z @ 14 NONAME ; HsActivityDbClient::~HsActivityDbClient(unsigned int)
+	?metaObject@HsActivityDbClient@@UBEPBUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const * HsActivityDbClient::metaObject(void) const
+	?removeApplicationActivities@HsActivityDbClient@@UAEHABV?$QHash@VQString@@VQVariant@@@@@Z @ 16 NONAME ; int HsActivityDbClient::removeApplicationActivities(class QHash<class QString, class QVariant> const &)
+	?tr@HsActivityDbClient@@SA?AVQString@@PBD0H@Z @ 17 NONAME ; class QString HsActivityDbClient::tr(char const *, char const *, int)
+	?addActivity@HsActivityDbClient@@UAEHABV?$QHash@VQString@@VQVariant@@@@@Z @ 18 NONAME ; int HsActivityDbClient::addActivity(class QHash<class QString, class QVariant> const &)
+	?staticMetaObject@HsActivityDbClient@@2UQMetaObject@@B @ 19 NONAME ; struct QMetaObject const HsActivityDbClient::staticMetaObject
+	??1HsActivityDbClient@@UAE@XZ @ 20 NONAME ; HsActivityDbClient::~HsActivityDbClient(void)
+	?activityRequested@HsActivityDbClient@@IAEXABVQString@@@Z @ 21 NONAME ; void HsActivityDbClient::activityRequested(class QString const &)
+	?updateActivity@HsActivityDbClient@@UAEHABV?$QHash@VQString@@VQVariant@@@@@Z @ 22 NONAME ; int HsActivityDbClient::updateActivity(class QHash<class QString, class QVariant> const &)
+	?removeActivity@HsActivityDbClient@@UAEHABV?$QHash@VQString@@VQVariant@@@@@Z @ 23 NONAME ; int HsActivityDbClient::removeActivity(class QHash<class QString, class QVariant> const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/eabi/hsactivitydbclientu.def	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,34 @@
+EXPORTS
+	_ZN18HsActivityDbClient10activitiesER5QListI5QHashI7QString8QVariantEE @ 1 NONAME
+	_ZN18HsActivityDbClient11addActivityERK5QHashI7QString8QVariantE @ 2 NONAME
+	_ZN18HsActivityDbClient11qt_metacallEN11QMetaObject4CallEiPPv @ 3 NONAME
+	_ZN18HsActivityDbClient11qt_metacastEPKc @ 4 NONAME
+	_ZN18HsActivityDbClient12waitActivityERK5QHashI7QString8QVariantE @ 5 NONAME
+	_ZN18HsActivityDbClient14launchActivityERK5QHashI7QString8QVariantE @ 6 NONAME
+	_ZN18HsActivityDbClient14removeActivityERK5QHashI7QString8QVariantE @ 7 NONAME
+	_ZN18HsActivityDbClient14updateActivityERK5QHashI7QString8QVariantE @ 8 NONAME
+	_ZN18HsActivityDbClient16staticMetaObjectE @ 9 NONAME DATA 16
+	_ZN18HsActivityDbClient17activityRequestedERK7QString @ 10 NONAME
+	_ZN18HsActivityDbClient19getStaticMetaObjectEv @ 11 NONAME
+	_ZN18HsActivityDbClient21applicationActivitiesER5QListI5QHashI7QString8QVariantEERKS4_ @ 12 NONAME
+	_ZN18HsActivityDbClient22asyncRequestCompleatedEiiRK7QString @ 13 NONAME
+	_ZN18HsActivityDbClient27removeApplicationActivitiesERK5QHashI7QString8QVariantE @ 14 NONAME
+	_ZN18HsActivityDbClient7connectEv @ 15 NONAME
+	_ZN18HsActivityDbClientC1EP7QObject @ 16 NONAME
+	_ZN18HsActivityDbClientC2EP7QObject @ 17 NONAME
+	_ZN18HsActivityDbClientD0Ev @ 18 NONAME
+	_ZN18HsActivityDbClientD1Ev @ 19 NONAME
+	_ZN18HsActivityDbClientD2Ev @ 20 NONAME
+	_ZNK18HsActivityDbClient10metaObjectEv @ 21 NONAME
+	_ZTI18HsActivityDbClient @ 22 NONAME
+	_ZTV18HsActivityDbClient @ 23 NONAME
+	_ZThn12_N18HsActivityDbClient22asyncRequestCompleatedEiiRK7QString @ 24 NONAME
+	_ZThn8_N18HsActivityDbClient10activitiesER5QListI5QHashI7QString8QVariantEE @ 25 NONAME
+	_ZThn8_N18HsActivityDbClient11addActivityERK5QHashI7QString8QVariantE @ 26 NONAME
+	_ZThn8_N18HsActivityDbClient12waitActivityERK5QHashI7QString8QVariantE @ 27 NONAME
+	_ZThn8_N18HsActivityDbClient14launchActivityERK5QHashI7QString8QVariantE @ 28 NONAME
+	_ZThn8_N18HsActivityDbClient14removeActivityERK5QHashI7QString8QVariantE @ 29 NONAME
+	_ZThn8_N18HsActivityDbClient14updateActivityERK5QHashI7QString8QVariantE @ 30 NONAME
+	_ZThn8_N18HsActivityDbClient21applicationActivitiesER5QListI5QHashI7QString8QVariantEERKS4_ @ 31 NONAME
+	_ZThn8_N18HsActivityDbClient27removeApplicationActivitiesERK5QHashI7QString8QVariantE @ 32 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/hsactivitydbclient.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+#
+
+TEMPLATE = lib
+TARGET = hsactivitydbclient
+
+QT        += core \
+             sql
+
+QT        -= gui 
+
+HEADERS   += inc/hsactivitydbclient.h
+
+SOURCES   += src/hsactivitydbclient.cpp
+
+DEFINES += ACTIVITY_LIB
+
+symbian{
+TARGET.UID3 = 0xE467C21E
+
+HEADERS   += ../s60/inc/hsserializer.h \
+             s60/inc/hsactivitydbclient_p.h \
+			 s60/inc/hsactivitydbasyncrequest_p.h
+
+SOURCES   += ../s60/src/hsserializer.cpp \
+             s60/src/hsactivitydbclient_p.cpp \
+			 s60/src/hsactivitydbasyncrequest_p.cpp
+
+
+hsactivitydbclientdll.sources = hsactivitydbclient.dll
+hsactivitydbclientdll.path = $$SHARED_LIB_DIR
+DEPLOYMENT += hsactivitydbclientdll
+
+BLD_INF_RULES.prj_exports += "../inc/hsactivitydbclientinterface.h /epoc32/include/hsactivitydbclientinterface.h" \
+                             "inc/hsactivitydbclient.h /epoc32/include/hsactivitydbclient.h" \
+							 "inc/hsactivitydbasyncrequestobserver.h /epoc32/include/hsactivitydbasyncrequestobserver.h"
+DEPLOYMENT += api
+TARGET.CAPABILITY = ALL -TCB
+TARGET.EPOCALLOWDLLDATA = 1
+MMP_RULES += EXPORTUNFROZEN
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/inc/hsactivitydbasyncrequestobserver.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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:
+*
+*/
+
+#ifndef HSACTIVITYDBASYNCREQUESTOBSERVER_H
+#define HSACTIVITYDBASYNCREQUESTOBSERVER_H
+#include <QString>
+class HsActivityDbAsyncRequestObserver
+{
+public:
+    /**
+     * Function inform observer about asynchronous request results
+     * @param result - request result
+     * @param requestType - request type
+     * @param data - respons data  
+     */
+    virtual void asyncRequestCompleated(int result, 
+                                        int requestType, 
+                                        const QString& data)=0;
+};
+#endif // HSACTIVITYDBASYNCREQUESTOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/inc/hsactivitydbclient.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,125 @@
+/*
+* 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 HSACTIVITYDBCLIENT_H
+#define HSACTIVITYDBCLIENT_H
+#include <QObject>
+#include <hsactivitydbasyncrequestobserver.h>
+#include "hsactivitydbclientinterface.h"
+
+#ifdef ACTIVITY_LIB
+    #define ACTIVITY_EXPORT Q_DECL_EXPORT
+#else
+    #define ACTIVITY_EXPORT Q_DECL_IMPORT
+#endif
+
+class HsActivityDbClientPrivate;
+
+/**
+ * Class implemets HsActivityDbClientInterface and is responsible for activity data management.
+ */
+class ACTIVITY_EXPORT HsActivityDbClient:   public QObject,
+                                            public HsActivityDbClientInterface,
+                                            public HsActivityDbAsyncRequestObserver
+{
+Q_OBJECT
+public:
+    /**
+     * Constructor
+     */
+    HsActivityDbClient(QObject* =0);
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityDbClient();
+    
+    /**
+     * Establish connection with activity server
+     * @return 0 on succees, error code otherwise
+     */
+    int connect();
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbAsyncRequestObserver::asyncRequestCompleated(int, int, const QString&)
+     */
+    void asyncRequestCompleated(int, int, const QString&);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::saveActivity(const QVariantHash&)
+     */
+    int addActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::updateActivity(const QVariantHash&)
+     */
+    int updateActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::deleteActivity(const QVariantHash &)
+     */
+    int removeActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::deleteApplicationActivities(const QVariantHash &)
+     */
+    int removeApplicationActivities(const QVariantHash &activity);
+        
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::activities(QList<QVariantHash>&)
+     */
+    int activities(QList<QVariantHash> &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::applicationActivities(QList<QVariantHash> &, const QVariantHash &)
+     */
+    int applicationActivities(QList<QVariantHash> &, 
+                              const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::waitActivity(const QVariantHash &)
+     */
+    int waitActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::launchActivity(const QVariantHash &)
+     */
+    int launchActivity(const QVariantHash &);
+signals:
+    /**
+     * Function notify about runtime activity change
+     * @param activityId - requested activity name
+     */
+    void activityRequested(const QString& activityId);
+private:
+    /**
+     * Private client implementation.
+     * Own.
+     */
+    HsActivityDbClientPrivate* d_ptr;
+};
+
+#endif //HSACTIVITYDBCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbasyncrequest_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,79 @@
+/*
+* 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 HSACTIVITYDBASYNCREQUESTPRIVATE_H
+#define HSACTIVITYDBASYNCREQUESTPRIVATE_H
+#include <e32base.h>
+#include <QVariant>
+#include <hsactivitydbasyncrequestobserver.h>
+
+class HsActivityDbClientPrivate;
+
+/**
+ * Class is responsible for async. request handling
+ */
+class HsActivityDbAsyncRequestPrivate : public CActive
+
+{
+public:
+    /**
+     * First step constructor
+     */
+    static HsActivityDbAsyncRequestPrivate* 
+        NewL(HsActivityDbAsyncRequestObserver &, HsActivityDbClientPrivate &);
+    
+    /**
+     * First step constructor
+     */
+    static HsActivityDbAsyncRequestPrivate* 
+        NewLC(HsActivityDbAsyncRequestObserver &, HsActivityDbClientPrivate &);
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityDbAsyncRequestPrivate();
+    
+    /**
+     * Function create subscription to current ativity changes
+     * @param condition - activity filetering rules
+     */
+    void waitActivity(const QVariantHash& condition);
+protected:
+    /**
+     * Interface implementation.
+     * @see void CActive::DoCancel()
+     */
+    void DoCancel();
+    
+    /**
+     * Interface implementation.
+     * @see void CActive::DoCancel()
+     */
+    void RunL();
+private:
+    /**
+     * Constructor
+     */
+    HsActivityDbAsyncRequestPrivate(HsActivityDbAsyncRequestObserver &,
+                                    HsActivityDbClientPrivate &);
+private:
+    HsActivityDbAsyncRequestObserver& mObserver; 
+    HsActivityDbClientPrivate& mSession;
+    int mRequestType;
+    RBuf8 mDataBuf;
+    TPckgBuf<int> mDataSize;
+};
+#endif // HSACTIVITYDBCLIENTPRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/s60/inc/hsactivitydbclient_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,178 @@
+/*
+* 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 HSACTIVITYDBCLIENTPRIVATE_H
+#define HSACTIVITYDBCLIENTPRIVATE_H
+#include "hsactivitydbclientinterface.h"
+#include <e32base.h>
+#include <hsactivitydbasyncrequestobserver.h>
+
+class HsActivityDbAsyncRequestPrivate;
+/**
+ * Class implemets HsActivityDbClientInterface and is responsible for 
+ * activity data management on S60 enviroment.
+ */
+class HsActivityDbClientPrivate : protected RSessionBase,
+                                  public HsActivityDbClientInterface
+{
+public:
+    /**
+     * Constructor
+     */
+    HsActivityDbClientPrivate(HsActivityDbAsyncRequestObserver&);
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityDbClientPrivate();
+    
+    /**
+     * Function establish connection to activity server
+     * @return 0 on succees, error code otherwise
+     */
+    int connect();
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::addActivity(const QVariantHash &)
+     */
+    int addActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::updateActivity(const QVariantHash &)
+     */
+    int updateActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::removeActivity(const QVariantHash &)
+     */
+    int removeActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::removeApplicationActivities(const QVariantHash &)
+    */
+    int removeApplicationActivities(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::requestedActivityName(QString &, const QVariantHash &);
+     */
+    int requestedActivityName(QString &, const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::activities(QList<QVariantHash> &);
+     */
+    int activities(QList<QVariantHash> &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::applicationActivities(QList<QVariantHash> &, const QVariantHash &)
+     */
+    int applicationActivities(QList<QVariantHash>&, const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::waitActivity(const QVariantHash &)
+     */
+    int waitActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::launchActivity(const QVariantHash &)
+     */
+    int launchActivity(const QVariantHash &);
+
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::cancelWaitActivity()
+     */
+    int cancelWaitActivity();
+    
+public:
+    /**
+     * Function get cached data from server
+     * @param dst - destination, preallocated buffer
+     */
+    void getData(RBuf8 & dst);
+    
+    /**
+     * Function initialize aync request
+     * @param func - requested function
+     * @param data - request data
+     * @param status - request status
+     */
+    void sendDataAsync(int func,const TIpcArgs & data, TRequestStatus& status);
+    
+private:
+    /**
+     * Function start activity server process.
+     * Function can leave on failure.
+     */
+    void startServerL();
+    
+    /**
+     * Function establish connection to activity server.
+     * Function can leave on failure
+     */
+    void connectL();
+    
+    /**
+     * Function execute remote call request.
+     * @param function - remote function identyfier
+     * @param activity - remote function parameters  
+     */
+    void execSimpleRequestL( int function, const QVariantHash &activity);
+    
+    /**
+     * Function retrieve current activity name for application.
+     * Function can leave on failure
+     * @param  result - activity name
+     * @param activity - request filtering rules 
+     */
+    void requestedActivityNameL(QString& result, 
+                                const QVariantHash &activity);
+    
+    /**
+     * Function retrieve all stored activity
+     * Function can leave on failure
+     * @param result - list of activity 
+     */
+    void activitiesL(QList<QVariantHash>& result);
+    
+    /**
+     * Function retrieve all stored activity
+     * Function can leave on failure
+     * @param result - list of activity
+     * @param cond - request conditions  
+     */
+    void applicationActivitiesL(QList<QVariantHash>& result, 
+                                const QVariantHash & cond);
+    
+    void waitActivityL(const QVariantHash &activity);
+private:
+    /**
+     * Async request handler
+     * Own
+     */
+    HsActivityDbAsyncRequestPrivate* mAsyncDataHandler; 
+
+};
+#endif // HSACTIVITYDBCLIENTPRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbasyncrequest_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* 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 "hsactivitydbasyncrequest_p.h"
+#include "hsactivitydbclient_p.h"
+#include "hsserializer.h"
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbAsyncRequestPrivate* 
+    HsActivityDbAsyncRequestPrivate::NewL(HsActivityDbAsyncRequestObserver& observer,
+                                          HsActivityDbClientPrivate& session)
+{
+    HsActivityDbAsyncRequestPrivate* self = 
+        HsActivityDbAsyncRequestPrivate::NewLC(observer, session);
+    CleanupStack::Pop(self);
+    return self;
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbAsyncRequestPrivate* 
+    HsActivityDbAsyncRequestPrivate::NewLC(HsActivityDbAsyncRequestObserver& observer,
+                                           HsActivityDbClientPrivate& session)
+{
+    HsActivityDbAsyncRequestPrivate* self = 
+        new (ELeave)HsActivityDbAsyncRequestPrivate(observer, session);
+    CleanupStack::PushL(self);
+    self->mDataBuf.CreateL(64);
+    return self;
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbAsyncRequestPrivate::HsActivityDbAsyncRequestPrivate(HsActivityDbAsyncRequestObserver &observer,
+                                                                 HsActivityDbClientPrivate &session)
+:
+    CActive(EPriorityStandard),
+    mObserver(observer),
+    mSession(session),
+    mRequestType(-1),
+    mDataSize()
+{
+    CActiveScheduler::Add(this);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbAsyncRequestPrivate::~HsActivityDbAsyncRequestPrivate()
+{
+    mDataBuf.Close();
+    Cancel();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbAsyncRequestPrivate::DoCancel()
+{
+    if(IsActive()) {
+    mSession.cancelWaitActivity();
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbAsyncRequestPrivate::RunL()
+{
+    RBuf8 buff;
+    CleanupClosePushL(buff);
+    QString data;
+    int requestResult(iStatus.Int());
+    if(KErrNone == requestResult) {
+        if(0 < mDataSize()) {
+            buff.CreateL(mDataSize());
+        }
+        mSession.getData(buff);
+        data = QString::fromAscii(reinterpret_cast<const char*>(buff.Ptr()), 
+                                  buff.Length());
+        buff.Close();
+    }
+    mObserver.asyncRequestCompleated(requestResult, mRequestType, data);
+    CleanupStack::PopAndDestroy(&buff);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbAsyncRequestPrivate::waitActivity(const QVariantHash& condition)
+{
+    mRequestType = WaitActivity;
+    iStatus = KRequestPending;
+    SetActive();
+    mDataBuf << condition;
+    mSession.sendDataAsync(mRequestType, TIpcArgs(&mDataBuf, &mDataSize), iStatus);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/s60/src/hsactivitydbclient_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,301 @@
+/*
+* 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 "hsactivitydbclient_p.h"
+#include "hsactivitydbasyncrequest_p.h"
+#include "hsactivityglobals.h"
+#include "hsserializer.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbClientPrivate::HsActivityDbClientPrivate(HsActivityDbAsyncRequestObserver& observer)
+{
+    mAsyncDataHandler = HsActivityDbAsyncRequestPrivate::NewL(observer, *this);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbClientPrivate::~HsActivityDbClientPrivate()
+{
+    delete mAsyncDataHandler;
+    Close();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::connect()
+{
+    TRAPD(errNo, connectL());
+    return errNo;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::addActivity(const QVariantHash &activity)
+{
+    TRAPD( errNo, execSimpleRequestL(AddActivity, activity);)
+    return errNo; 
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::updateActivity(const QVariantHash &activity)
+{
+    TRAPD( errNo, execSimpleRequestL(UpdateActivity, activity);)
+    return errNo; 
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::removeActivity(const QVariantHash &activity)
+{
+    TRAPD( errNo, execSimpleRequestL(RemoveActivity, activity);)
+    return errNo; 
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::removeApplicationActivities(const QVariantHash &activity)
+{
+    TRAPD( errNo, execSimpleRequestL(RemoveApplicationActivities, activity);)
+    return errNo; 
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::activities(QList<QVariantHash>& result)
+{
+    TRAPD(errNo, activitiesL(result));
+    return errNo;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::applicationActivities(QList<QVariantHash>& result, 
+                                                      const QVariantHash & condition)
+{
+    TRAPD(errNo, applicationActivitiesL(result, condition));
+    return errNo;
+}
+
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::waitActivity(const QVariantHash &activity)
+{
+    TRAPD( errNo, waitActivityL(activity);)
+    return errNo;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::launchActivity(const QVariantHash &activity)
+{
+    TRAPD( errNo, execSimpleRequestL(LaunchActivity, activity);)
+    return errNo;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClientPrivate::cancelWaitActivity()
+{
+    return SendReceive(CancelWait, TIpcArgs());
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::startServerL()
+{
+    RProcess server;
+    const TUidType uid(KNullUid, KNullUid, KActivityServerUid);
+    User::LeaveIfError(server.Create( KActivityServerName, KNullDesC, uid));
+    TRequestStatus stat;
+    server.Rendezvous( stat );
+    if ( stat != KRequestPending ) {
+        server.Kill(0);
+    } else {
+        server.Resume();
+    }
+    User::WaitForRequest(stat);
+    int errNo = (EExitPanic == server.ExitType()) ? 
+                KErrGeneral : stat.Int();
+    if(KErrCancel == errNo) {
+        errNo = KErrNone;
+    }
+    server.Close();
+    User::LeaveIfError(errNo);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::connectL()
+{
+    const int asyncMessageSlots(4);
+    const int maxRetry(4);
+    
+    TInt retry = maxRetry;
+    TInt errNo(KErrNone);
+    do {
+        errNo = CreateSession( KActivityServerName, TVersion( 0, 0, 0 ), asyncMessageSlots );
+        if( KErrNotFound != errNo && KErrServerTerminated != errNo) {
+            retry =0;
+        } else {
+            TRAP(errNo, startServerL());
+            if (KErrNone != errNo && KErrAlreadyExists != errNo) {
+                retry =0;
+            }
+        }
+    } while(--retry > 0);
+    User::LeaveIfError(errNo);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::execSimpleRequestL(int function, const QVariantHash &activity)
+{
+    RBuf8 data;
+    CleanupClosePushL(data);
+    data.CreateL(256);
+    data << activity;
+    User::LeaveIfError(SendReceive(function, TIpcArgs(&data)));
+    CleanupStack::PopAndDestroy(&data);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::requestedActivityNameL(QString& result, 
+                                                const QVariantHash &activity)
+{
+    RBuf8 data;
+    TPckgBuf<int> sizeBuf;
+    CleanupClosePushL(data);
+    data.CreateL(256);
+    data << activity;
+    User::LeaveIfError(SendReceive(RequestedActivityName, TIpcArgs(&data,&sizeBuf)));
+    if(sizeBuf() > data.MaxSize()) {
+       data.ReAlloc(sizeBuf()); 
+    }
+    User::LeaveIfError(SendReceive(GetData, TIpcArgs(&data)));
+    result = QString::fromAscii(reinterpret_cast<const char*>(data.Ptr()), 
+                                data.Length());
+    CleanupStack::PopAndDestroy(&data);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::activitiesL(QList<QVariantHash>& result)
+{
+    RBuf8 data;
+    TPckgBuf<int> sizeBuf;
+    CleanupClosePushL(data);
+    data.CreateL(256);
+    User::LeaveIfError(SendReceive(Activities, TIpcArgs(&data, &sizeBuf)));
+    if(sizeBuf() > data.MaxSize()) {
+       data.ReAlloc(sizeBuf()); 
+    }
+    User::LeaveIfError(SendReceive(GetData, TIpcArgs(&data)));
+    result << data;
+    CleanupStack::PopAndDestroy(&data);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::applicationActivitiesL(QList<QVariantHash>& result, 
+                                                     const QVariantHash & condition)
+{
+    RBuf8 data;
+    TPckgBuf<int> sizeBuf;
+    CleanupClosePushL(data);
+    data.CreateL(256);
+    data << condition;
+    User::LeaveIfError(SendReceive(ApplicationActivities, TIpcArgs(&data, &sizeBuf)));
+    if(sizeBuf() > data.MaxSize()) {
+       data.ReAlloc(sizeBuf()); 
+    }
+    User::LeaveIfError(SendReceive(GetData, TIpcArgs(&data)));
+    result << data;
+    CleanupStack::PopAndDestroy(&data);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::waitActivityL(const QVariantHash &activity)
+{
+    if(mAsyncDataHandler->IsActive()) {
+        User::Leave(KErrServerBusy);
+    } else {
+        mAsyncDataHandler->waitActivity(activity);
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::getData(RBuf8& data)
+{
+    SendReceive(GetData, TIpcArgs(&data));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClientPrivate::sendDataAsync(int func,
+                                              const TIpcArgs &data, 
+                                              TRequestStatus& status)
+{
+    SendReceive(func, data, status);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbclient/src/hsactivitydbclient.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,138 @@
+/*
+* 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 "hsactivitydbclient.h"
+#include "hsactivitydbclient_p.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbClient::HsActivityDbClient(QObject* obj)
+:
+    QObject(obj),
+    d_ptr(0)
+{
+    d_ptr = new HsActivityDbClientPrivate(*this);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityDbClient::~HsActivityDbClient()
+{
+    delete d_ptr;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::connect()
+{
+    return d_ptr->connect();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityDbClient::asyncRequestCompleated(int result, 
+                                                int requestType, 
+                                                const QString& data)
+{
+    switch(requestType){
+    case WaitActivity:
+        if( KErrNone == result ) {
+            emit activityRequested(data);
+        }
+        break;
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::addActivity(const QVariantHash &activity)
+{
+    return d_ptr->addActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::updateActivity(const QVariantHash &activity)
+{
+    return d_ptr->updateActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::removeActivity(const QVariantHash &activity)
+{
+    return d_ptr->removeActivity(activity);
+}
+    
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::removeApplicationActivities(const QVariantHash &activity)
+{
+    return d_ptr->removeApplicationActivities(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::activities(QList<QVariantHash>& result)
+{
+    return d_ptr->activities(result);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::applicationActivities(QList<QVariantHash> & result, 
+                                              const QVariantHash & conditions)
+{
+    return d_ptr->applicationActivities(result, conditions);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::waitActivity(const QVariantHash &activity)
+{
+    return d_ptr->waitActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityDbClient::launchActivity(const QVariantHash &activity)
+{
+    return d_ptr->launchActivity(activity);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/hsactivitydbserver.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+#
+
+TEMPLATE = app
+TARGET = hsactivitydbserver 
+
+QT        += core \
+             gui \
+             sql 
+
+HEADERS   += ../inc/hsactivitydbclientinterface.h \
+             inc/hsactivity.h \
+             inc/hsactivityserver.h \
+             inc/hsactivitystorage.h \
+			 inc/hsactivitystorage_p.h
+
+SOURCES   += src/hsactivityserver.cpp \
+			 src/hsactivitystorage.cpp \
+             src/hsactivitystorage_p.cpp
+
+symbian{
+TARGET.UID3 = 0x200267B4
+HEADERS   += ../s60/inc/hsactivityglobals.h \
+             ../s60/inc/hsserializer.h \
+             s60/inc/hsactivityserver_p.h \
+             s60/inc/hsactivitysession_p.h
+			 
+
+SOURCES   += s60/src/main.cpp \
+             ../s60/src/hsserializer.cpp \
+             s60/src/hsactivityserver_p.cpp \
+			 s60/src/hsactivitysession_p.cpp
+
+TARGET.CAPABILITY = ALL -TCB
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivity.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,72 @@
+/*
+* 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 HSACTIVITY_H
+#define HSACTIVITY_H
+
+
+const char ActivityOrganization [] = "nokia";
+
+const char ActivityApplication [] = "hsactivitydbserver";
+
+const char ActivityStorageDriver [] = "QSQLITE";
+
+const char ActivityStorageName [] = "ActivitySQLClient";
+
+const char ActivityStorageProperty [] = "activitydatabase";
+
+const char ActivityDefaultStorage [] = "activitydatabase.db";
+
+const char ActivityTableKeyword [] = ":Table";
+const char ActivityDataKeyword [] = ":Data";
+
+
+
+const char ActivityCreateQuery [] = "CREATE TABLE Activities(" \
+                                    "ApplicationId INTEGER NOT NULL," \
+                                    "ActivityName TEXT NOT NULL," \
+                                    "Data BLOB NOT NULL," \
+                                    "PRIMARY KEY ( ApplicationId, ActivityName ) )";
+
+const char ActivityDropQuery [] = "DROP TABLE :Table";
+
+const char ActivitySelectActivityQuery [] = "SELECT ApplicationId FROM Activities WHERE " \
+                                            "ApplicationId = :ApplicationId AND " \
+                                            "ActivityName = :ActivityName";
+
+const char ActivityUpdateActivityQuery [] = "UPDATE Activities SET Data = :Data WHERE " \
+                                            "ApplicationId = :ApplicationId AND " \
+                                            "ActivityName = :ActivityName";
+
+const char ActivityInsertActivityQuery [] = "INSERT INTO Activities( ApplicationId, ActivityName, Data ) VALUES " \
+                                            "( :ApplicationId, :ActivityName, :Data )";
+
+const char ActivitySelectActiveQuery [] = "SELECT ActivityName FROM Activities WHERE " \
+                                          "ApplicationId = :ApplicationId";
+
+const char ActivityActivitiesQuery [] = "SELECT Data FROM Activities";
+
+const char ActivityApplicationActivitiesQuery [] = "SELECT Data FROM Activities " \
+                                                   "WHERE ApplicationId = :ApplicationId";
+
+const char ActivityDeleteActivityQuery [] = "DELETE FROM Activities WHERE " \
+                                            "ApplicationId = :ApplicationId AND " \
+                                            "ActivityName = :ActivityName";
+
+const char ActivityDeleteApplicationActivitiesQuery [] = "DELETE FROM Activities WHERE " \
+                                                         "ApplicationId = :ApplicationId";
+
+#endif //HSACTIVITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivityserver.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 HSACTIVITYSERVER_H
+#define HSACTIVITYSERVER_H
+
+#include "hsactivitydbclientinterface.h"
+
+class HsActivityServerPrivate;
+
+/**
+ * Class implemets server functionality to store and retrieve activity
+ */
+class HsActivityServer
+{
+public:
+    /**
+     * Constructor
+     * @param storage - reference to initialized activity storage
+     */
+    HsActivityServer(HsActivityDbClientInterface& storage);
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityServer();
+    
+    /**
+     * Function establish server and initialize listening proces
+     * @return true on succees, false otherwise 
+     */
+    bool start();
+private:
+    /**
+     * Private server implementation
+     */
+    HsActivityServerPrivate* d_ptr;
+};
+
+#endif //HSACTIVITYSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivitystorage.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,93 @@
+/*
+* 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 HSACTIVITYSTORAGE_H
+#define HSACTIVITYSTORAGE_H
+#include "hsactivitydbclientinterface.h"
+class HsActivityStoragePrivate;
+
+/**
+ * Class implements HsActivityDbClientInterface and storage functionality
+ */
+class HsActivityStorage: public HsActivityDbClientInterface
+{
+public:
+    /**
+     * Constructor
+     */
+    HsActivityStorage();
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityStorage();
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::addActivity(const QVariantHash&)
+     */
+    int addActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::updateActivity(const QVariantHash&)
+     */
+    int updateActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::removeActivity(const QVariantHash &)
+     */
+    int removeActivity(const QVariantHash &activity);
+
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::removeApplicationActivities(const QVariantHash &)
+    */
+    int removeApplicationActivities(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::activities(QList<QVariantHash> &)
+     */
+    int activities(QList<QVariantHash>& result);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::applicationActivities(QList<QVariantHash> &, const QVariantHash &)
+     */
+    int applicationActivities(QList<QVariantHash>& result, 
+                              const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::waitActivity(const QVariantHash &)
+     */
+    int waitActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::launchActivity(const QVariantHash &)
+     */
+    int launchActivity(const QVariantHash &activity);
+private:
+    /**
+     * Private storage implementation
+     * Own.
+     */
+    HsActivityStoragePrivate* d_ptr;
+};
+#endif //HSACTIVITYSTORAGE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/inc/hsactivitystorage_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,152 @@
+/*
+* 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 HSACTIVITYSTORAGEPRIVATE_H
+#define HSACTIVITYSTORAGEPRIVATE_H
+#include "hsactivitydbclientinterface.h"
+#include <QSqlDatabase>
+
+/**
+ * Class implements HsActivityDbClientInterface and storage functionality using
+ * database subsystem 
+ */
+class HsActivityStoragePrivate: public HsActivityDbClientInterface
+{
+public:
+    /**
+     * Constructor
+     */
+    HsActivityStoragePrivate();
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityStoragePrivate();
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::addActivity(const QVariantHash&)
+     */
+    int addActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::updateActivity(const QVariantHash&)
+     */
+    int updateActivity(const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::removeActivity(const QVariantHash &)
+     */
+    int removeActivity(const QVariantHash &activity);
+
+   /**
+    * Interface implementation.
+    * @see int HsActivityDbClientInterface::removeApplicationActivities(const QVariantHash &)
+    */
+    int removeApplicationActivities(const QVariantHash &activity);
+
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::requestedActivityName( QString &, const QVariantHash &)
+     */
+    int requestedActivityName(QString& result, 
+                              const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::activities(QList<QVariantHash> &)
+     */
+    int activities(QList<QVariantHash> &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::applicationActivities(QList<QVariantHash> &, const QVariantHash &)
+     */
+    int applicationActivities(QList<QVariantHash> &, const QVariantHash &);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::waitActivity(const QVariantHash &)
+     */
+    int waitActivity(const QVariantHash &activity);
+    
+    /**
+     * Interface implementation.
+     * @see int HsActivityDbClientInterface::launchActivity(const QVariantHash &)
+     */
+    int launchActivity(const QVariantHash &activity);
+private:
+    /**
+     * Function check database structure
+     * @return true if structure is valid, false otherwise
+     */
+    bool checkTables();
+    
+    /**
+     * Function create database structure
+     */
+    void recreateTables();
+    
+    /**
+     * Function return last SQL query error code
+     * @param querty - executed sql query
+     * @return SQL query error code  
+     */
+    int getSqlErrorCode(const QSqlQuery& query);
+    
+    /**
+     * Function exeute SQL query
+     * @param query - SQL 
+     * @return true on succees, false otherwise
+     */
+    bool exec(QSqlQuery& query);
+    
+    /**
+     * Function exeute SQL query
+     * @param query - SQL query that has to be executed
+     * @return true on succees, false otherwise
+     */
+    bool exec(const QString &query, const QVariantHash& params);
+    
+    /**
+     * Funciton bind provided filtering rules with prepared SQL query
+     * @param query - SQL query 
+     * @param activity - filtering rules
+     * @param additionalData - additional filetering rules
+     */
+    void bind( QSqlQuery& query, 
+               const QVariantHash &activity, 
+               const QVariantHash &additionalData = QVariantHash());
+    
+    /**
+     * Funciton get records that match conditions
+     * @param result - output destination 
+     * @param query - SQL query sting
+     * @param conditions - query conditions
+     */
+    int activities(QList<QVariantHash> &results, 
+                   const QString &query,
+                   const QVariantHash &conditions);
+
+private:
+    /**
+     * Connectioin to SQL engine
+     */
+    QSqlDatabase mConn;
+};
+#endif //HSACTIVITYSTORAGEPRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/s60/inc/hsactivityserver_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 HSACTIVITYSERVERPRIVATE_H
+#define HSACTIVITYSERVERPRIVATE_H
+
+#include <e32base.h>
+#include "hsactivitydbclientinterface.h"
+
+/**
+ * Class implemets server functionality for S60 enviroment
+ */
+class HsActivityServerPrivate : public CServer2 
+{
+public:
+    /**
+     * Constructor
+     */
+    HsActivityServerPrivate(HsActivityDbClientInterface& storage);
+    
+    /**
+     * Destructor
+     */
+    ~HsActivityServerPrivate();
+    
+    /**
+     * Function establish server and initialize listening proces
+     * @return true on succees, false otherwise 
+     */
+    bool start();
+    
+    /**
+     * Function look for active application session and complete pending message 
+     */
+    void notifyL(int applicationId, const QString& activityName);
+    
+    /**
+     * Cancel notification 
+     */
+    void cancelNotify(int applicationId);
+    
+    /**
+     * Function add item to pending messages
+     */
+    void waitNotification(int applicationId, const RMessage2& msg);
+private:
+    /**
+     * Function create new client session to handle its request
+     * @param version - client implementation version
+     * @param message - request message
+     */
+    CSession2* NewSessionL(const TVersion& version,const RMessage2& message)const;
+
+private:
+    /**
+     * Reference to initialized storage client
+     */
+    HsActivityDbClientInterface& mStorage;
+    
+    QHash<int,RMessage2> mPendingMessage;
+};
+
+#endif //HSACTIVITYSERVERPRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/s60/inc/hsactivitysession_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,155 @@
+/*
+* 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 ACTIVITYSESSIONPRIVATE_H
+#define ACTIVITYSESSIONPRIVATE_H
+#include <e32base.h>
+#include "hsactivitydbclientinterface.h"
+/**
+ * Class impolements client session for S60 enviroment. 
+ * Class is responsible for request handling and data translations
+ */
+class HsActivitySessionPrivate: public CSession2
+{
+public:
+    /**
+     * Constructor
+     * @param storage - reference to initialized activity storage
+     */
+    HsActivitySessionPrivate(HsActivityDbClientInterface& storage);
+    
+    /**
+     * Destructor
+     */
+    ~HsActivitySessionPrivate();
+    
+    /**
+     * Implements interface
+     * @see void CSession2::ServiceL(const RMessage2&)
+     */
+    void ServiceL(const RMessage2& message);
+    
+    /**
+     * Implements interface
+     * @see void CSession2::ServiceError(const RMessage2 &, TInt)
+     */
+    void ServiceError(const RMessage2 &message, TInt error);
+    
+    void LaunchActivityL(const RMessage2 &message, const QString &name );
+    
+    void CancelNotify(RMessage2& message);
+private:
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleAddActivityL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleUpdateActivityL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleRemoveActivityL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleRemoveApplicationActivitiesL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleActivitiesL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleApplicationActivitiesL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to server
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleLaunchActivityL(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to server
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleWaitActivityL(const RMessage2& message);
+    
+    /**
+	 * Function cancels subscribtion
+	 * @param message - request message 
+	 */
+    void HandleCancelWaitActivity(const RMessage2& message);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void HandleGetDataL(const RMessage2& message);
+    
+    void LaunchActivityL();
+    
+    void WaitActivityL(const RMessage2& message);
+    
+    void CancelNotify();
+        
+    
+    /**
+     * Function deserialize data for request message
+     * Function can leave on failure.
+     */
+    void ReadDataL(const RMessage2& src);
+    
+    /**
+     * Function handle data translation and forward request to storage client
+     * Function can leave on failure.
+     * @param message - request message 
+     */
+    void LeaveIfNotZero(int errNo);
+private:
+    /**
+     * Reference to storage client
+     */
+    HsActivityDbClientInterface& mStorage;
+    RBuf8 mData;
+    QVariantHash mActivity;
+    QList<QVariantHash> mResult;
+    QString mName;
+    int mAppId;
+};
+#endif // ACTIVITYSESSIONPRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/s60/src/hsactivityserver_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* 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: Application entry point
+*
+*/
+#include "hsactivityserver_p.h"
+#include "hsactivitysession_p.h"
+#include "hsactivityglobals.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityServerPrivate::HsActivityServerPrivate(HsActivityDbClientInterface& storage)
+:
+    CServer2( EPriorityNormal, ESharableSessions),
+    mStorage(storage)
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityServerPrivate::~HsActivityServerPrivate()
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+bool HsActivityServerPrivate::start()
+{
+    return ( KErrNone == Start(KActivityServerName) );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityServerPrivate::notifyL(int applicationId, 
+                                     const QString& activityName)
+{
+    if(mPendingMessage.end() != mPendingMessage.find(applicationId)) {
+        static_cast<HsActivitySessionPrivate*>(mPendingMessage.find(applicationId).value().Session())
+            ->LaunchActivityL(mPendingMessage.find(applicationId).value(), activityName );
+        mPendingMessage.erase(mPendingMessage.find(applicationId));
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityServerPrivate::waitNotification(int applicationId, 
+                                               const RMessage2& msg)
+{
+    if(mPendingMessage.find(applicationId) != mPendingMessage.end()) {
+        msg.Kill(EBadMessageNumber);
+    }
+    mPendingMessage.insert(applicationId,msg);
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityServerPrivate::cancelNotify(int applicationId)
+	{
+	if(mPendingMessage.end() != mPendingMessage.find(applicationId)) 
+		{
+		static_cast<HsActivitySessionPrivate*>(mPendingMessage.find(applicationId).value().Session())
+			->CancelNotify(mPendingMessage.find(applicationId).value());
+	    mPendingMessage.erase(mPendingMessage.find(applicationId));
+		}
+	}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CSession2* HsActivityServerPrivate::NewSessionL(const TVersion&,
+                                               const RMessage2&)const
+{
+    return new (ELeave) HsActivitySessionPrivate(mStorage);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/s60/src/hsactivitysession_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,286 @@
+/*
+* 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: Application entry point
+*
+*/
+#include "hsactivityserver_p.h"
+#include "hsactivitysession_p.h"
+#include "hsactivityglobals.h"
+#include "hsserializer.h"
+#include <qglobal.h>
+
+const char ActivityPrimaryKeyFormat [] = "%1:%2";
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivitySessionPrivate::HsActivitySessionPrivate(HsActivityDbClientInterface& storage)
+: mStorage(storage), mAppId(KErrNotFound)
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivitySessionPrivate::~HsActivitySessionPrivate()
+{
+	 CancelNotify();
+     mData.Close();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::ServiceL(const RMessage2& message)
+{
+    mActivity.clear();
+    mResult.clear();
+    mName.clear();
+    
+    int errNo(KErrNone);
+    switch(message.Function()) {
+    case AddActivity: HandleAddActivityL(message); break;
+    case UpdateActivity: HandleUpdateActivityL(message); break;
+    case RemoveActivity: HandleRemoveActivityL(message); break;
+    case RemoveApplicationActivities: HandleRemoveApplicationActivitiesL(message); break;
+    case Activities: HandleActivitiesL(message);break;
+    case ApplicationActivities: HandleApplicationActivitiesL(message);break;
+    case LaunchActivity: HandleLaunchActivityL(message);break;
+    case WaitActivity: HandleWaitActivityL(message);return; //!!!!! This message shouldn't be compleated !!!!!
+    case GetData: HandleGetDataL(message); break;
+    case CancelWait: HandleCancelWaitActivity(message); break;
+    default:
+        message.Panic(KErr400, CServer2::EBadMessageNumber);
+    }
+    message.Complete(KErrNone);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::ServiceError(const RMessage2 &message, TInt error)
+{
+    message.Complete(error);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleAddActivityL(const RMessage2& message)
+{
+    ReadDataL(message);
+    LeaveIfNotZero(mStorage.addActivity(mActivity));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleUpdateActivityL(const RMessage2& message)
+{
+    ReadDataL(message);
+    LeaveIfNotZero(mStorage.updateActivity(mActivity));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleRemoveActivityL(const RMessage2& message)
+{
+    ReadDataL(message);
+    LeaveIfNotZero(mStorage.removeActivity(mActivity));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleRemoveApplicationActivitiesL(const RMessage2& message)
+{
+    ReadDataL(message);
+    LeaveIfNotZero(mStorage.removeApplicationActivities(mActivity));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleActivitiesL(const RMessage2& message)
+{
+    int errNo(KErrNone);
+    QT_TRYCATCH_LEAVING(errNo = mStorage.activities(mResult));
+    LeaveIfNotZero(errNo);
+    mData << mResult;
+    TPckgC<int> dataSize(mData.Size());
+    message.WriteL(1, dataSize);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleApplicationActivitiesL(const RMessage2& message)
+{
+    int errNo(KErrNone);
+    ReadDataL(message);
+    QT_TRYCATCH_LEAVING(errNo = mStorage.applicationActivities(mResult, mActivity));
+    LeaveIfNotZero(errNo);
+    mData << mResult;
+    TPckgC<int> dataSize(mData.Size());
+    message.WriteL(1, dataSize);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleLaunchActivityL(const RMessage2& message)
+{
+    ReadDataL(message);
+    LaunchActivityL();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleWaitActivityL(const RMessage2& message)
+{
+    ReadDataL(message);
+    WaitActivityL(message);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleCancelWaitActivity(const RMessage2& /*message*/)
+	{
+	CancelNotify();
+	}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::HandleGetDataL(const RMessage2& message)
+{
+    message.WriteL(0, mData);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::LaunchActivityL()
+{
+    CServer2* const server(const_cast<CServer2*>(Server()));
+    if(mActivity.end() == mActivity.find(ActivityApplicationKeyword) || 
+       mActivity.end() == mActivity.find(ActivityActivityKeyword)) {
+        User::Leave(KErrCorrupt);
+    }
+    static_cast<HsActivityServerPrivate*>
+        (server)->notifyL(mActivity.find(ActivityApplicationKeyword).value().toInt(), 
+                         mActivity.find(ActivityActivityKeyword).value().toString());
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::LaunchActivityL(const RMessage2 &message, 
+                                               const QString &name )
+{
+    if (mData.MaxSize() < name.toAscii().length()){
+        mData.ReAlloc( name.toAscii().length());
+    }
+    mData.Copy(reinterpret_cast<const TUint8*>(name.toAscii().data()),
+                                               name.toAscii().length());
+    TPckgC<int> dataSize(mData.Size());
+    message.WriteL(1, dataSize);
+    message.Complete(KErrNone);
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::WaitActivityL(const RMessage2& msg)
+{
+    CServer2* const server(const_cast<CServer2*>(Server()));
+    if(mActivity.end() == mActivity.find(ActivityApplicationKeyword)) {
+        User::Leave(KErrCorrupt);
+    }
+    mAppId = mActivity.find(ActivityApplicationKeyword).value().toInt();
+    static_cast<HsActivityServerPrivate*>
+        (server)->waitNotification(mAppId, msg);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::CancelNotify()
+	{
+	if ( mAppId != KErrNotFound )
+	    {
+	    CServer2* const server(const_cast<CServer2*>(Server()));
+	    static_cast<HsActivityServerPrivate*>(server)->cancelNotify(mAppId);
+	    mAppId = KErrNotFound;
+	    }
+	}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::CancelNotify(RMessage2& message)
+	{
+	message.Complete(KErrCancel);
+	}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::ReadDataL(const RMessage2& src)
+{
+    int srcLength = src.GetDesLength(0);
+    User::LeaveIfError(srcLength);
+    RBuf8 buffer;
+    CleanupClosePushL(buffer);
+    buffer.CreateL(srcLength);
+    src.ReadL( 0, buffer, 0);
+    if (buffer.Length() != srcLength) {
+        User::Leave(KErrCorrupt);
+    }
+    mActivity << buffer;
+    CleanupStack::PopAndDestroy(&buffer);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivitySessionPrivate::LeaveIfNotZero(int errNo)
+{
+    if (KErrNone != errNo) {
+        User::LeaveIfError(errNo);
+        User::Leave(KErrGeneral);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/s60/src/main.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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: Application entry point
+*
+*/
+#include <QtCore>
+#include <QApplication>
+
+#include "hsactivityserver.h"
+#include "hsactivitystorage.h"
+
+
+
+int main(int argc, char *argv[])
+{
+    QApplication app(argc, argv);
+    HsActivityStorage storage;
+    HsActivityServer server(storage);
+    int retVal(KErrGeneral);
+    if( server.start() ){
+        RProcess::Rendezvous(KErrNone);
+        retVal = app.exec();
+    }else
+        RProcess::Rendezvous(retVal);
+    return retVal;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/src/hsactivityserver.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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: Application entry point
+*
+*/
+#include "hsactivityserver.h"
+#include "hsactivityserver_p.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityServer::HsActivityServer(HsActivityDbClientInterface& storage)
+:
+    d_ptr(new HsActivityServerPrivate(storage))
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityServer::~HsActivityServer()
+{
+    delete d_ptr;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+bool HsActivityServer::start()
+{
+    return d_ptr->start();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/src/hsactivitystorage.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,110 @@
+/*
+* 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: Application entry point
+*
+*/
+#include "hsactivitystorage.h"
+#include "hsactivitystorage_p.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityStorage::HsActivityStorage()
+:
+d_ptr(new HsActivityStoragePrivate())
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityStorage::~HsActivityStorage()
+{
+    delete d_ptr;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::addActivity(const QVariantHash& activity)
+{
+    return d_ptr->addActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::updateActivity(const QVariantHash& activity)
+{
+    return d_ptr->updateActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::removeActivity(const QVariantHash& activity)
+{
+    return d_ptr->removeActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::removeApplicationActivities(const QVariantHash& activity)
+{
+    return d_ptr->removeApplicationActivities(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::activities(QList<QVariantHash>& result)
+{   
+    return d_ptr->activities(result);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::applicationActivities(QList<QVariantHash>& result, 
+                                             const QVariantHash &activity)
+{
+    return d_ptr->applicationActivities(result, activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::waitActivity(const QVariantHash &activity)
+{
+    return d_ptr->waitActivity(activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStorage::launchActivity(const QVariantHash &activity)
+{
+    return d_ptr->launchActivity(activity);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/src/hsactivitystorage_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,345 @@
+/*
+* 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 <QSqlQuery>
+#include <QSqlError>
+#include <QStringList>
+#include <QSettings>
+#include <QSqlDriver>
+#include <QDebug>
+#include "hsactivitystorage_p.h"
+#include "hsactivity.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityStoragePrivate::HsActivityStoragePrivate()
+{
+    // determine database localization
+    QSettings settings(ActivityOrganization, ActivityApplication);
+    settings.setValue(ActivityStorageProperty, ActivityDefaultStorage);
+    if (!settings.contains(ActivityStorageProperty)) {
+        settings.setValue(ActivityStorageProperty, ActivityDefaultStorage);
+    }
+    QString databaseFile = settings.value(ActivityStorageProperty).toString();
+    
+    if (QSqlDatabase::contains(ActivityStorageName)) {
+        mConn = QSqlDatabase::database(ActivityStorageName);
+    } else {   
+        mConn = QSqlDatabase::addDatabase(ActivityStorageDriver, ActivityStorageName);
+        mConn.setDatabaseName(databaseFile);    
+        if (!mConn.open()) {
+            qWarning(qPrintable(mConn.lastError().text()));
+            return;
+        }
+    }
+    if (!checkTables()) {
+        recreateTables();
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+HsActivityStoragePrivate::~HsActivityStoragePrivate()
+{
+    mConn.close();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::addActivity(const QVariantHash &activity)
+{
+    // stream whole entry to bytearray
+    QByteArray streamedData;
+    QDataStream stream(&streamedData, QIODevice::WriteOnly);
+    stream << activity;
+    
+    //insert data
+    QSqlQuery query(mConn);
+    query.prepare(ActivitySelectActivityQuery);
+    bind(query, activity);
+    exec(query);
+    if(query.next()) {
+        return KErrGeneral;
+    }
+    query.prepare(ActivityInsertActivityQuery);
+    QVariantHash additionalData;
+    additionalData.insert(ActivityDataKeyword, streamedData);
+    bind(query, activity, additionalData);
+    exec(query);
+    return 0>=query.numRowsAffected() ? KErrGeneral : getSqlErrorCode(query);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::updateActivity(const QVariantHash &activity)
+{
+    // stream whole entry to bytearray
+    QByteArray streamedData;
+    QDataStream stream(&streamedData, QIODevice::WriteOnly);
+    stream << activity;
+    
+    // update
+    QSqlQuery query(mConn);
+    query.prepare(ActivityUpdateActivityQuery);
+    QVariantHash additionalData;
+    additionalData.insert(ActivityDataKeyword, streamedData);
+    bind(query, activity, additionalData);
+    exec(query);
+    return 0>=query.numRowsAffected() ? KErrGeneral : getSqlErrorCode(query);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::removeActivity(const QVariantHash &activity)
+{
+    return exec(ActivityDeleteActivityQuery, activity);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::removeApplicationActivities(const QVariantHash &activity)
+{
+    return exec(ActivityDeleteApplicationActivitiesQuery, activity);
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::requestedActivityName(QString& result, 
+                                                    const QVariantHash &activity)
+{
+    QSqlQuery query(mConn);
+    query.prepare(ActivitySelectActiveQuery);
+    bind(query, activity);
+    int retVal(KErrNone);
+    if (exec(query) && query.next()) {
+        result = query.value(0).toString();
+    } else {
+        retVal = KErrNotFound;
+    }
+    return retVal;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::activities(QList<QVariantHash>& result)
+{
+    return activities(result, ActivityActivitiesQuery, QVariantHash());
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::applicationActivities(QList<QVariantHash> & result, 
+                                                    const QVariantHash & condition)
+{
+    return activities(result, ActivityApplicationActivitiesQuery, condition);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::waitActivity(const QVariantHash &)
+{
+    return KErrNotSupported;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::launchActivity(const QVariantHash &)
+{
+    return KErrNotSupported;
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+bool HsActivityStoragePrivate::checkTables()
+{
+    return (QStringList("Activities") == mConn.tables()); 
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityStoragePrivate::recreateTables()
+{
+    //start sql transaction
+    if (!mConn.transaction()) {
+        qErrnoWarning(qPrintable(mConn.lastError().text()));
+        return;
+    }
+    
+    // drop any existing tables
+    QSqlQuery query(mConn);
+    foreach (const QString &tableName, mConn.tables()) {
+        query.prepare(ActivityDropQuery);
+        query.bindValue(ActivityTableKeyword, tableName);
+        exec(query);
+    }
+    
+    // create new table
+    query.prepare(ActivityCreateQuery);
+    exec(query);
+    
+    //finish sql transaction
+    if (!mConn.commit()) {
+        qErrnoWarning(qPrintable(mConn.lastError().text()));
+    }  
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::getSqlErrorCode(const QSqlQuery& query)
+{
+    const QSqlError err(query.lastError());
+    const QString errStr(err.text());
+    
+    if (QSqlError ::NoError == err.type()) {
+        return 0;
+    } else {
+        qErrnoWarning(qPrintable(errStr));
+        return err.number();
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+bool HsActivityStoragePrivate::exec(QSqlQuery& query)
+{
+    const bool retVal = query.exec();
+    qErrnoWarning(qPrintable(query.lastQuery()));
+    if (!retVal) {
+        getSqlErrorCode(query);
+    }
+    return retVal;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+bool HsActivityStoragePrivate::exec(const QString &queryStr, const QVariantHash& params)
+{
+    QSqlQuery query(mConn);
+    query.prepare(queryStr);
+    bind(query, params);
+    query.exec();
+    return getSqlErrorCode(query);
+    
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsActivityStoragePrivate::bind( QSqlQuery& query, 
+                                   const QVariantHash &activity,
+                                   const QVariantHash &additionalData)
+{
+    const QChar tag(' ');
+    QString queryString( query.lastQuery() );
+    QVariantHash::const_iterator iter;
+    int offset(0);
+    QStringList tokens;
+    
+    //explode SQL query to tokens 
+    do {
+        offset = queryString.indexOf(tag, 0);
+        if (0 < offset) {
+            tokens << queryString.left(offset++);
+            queryString = queryString.right(queryString.length() - offset);
+        } else {
+            if (0 < queryString.length()) {
+                tokens << queryString;
+            }
+            break;
+        }
+    } while (true);
+    
+    //current Sql driver doesnt support proper query formating.
+    //reuest filtering data has to be binded in right order.
+    QStringList::iterator token = tokens.begin();
+    //iterate all tokens
+    for (; token != tokens.end(); token = tokens.erase(token)) {
+        //iterate all provided data and chcek if it match pattern
+        for ( iter = activity.constBegin();
+             iter != activity.constEnd(); 
+             ++iter ) {
+             if( (*token).contains(iter.key()) ){
+                query.bindValue(iter.key(), iter.value());
+                break;
+            }
+        }
+        for (iter = additionalData.constBegin(); 
+            iter != additionalData.constEnd(); 
+            ++iter) {
+            if ((*token).contains(iter.key())) {
+                query.bindValue(iter.key(), iter.value());
+                break;
+            }
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+int HsActivityStoragePrivate::activities(QList<QVariantHash> &results, 
+                                         const QString &queryStr,
+                                         const QVariantHash &conditions)
+{
+    results.clear();
+    
+    QSqlQuery query(mConn);
+    query.prepare(queryStr);
+    bind(query, conditions);
+    if (exec(query)) {
+        QVariantHash activityEntry;
+        while (query.next()) {
+            activityEntry.clear();
+            QByteArray data(query.value(0).toByteArray());
+            QDataStream stream(&data, QIODevice::ReadOnly);
+            stream >> activityEntry;
+            results.append(activityEntry);
+        }
+    }
+    return getSqlErrorCode(query);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/hsactivitydbserver/src/main.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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: Application entry point
+*
+*/
+#include <QtCore>
+#include <QCoreApplication>
+
+#include "hsactivityserver.h"
+#include "hsactivitystorage.h"
+
+
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+    HsActivityStorage storage;
+    HsActivityServer server(storage);
+    int retVal(KErrGeneral);
+    if( server.start() ){
+        retVal = app.exec();
+    }
+    return retVal;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/inc/hsactivitydbclientinterface.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* 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 HSACTIVITYDBCLIENTINTERFACE_H
+#define HSACTIVITYDBCLIENTINTERFACE_H
+#include <qvariant.h>
+
+/**
+ * Enumerate supported functions
+ */
+enum ClientFunctions 
+{
+    AddActivity =0,
+    UpdateActivity,
+    RemoveActivity,
+    RemoveApplicationActivities,
+    RequestedActivityName,
+    Activities,
+    ApplicationActivities,
+    WaitActivity,
+    LaunchActivity,
+    GetData,
+    CancelWait
+};
+
+const char ActivityApplicationKeyword [] = ":ApplicationId";
+const char ActivityActivityKeyword [] = ":ActivityName";
+
+class HsActivityDbClientInterface
+{
+public:
+    
+    /**
+     * Function save provided avtivity in activity storage
+     * @param activity - activity to store
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int addActivity(const QVariantHash &activity) =0;
+    
+    /**
+     * Function update exiting activity
+     * @param activity - filtering rules
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int updateActivity(const QVariantHash &activity) =0;
+    
+    /**
+     * Function delete activity
+     * @param activity - filtering rules
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int removeActivity(const QVariantHash &activity) =0;
+    
+    /**
+     * Function delete activity for application
+     * @param activity - filtering rules
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int removeApplicationActivities(const QVariantHash &activity) =0;
+    
+    /**
+     * Function return list of all activity
+     * @param result - destination list
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int activities(QList<QVariantHash>& result) =0;
+    
+    /**
+     * Function return list of all activity
+     * @param result - destination list,
+     * @param activity - filtering rules
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int applicationActivities(QList<QVariantHash>& result, 
+                                      const QVariantHash &activity) =0;
+    
+    /**
+     * Function subscribe to activity
+     * @param  activity - filtering rules
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int waitActivity(const QVariantHash &activity)=0;
+    
+    /**
+     * Function launch application activity
+     * @param activity - filtering rules 
+     * @return 0 on succees, error code otherwise 
+     */
+    virtual int launchActivity(const QVariantHash &activity)=0;
+};
+#endif //HSACTIVITYDBCLIENTINTERFACE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/s60/inc/hsactivityglobals.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 ACTIVITYSYMBIAN_H
+#define ACTIVITYSYMBIAN_H
+
+#include <e32base.h>
+const TUid KActivityServerUid = {0x200267B4};
+_LIT( KActivityServerName, "hsactivitydbserver" );
+_LIT( KErr400, "Bad Reqest" );
+_LIT( KErr403, "Access denied" );
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/s60/inc/hsserializer.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+*
+*/
+#ifndef HSSERIALIZER_H
+#define HSSERIALIZER_H
+#include <qvariant.h>
+
+/**
+ * Operator serialize VarinatHash to RBuf8
+ */
+RBuf8& operator <<(RBuf8& dst, const QVariantHash& src);
+
+/**
+ * Operator deserialize RBuf8 to VarinatHash
+ */
+QVariantHash& operator <<(QVariantHash& dst, const TDesC8& src);
+
+/**
+ * Operator serialize QList<QVariantHash> to RBuf8
+ */
+RBuf8& operator <<(RBuf8& dst, const QList<QVariantHash>& src);
+
+/**
+ * Operator deserialize RBuf8 to QList<QVariantHash>
+ */
+QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8& src); 
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitydatabase/s60/src/hsserializer.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,82 @@
+/*
+* 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 "hsserializer.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+RBuf8& operator <<(RBuf8& dst, const QVariantHash& src)
+{
+    QByteArray buffer;
+    QDataStream stream(&buffer, QIODevice::WriteOnly);
+    
+    QT_TRYCATCH_LEAVING(stream << src);
+    const int dataLength(buffer.length());
+    const unsigned char* dataPtr(reinterpret_cast<const unsigned char*>(buffer.constData()));
+    if( dst.MaxLength() < dataLength ) {
+        dst.ReAllocL(dataLength);
+    }
+    dst.Copy(dataPtr, dataLength);
+    return dst;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+QVariantHash& operator <<(QVariantHash& dst, const TDesC8& src)
+{
+    QByteArray buffer( QByteArray::fromRawData(reinterpret_cast<const char*>(src.Ptr()), 
+                                               src.Length()) );
+    
+    QDataStream stream(&buffer, QIODevice::ReadOnly);
+    QT_TRYCATCH_LEAVING(stream >> dst);
+    return dst;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+RBuf8& operator <<(RBuf8& dst, const QList<QVariantHash>& 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<const TUint8*>(buffer.data()), buffer.length());
+    return dst;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8& src)
+{
+    QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char*>(src.Ptr()), 
+                                              src.Length()));
+    
+    QDataStream stream(&buffer, QIODevice::ReadOnly);
+    QT_TRYCATCH_LEAVING(stream >> dst);
+    return dst;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitylauncher/activitylauncher.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,31 @@
+#
+# 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 = app
+
+TARGET = activitylauncher
+
+CONFIG += hb console mobility
+MOBILITY = serviceframework
+
+SOURCES =   main.cpp \
+            activitylauncherview.cpp \
+
+HEADERS =   activitylauncherview.h \
+
+symbian {
+    TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitylauncher/activitylauncherview.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,107 @@
+/*
+* 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 "activitylauncherview.h"
+
+#include <QGraphicsLinearLayout>
+#include <QStandardItemModel>
+#include <QProcess>
+
+#include <qservicemanager.h>
+
+#include <hblabel.h>
+#include <hbapplication.h>
+#include <hbpushbutton.h>
+#include <hbgridview.h>
+
+#include <hsactivitydbclientinterface.h>
+
+QTM_USE_NAMESPACE
+
+ActivityLauncherView::ActivityLauncherView(QGraphicsItem *parent) : HbView(parent), mModel(NULL), mActivityManager(NULL)
+{
+    QServiceManager serviceManager;
+    mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+    
+    if (!mActivityManager) {
+        qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service");
+    }
+
+    // create UI
+    setTitle(tr("Activity launcher"));
+    QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
+    QGraphicsLinearLayout* statusLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+    mStatusLabel = new HbLabel(this);
+    mStatusLabel->setAlignment(Qt::AlignLeft);
+    statusLayout->setMaximumHeight(15);
+
+    HbLabel* statusHeader = new HbLabel("Status: ");
+    statusHeader->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+    statusLayout->addItem(statusHeader);
+    statusLayout->addItem(mStatusLabel);
+
+    HbGridView* activities = new HbGridView();
+    connect(activities, SIGNAL(activated(QModelIndex)), this, SLOT(itemPressed(QModelIndex)));
+    activities->setRowCount(1);
+    activities->setColumnCount(1);
+
+    activities->setScrollDirections(Qt::Horizontal);
+
+    mModel = new QStandardItemModel(this);
+    activities->setModel(mModel);
+
+    layout->addItem(statusLayout);
+    layout->addItem(activities);
+
+    setLayout(layout);
+    qApp->installEventFilter(this);
+    getActivitiesList();
+}
+
+ActivityLauncherView::~ActivityLauncherView()
+{
+	delete mActivityManager;
+}
+
+void ActivityLauncherView::getActivitiesList()
+{
+    mStatusLabel->setPlainText("Fetching activities");
+    mCurrentActivities.clear();
+    QMetaObject::invokeMethod(mActivityManager, "activitiesList", Q_RETURN_ARG(QList<QVariantHash>, mCurrentActivities));
+    mModel->clear();
+
+    foreach(const QVariantHash& activityEntry, mCurrentActivities) {
+        QStandardItem* newItem = new QStandardItem(QIcon(activityEntry.value("screenshot").value<QPixmap>()), QString("%1").arg(activityEntry.value(ActivityActivityKeyword).toInt()));
+        mModel->invisibleRootItem()->appendRow(newItem);
+    }
+    mStatusLabel->setPlainText(QString("Ready (%1 activities)").arg(mCurrentActivities.count()));
+}
+
+bool ActivityLauncherView::eventFilter(QObject* obj, QEvent* event)
+{
+    if (event->type() == QEvent::ApplicationActivate) {
+        getActivitiesList();
+    }
+    return QObject::eventFilter(obj, event);
+}
+
+void ActivityLauncherView::itemPressed(const QModelIndex& index)
+{
+    QVariantHash activity = mCurrentActivities.at(index.row());
+    int applicationId = activity.value(ActivityApplicationKeyword).toInt();
+    QString activityName = activity.value(ActivityActivityKeyword).toString();
+    QMetaObject::invokeMethod(mActivityManager, "launchActivity", Q_ARG(int, applicationId), Q_ARG(QString, activityName));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitylauncher/activitylauncherview.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* 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 ACTIVITYLAUNCHERVIEW_H
+#define ACTIVITYLAUNCHERVIEW_H
+
+#include <hbview.h>
+#include <QVariant>
+
+class HbLabel;
+class QStandardItemModel;
+    
+class ActivityLauncherView : public HbView
+{
+    Q_OBJECT
+
+public:
+    ActivityLauncherView(QGraphicsItem *parent = 0);
+    ~ActivityLauncherView();
+
+private slots:
+	void itemPressed(const QModelIndex& index);
+
+protected:
+    bool eventFilter(QObject* obj, QEvent* event);
+
+private:
+    void getActivitiesList();
+
+private:
+    QStandardItemModel* mModel;
+    QList<QVariantHash> mCurrentActivities;
+    HbLabel* mStatusLabel;
+    
+    QObject* mActivityManager;
+};
+
+#endif // ACTIVITYLAUNCHERVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitylauncher/main.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+*
+*/
+
+#include <QCoreApplication>
+
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+
+#include "activitylauncherview.h"
+
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv); 
+
+    HbMainWindow mainWindow;
+    ActivityLauncherView mainView;
+    mainWindow.addView(&mainView);
+    mainWindow.show();
+
+    return app.exec(); 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activitymanager.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+
+symbian:SUBDIRS += activitydatabase
+
+SUBDIRS +=  activityserviceplugin \
+            activitylauncher \
+            orbitintegration/hbactivityplugin 
+            
+
+
+tests:SUBDIRS += activityserviceplugin/unittests
+symbian:SUBDIRS += activityserviceplugin/symbianinstaller
+
+symbian:include(rom.pri)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityclient.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 "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 &parameters)
+{
+    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 &parameters)
+{
+    return d_ptr->updateActivity(activityId, data, parameters);
+}
+
+QList<QVariantHash> 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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityclient.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QObject>
+#include <QVariant>
+#include <QString>
+
+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 &parameters);
+    bool removeActivity(const QString &activityId);
+    bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters);
+    QList<QVariantHash> activities() const;
+    QVariant activityData(const QString &activityId) const;
+    bool waitActivity();
+
+signals:
+    void activityRequested(const QString &activityId);
+    
+private:
+    ActivityClientPrivate *d_ptr;
+    friend class ActivityClientPrivate;
+    
+};
+
+#endif // ACTIVITYCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityclient_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,103 @@
+/*
+* 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 <hsactivitydbclient.h>
+
+#include <QStringList>
+#include <QTimer>
+
+ActivityClientPrivate::ActivityClientPrivate(ActivityClient *q) : QObject(q)
+{
+    mDataStorage = new ActivityDataStorage();
+    mServerClient = new HsActivityDbClient();
+    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 &parameters)
+{
+    QVariantHash activity(parameters);
+    mDataStorage->addActivity(activityId, data);
+    RProcess process;
+    
+    activity.insert(ActivityApplicationKeyword, static_cast<int>(process.SecureId().iId));
+    activity.insert(ActivityActivityKeyword, activityId);
+    mServerClient->addActivity(activity);
+    
+    // @todo make those operations atomic
+    // @todo return real result
+    return true;
+}
+
+bool ActivityClientPrivate::removeActivity(const QString &activityId)
+{
+    QVariantHash activity;
+    RProcess process;
+    activity.insert(ActivityApplicationKeyword, static_cast<int>(process.SecureId().iId));
+    activity.insert(ActivityActivityKeyword, activityId);
+    mDataStorage->removeActivity(activityId); 
+    mServerClient->removeActivity(activity); 
+    // @todo make those operations atomic
+    // @todo return real result
+    return true;
+}
+
+bool ActivityClientPrivate::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
+{
+    QVariantHash activity(parameters);
+    RProcess process;
+    activity.insert(ActivityApplicationKeyword, static_cast<int>(process.SecureId().iId));
+    activity.insert(ActivityActivityKeyword, activityId);
+    mDataStorage->updateActivity(activityId, data);
+    mServerClient->updateActivity(activity);
+    // @todo make those operations atomic
+    // @todo return real result
+    return true;
+}
+
+QList<QVariantHash> ActivityClientPrivate::activities() const
+{
+    QVariantHash activity;
+    RProcess process;
+    activity.insert(ActivityApplicationKeyword, static_cast<int>(process.SecureId().iId));
+
+    QList<QVariantHash> activities;
+
+    mServerClient->applicationActivities(activities, activity);
+    return activities;
+}
+
+QVariant ActivityClientPrivate::activityData(const QString &activityId) const
+{
+    return mDataStorage->activityData(activityId);
+}
+
+bool ActivityClientPrivate::waitActivity()
+{
+    RProcess process;
+    QVariantHash activity;
+    activity.insert(ActivityApplicationKeyword, static_cast<int>(process.SecureId().iId));
+    return !mServerClient->waitActivity(activity);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityclient_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 ACTIVITYCLIENT_P_H
+#define ACTIVITYCLIENT_P_H
+
+#include <QObject>
+#include <QVariant>
+#include <QString>
+#include <QPixmap>
+
+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 &parameters);
+    bool removeActivity(const QString &activityId);
+    bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters);
+    QList<QVariantHash> activities() const;
+    QVariant activityData(const QString &activityId) const;
+    bool waitActivity();
+    
+    
+private:
+    ActivityClient* q_ptr;   
+    ActivityDataStorage* mDataStorage;
+    HsActivityDbClient* mServerClient;
+};
+
+#endif // ACTIVITYCLIENT_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activitydatastorage.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QSqlDatabase>
+#include <QSqlQuery>
+#include <QSqlError>
+#include <QStringList>
+
+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()));
+    }    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activitydatastorage.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QVariant>
+#include <QString>
+
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activitymanager.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+*
+*/
+
+#include "activitymanager.h"
+#include "activitymanager_p.h"
+
+ActivityManager::ActivityManager(QObject *parent) : QObject(parent), d_ptr(new ActivityManagerPrivate(this))
+{
+}
+
+ActivityManager::~ActivityManager()
+{
+}
+
+QList<QVariantHash> 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::removeActivity(int applicationId, const QString &activityId)
+{ 
+    d_ptr->removeActivity(applicationId, activityId);
+}
+
+void ActivityManager::removeApplicationActivities(int applicationId)
+{ 
+    d_ptr->removeApplicationActivities(applicationId);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activitymanager.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 ACTIVITYMANAGER_H
+#define ACTIVITYMANAGER_H
+
+#include <QObject>
+#include <QVariant>
+#include <QList>
+
+class ActivityManagerPrivate;
+
+class ActivityManager : public QObject
+{
+
+Q_OBJECT
+
+public:
+    ActivityManager(QObject *parent = 0);
+    ~ActivityManager();
+
+public slots:
+    QList<QVariantHash> activitiesList();
+    void launchActivity(const QString &uri);  
+    void launchActivity(int applicationId, const QString &activityId);  
+    void removeActivity(int applicationId, const QString &activityId);  
+    void removeApplicationActivities(int applicationId);  
+    
+private:
+    ActivityManagerPrivate *d_ptr;
+    
+    friend class ActivityManagerPrivate;
+    
+};
+
+#endif // ACTIVITYMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activitymanager_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,83 @@
+/*
+* 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 <hsactivitydbclient.h>
+
+#include <QRegExp>
+#include <QStringList>
+
+ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager *q) : QObject(q), q_ptr(q)
+{
+    mServerClient = new HsActivityDbClient();
+    mServerClient->connect();
+}
+
+ActivityManagerPrivate::~ActivityManagerPrivate()
+{
+    delete mServerClient;
+}
+
+QList<QVariantHash> ActivityManagerPrivate::activitiesList()
+{
+    QList<QVariantHash> 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).toInt(), 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::removeActivity(int applicationId, const QString &activityId)
+{ 
+    QVariantHash activity;
+    activity.insert(ActivityApplicationKeyword, applicationId);
+    activity.insert(ActivityActivityKeyword, activityId);
+    mServerClient->removeActivity(activity);
+}
+
+void ActivityManagerPrivate::removeApplicationActivities(int applicationId)
+{
+    QVariantHash activity;
+    activity.insert(ActivityApplicationKeyword, applicationId);
+    mServerClient->removeApplicationActivities(activity);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activitymanager_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* 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 <QObject>
+#include <QVariant>
+#include <QList>
+#include "applicationlauncher.h"
+
+class ActivityManager;
+class HsActivityDbClient;
+
+class ActivityManagerPrivate : public QObject
+{
+
+Q_OBJECT
+
+public:
+    ActivityManagerPrivate(ActivityManager *q);
+    ~ActivityManagerPrivate();
+
+public slots:
+    QList<QVariantHash> activitiesList();
+    void launchActivity(const QString &uri);  
+    void launchActivity(int applicationId, const QString &activityId);  
+    void removeActivity(int applicationId, const QString &activityId);  
+    void removeApplicationActivities(int applicationId);  
+
+private:
+    ActivityManager *q_ptr;
+    HsActivityDbClient *mServerClient;
+    
+    
+};
+
+#endif // ACTIVITYMANAGER_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityserviceplugin.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <qserviceinterfacedescriptor.h>
+#include <qabstractsecuritysession.h>
+#include <qservicecontext.h>
+
+#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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityserviceplugin.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QObject>
+#include <qserviceplugininterface.h>
+
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityserviceplugin.pri	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+#
+
+CONFIG += mobility
+MOBILITY = serviceframework
+
+QT += sql
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityserviceplugin.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,64 @@
+#
+# 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 = activityserviceplugin
+
+CONFIG += plugin 
+include(activityserviceplugin.pri)
+
+HEADERS +=  activityserviceplugin.h \
+            activitydatastorage.h \
+            activityclient.h \
+            activityclient_p.h \
+            activitymanager.h \
+            activitymanager_p.h \
+            applicationlauncher.h \
+
+SOURCES +=  activityserviceplugin.cpp \
+            activitydatastorage.cpp \
+            activityclient.cpp \
+            activityclient_p.cpp \
+            activitymanager.cpp \
+            activitymanager_p.cpp \
+            applicationlauncher.cpp \
+
+symbian {
+    INCLUDEPATH += ./s60/
+    SOURCES += ./s60/applicationlauncher_p.cpp
+    
+    HEADERS += ./s60/applicationlauncher_p.h
+
+    LIBS += -lhsactivitydbclient \
+            -lxqutils \
+ 
+}
+
+win32 {
+    INCLUDEPATH += ./win/
+    SOURCES += ./win/applicationlauncher_p.cpp
+
+    HEADERS += ./win/applicationlauncher_p.h
+}            
+            
+symbian {
+    load(data_caging_paths) 
+    TARGET.EPOCALLOWDLLDATA = 1
+    TARGET.CAPABILITY = ALL -TCB
+
+    plugin.sources = activityserviceplugin.dll
+    plugin.path = $$QT_PLUGINS_BASE_DIR     
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/activityserviceplugin.xml	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<service>
+    <name>ActivityService</name>
+    <filepath>activityserviceplugin</filepath>
+    <description>Activities service</description>
+    <interface>
+        <name>com.nokia.qt.activities.ActivityClient</name>
+        <version>1.0</version>
+        <description>Implementation of ActivityClient</description>
+    </interface>
+    <interface>
+        <name>com.nokia.qt.activities.ActivityManager</name>
+        <version>1.0</version>
+        <description>Implementation of ActivityManager</description>
+    </interface>
+</service>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/applicationlauncher.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 QString &activityId)
+{
+    d_ptr->startApplication(applicationId, activityId);
+}
+
+void ApplicationLauncher::bringToForeground(int applicationId)
+{
+    d_ptr->bringToForeground(applicationId);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/applicationlauncher.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 APPLICATIONLAUNCHER_H
+#define APPLICATIONLAUNCHER_H
+
+class ApplicationLauncherPrivate;
+
+#include <QString>
+
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/s60/activitydatabase_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QSqlDatabase>
+#include <QSqlQuery>
+#include <QSqlError>
+#include <QStringList>
+#include <QSettings>
+
+
+
+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<QVariantHash> ActivityDatabasePrivate::allActivitiesList()
+{
+    QList<QVariantHash> retVal;
+    mClient.activities(retVal);
+    return retVal;
+}
+
+QList<QVariantHash> ActivityDatabasePrivate::applicationActivitiesList(const QString & applicationName)
+{
+    QList<QVariantHash> 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);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/s60/activitydatabase_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+*
+*/
+#ifndef ACTIVITYDATABASE_P_H
+#define ACTIVITYDATABASE_P_H
+
+#include <QVariant>
+#include <QList>
+#include <hsactivitydbclient.h>
+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<QVariantHash> allActivitiesList();
+    QList<QVariantHash> 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/s60/activityserverclient_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 &parameters)
+{
+    return true;
+}
+
+bool ActivityServerClientPrivate::removeActivity(const QString &activityId)
+{
+    return true;
+}
+
+bool ActivityServerClientPrivate::updateActivity(const QString &activityId, const QVariantHash &parameters)
+{
+    return true;
+}
+
+QList<QVariantHash> ActivityServerClientPrivate::applicationActivities()
+{
+    return QList<QVariantHash>();
+}
+
+bool ActivityServerClientPrivate::removeActivity(int applicationId, const QString &activityId)
+{
+    return true;
+}
+
+bool ActivityServerClientPrivate::removeApplicationActivities(int applicationId)
+{
+    return true;
+}
+
+QList<QVariantHash> ActivityServerClientPrivate::activities()
+{
+    return QList<QVariantHash>();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/s60/activityserverclient_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QString>
+#include <QVariantHash>
+
+class ActivityServerClient;
+
+class ActivityServerClientPrivate
+{
+
+public:
+    ActivityServerClientPrivate();
+  
+public: // API used by ActivityClient
+    bool addActivity(const QString &activityId, const QVariantHash &parameters);
+    bool removeActivity(const QString &activityId);
+    bool updateActivity(const QString &activityId, const QVariantHash &parameters);
+    QList<QVariantHash> applicationActivities();
+
+public: // API  used by ActivityManager
+    bool removeActivity(int applicationId, const QString &activityId);
+    bool removeApplicationActivities(int applicationId);
+    QList<QVariantHash> activities();    
+    
+public:
+    ActivityServerClient* q_ptr;    
+    
+};
+
+#endif // ACTIVITYSERVERCLIENT_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/s60/applicationlauncher_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+*
+*/
+#include "applicationlauncher_p.h"
+
+#include <apgcli.h>
+#include <apacmdln.h>
+#include <APGTASK.H>
+#include <eikenv.h>
+
+#include <XQConversions>
+
+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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/s60/applicationlauncher_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QString>
+
+class ApplicationLauncherPrivate
+{
+    
+public:    
+    bool isRunning(int applicationId);
+    void startApplication(int applicationId, const QString &activityId);
+    void bringToForeground(int applicationId);
+    
+};
+
+#endif // APPLICATIONLAUNCHER_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <qservicemanager.h>
+#include <QCoreApplication>
+
+QTM_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+
+    QServiceManager manager;
+    bool ok = manager.addService(":/activityserviceplugin.xml");
+    if ( !ok )
+    {
+    int err = manager.error();    
+    qFatal("%d ini", err);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,31 @@
+#
+# 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 = app
+
+QT = core
+#CONFIG += no_icon
+
+CONFIG += mobility
+MOBILITY = serviceframework
+
+SOURCES += activityserviceinstaller.cpp
+
+RESOURCES += activityserviceinstaller.qrc
+
+symbian {
+    TARGET.CAPABILITY = ALL -TCB
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/symbianinstaller/activityserviceinstaller/activityserviceinstaller.qrc	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/" >
+        <file alias="activityserviceplugin.xml">../../activityserviceplugin.xml</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/symbianinstaller/symbianinstaller.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,30 @@
+#
+# 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
+SUBDIRS = activityserviceinstaller
+
+symbian {
+    load(data_caging_paths) 
+
+    plugin.sources = activityserviceplugin.dll
+    plugin.path = $$QT_PLUGINS_BASE_DIR 
+    
+    installer.pkg_postrules += "\"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/activityserviceinstaller.exe\" \  
+                                         - \"!:\sys\bin\activityserviceinstaller.exe\",FR,RB,RW"
+    
+    DEPLOYMENT += plugin installer
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/win/activitydatabase_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QSqlDatabase>
+#include <QSqlQuery>
+#include <QSqlError>
+#include <QStringList>
+#include <QSettings>
+
+#include <hsactivitydbclient.h>
+
+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<QVariantHash> ActivityDatabasePrivate::allActivitiesList()
+{
+    return activitiesList("SELECT Data FROM Activities");
+}
+
+QList<QVariantHash> ActivityDatabasePrivate::applicationActivitiesList(const QString &applicationName)
+{
+    return activitiesList(QString("SELECT Data FROM Activities WHERE ApplicationName = '%1'").arg(applicationName));
+}
+
+QList<QVariantHash> ActivityDatabasePrivate::activitiesList(const QString& sqlCommand)
+{   
+    QSqlQuery query(QSqlDatabase::database(KConnectionName));
+    if (!query.exec(sqlCommand)) {
+        qFatal(qPrintable(query.lastError().text()));
+    }
+    
+    QList<QVariantHash> 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()));
+    }  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/win/activitydatabase_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* 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 <QVariant>
+#include <QList>
+
+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<QVariantHash> allActivitiesList();
+    QList<QVariantHash> 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<QVariantHash> activitiesList(const QString& sqlCommand);
+    
+private:
+    bool checkTables();
+    void recreateTables();
+    
+};
+
+#endif // ACTIVITYDATABASE_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/win/applicationlauncher_p.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QProcess>
+
+bool ApplicationLauncherPrivate::isRunning(int applicationId)
+{
+    // @todo
+    return true;
+}
+
+void ApplicationLauncherPrivate::startApplication(int applicationId, const QString &activityId)
+{
+    // @todo
+}
+
+void ApplicationLauncherPrivate::bringToForeground(int applicationId)
+{
+    // @todo
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/activityserviceplugin/win/applicationlauncher_p.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <QString>
+
+class ApplicationLauncherPrivate
+{
+    
+public:    
+    bool isRunning(int applicationId);
+    void startApplication(int applicationId, const QString &activityId);
+    void bringToForeground(int applicationId);
+    
+};
+
+#endif // APPLICATIONLAUNCHER_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,112 @@
+/*
+* 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 "hbactivityplugininterface.h"
+#include "hbactivityplugin.h"
+
+#include <qservicemanager.h>
+
+QTM_USE_NAMESPACE
+
+HbActivityPlugin::HbActivityPlugin(QObject *parent) : HbActivityPluginInterface(parent), mActivityClient(0)
+{
+    QServiceManager serviceManager;
+    
+    if (serviceManager.findInterfaces("ActivityService").isEmpty()) {
+        // clean old entries
+        serviceManager.removeService("ActivityService");
+        bool servicesAdded = serviceManager.addService(":/activityserviceplugin.xml");
+        if (!servicesAdded) {
+            qWarning("addService for ActivityService returned false, error %d", serviceManager.error());
+        }
+    }
+
+    mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");    
+    if (!mActivityClient) {
+        qWarning("Cannot initialize critical com.nokia.qt.activities.ActivityClient service.");
+    }
+    
+    connect(mActivityClient, SIGNAL(activityRequested(QString)), this, SIGNAL(activityRequested(QString)));
+}
+
+HbActivityPlugin::~HbActivityPlugin()
+{
+    delete mActivityClient;
+}
+
+bool HbActivityPlugin::addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
+{
+    bool retVal(false);
+    QMetaObject::invokeMethod(mActivityClient, 
+                              "addActivity", 
+                              Q_RETURN_ARG(bool, retVal), 
+                              Q_ARG(QString, activityId), 
+                              Q_ARG(QVariant, data), 
+                              Q_ARG(QVariantHash, parameters));
+    return retVal;
+}
+
+bool HbActivityPlugin::removeActivity(const QString &activityId)
+{
+    bool retVal(false);
+    QMetaObject::invokeMethod(mActivityClient, 
+                              "removeActivity", 
+                              Q_RETURN_ARG(bool, retVal), 
+                              Q_ARG(QString, activityId));
+    return retVal;
+}
+
+bool HbActivityPlugin::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
+{
+    bool retVal(false);
+    QMetaObject::invokeMethod(mActivityClient, 
+                              "updateActivity", 
+                              Q_RETURN_ARG(bool, retVal), 
+                              Q_ARG(QString, activityId),
+                              Q_ARG(QVariant, data),
+                              Q_ARG(QVariantHash, parameters));
+    return retVal;
+}
+QList<QVariantHash> HbActivityPlugin::activities()
+{
+    QList<QVariantHash> data;
+    QMetaObject::invokeMethod(mActivityClient, 
+                              "activities", 
+                              Q_RETURN_ARG(QList<QVariantHash>, data));
+    return data;
+}
+
+QVariant HbActivityPlugin::activityData(const QString &activityId)
+{
+    QVariant data;
+    QMetaObject::invokeMethod(mActivityClient, 
+                              "activityData", 
+                              Q_RETURN_ARG(QVariant, data),
+                              Q_ARG(QString, activityId));
+    return data;
+}
+
+bool HbActivityPlugin::waitActivity()
+{
+    bool retVal(false);
+    QMetaObject::invokeMethod(mActivityClient, 
+                              "waitActivity", 
+                              Q_RETURN_ARG(bool, retVal));
+    return retVal;
+}
+
+Q_EXPORT_PLUGIN2(hbactivityplugin, HbActivityPlugin) 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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 HBACTIVITYPLUGIN_H
+#define HBACTIVITYPLUGIN_H
+
+#include "hbactivityplugininterface.h"
+
+class HbActivityPlugin : public HbActivityPluginInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(HbActivityPluginInterface)
+    
+public:
+    HbActivityPlugin(QObject *parent = 0);
+    ~HbActivityPlugin();
+    
+public:
+    virtual bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters);
+    virtual bool removeActivity(const QString &activityId);
+    virtual bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters);
+    virtual QList<QVariantHash> activities();
+    virtual QVariant activityData(const QString &activityId);
+    virtual bool waitActivity();
+
+private:
+    QObject *mActivityClient;
+    
+};
+
+#endif //HBACTIVITYPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+#
+
+TEMPLATE = lib
+TARGET = hbactivityplugin
+
+CONFIG += plugin 
+
+CONFIG += mobility
+MOBILITY = serviceframework
+
+HEADERS +=  hbactivityplugininterface.h \
+            hbactivityplugin.h \
+
+SOURCES +=  hbactivityplugin.cpp \
+
+RESOURCES += hbactivityplugin.qrc
+
+symbian {
+    load(data_caging_paths)
+    pluginDep.sources = hbactivityplugin.dll
+    pluginDep.path = $$QT_PLUGINS_BASE_DIR    
+    DEPLOYMENT += pluginDep
+
+    TARGET.EPOCALLOWDLLDATA = 1
+    TARGET.CAPABILITY = ALL -TCB
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/orbitintegration/hbactivityplugin/hbactivityplugin.qrc	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/" >
+        <file alias="activityserviceplugin.xml">../../activityserviceplugin/activityserviceplugin.xml</file>
+    </qresource>
+</RCC> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/orbitintegration/hbactivityplugin/hbactivityplugininterface.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+*
+*/
+
+#ifndef HBACTIVITYPLUGININTERFACE_H
+#define HBACTIVITYPLUGININTERFACE_H
+
+#include <QtPlugin>
+#include <QObject>
+#include <QVariant>
+#include <QString>
+#include <QList>
+#include <QVariantHash>
+
+class HbActivityPluginInterface : public QObject
+{
+    Q_OBJECT
+
+public:
+    HbActivityPluginInterface(QObject *parent = 0) : QObject(parent) {}
+    
+public:
+    virtual bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters) = 0;
+    virtual bool removeActivity(const QString &activityId) = 0;
+    virtual bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters) = 0;
+    virtual QList<QVariantHash> activities() = 0;
+    virtual QVariant activityData(const QString &activityId) = 0;
+    virtual bool waitActivity() = 0;
+
+signals:
+    void activityRequested(const QString &activityId);
+    
+};
+
+Q_DECLARE_INTERFACE(HbActivityPluginInterface, "HbActivityPluginInterface/1.0")
+
+#endif // HBACTIVITYPLUGININTERFACE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/rom.pri	Wed Mar 24 03:15:43 2010 +0200
@@ -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 <platform_paths.hrh>"
+BLD_INF_RULES.prj_exports += "rom/activitymanager_core.iby  CORE_APP_LAYER_IBY_EXPORT_PATH(activitymanager_core.iby)"
+BLD_INF_RULES.prj_exports += "./sis/stubs/activitymanager_stub.sis  /epoc32/release/winscw/udeb/z/system/install/activitymanager_stub.sis"
+BLD_INF_RULES.prj_exports += "./sis/stubs/activitymanager_stub.sis  /epoc32/data/z/system/install/activitymanager_stub.sis"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/rom/activitymanager_core.iby	Wed Mar 24 03:15:43 2010 +0200
@@ -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 __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\activitylauncher.exe                            PROGRAMS_DIR\activitylauncher.exe
+data=ZPRIVATE\10003a3f\import\apps\activitylauncher_reg.rsc            private\10003a3f\import\apps\activitylauncher_reg.rsc
+data=\epoc32\data\z\resource\apps\activitylauncher.rsc                 resource\apps\activitylauncher.rsc
+
+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
+
+
+// stub sis
+data=ZSYSTEM/install/activitymanager_stub.sis                  system/install/activitymanager_stub.sis
+
+#endif //__TSACTMAN_CORE_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/sis/activitymanager.pkg	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"activitymanager"},(0x200267B4),1,0,0,TYPE=SA, RU
+
+;Localized Vendor Name
+%{"Nokia"}
+
+;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/activitylauncher.exe"    - "!:\sys\bin\activitylauncher.exe"
+"/epoc32/data/z/resource/apps/activitylauncher.rsc"    - "!:\resource\apps\activitylauncher.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitylauncher_reg.rsc"    - "!:\private\10003a3f\import\apps\activitylauncher_reg.rsc"
+
+"/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"
+
+"/epoc32/release/armv5/urel/hbactivityplugin.dll"    - "!:\sys\bin\hbactivityplugin.dll"
+"/epoc32/data/z/resource/qt/plugins/hbactivityplugin.qtplugin"-"!:\resource\qt\plugins\hbactivityplugin.qtplugin"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/sis/edit_pkg.pl	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,224 @@
+#
+# 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: 
+#
+#Options:
+# -version  -adds Qt version (4,6,0) intp pkg files
+# -target  -replaces $(PLATFORM)/$(TARGET) into armv5/urel
+# -test  -creates script for test app
+# default -version
+
+use strict;
+use File::Find;
+my $base = `cd`;
+$base =~ s/\\\w+\s+$//; #move one dir upper 
+my $modulebase = `cd`;
+$modulebase =~s/(\s+)$//; #remove linefeed from end
+print $base;;
+my $qtversion = "\, 4\, 6\, 0\,";
+my $target = "armv5\/urel";
+
+my $qtversionchnage = 0;
+my $qtversionarg = "-version";
+my $targetchnage = 0;
+my $targetarg = "-target";
+my $module = 0;
+my $modulearg = "-test";
+my $delmodule = 0;
+my $delmodulearg = "-delmodule";
+my $moduledir = "testsis";
+my $modulepath = $base."\\".$moduledir;
+my $ccert = $modulebase."\\"."cert.cer";
+my $ckey = $modulebase."\\"."key.pem";
+my $modulebatpath = $modulebase."\\".$moduledir."\\createmodulesis.bat"; 
+
+checkCmdLine();
+
+if ( $qtversionchnage == 1 || $targetchnage == 1 )
+	{
+	find( \&edits, $base );
+	}
+if ( $module == 1 )
+	{
+	system "mkdir $moduledir";
+	if ( not ( open (FWM, ">$modulebatpath") ) )
+		{
+		print "\n***Error: Couldn't open $modulebatpath file to write\n";
+		return;
+		}
+	binmode FWM;
+	print FWM "del /S/Q *.SIS\r\n";
+	print FWM "del /S/Q *.SISX\r\n";
+	close FWM;	
+	find( \&moduleSis, $base );
+	}	
+if ( $delmodule == 1 )
+	{
+	find( \&delModuleSis, $base );
+	}	
+
+sub edits() 
+	{
+	my $file=$_;
+	my $winpath=$File::Find::name;
+	$winpath=~s/\//\\/g;
+	if( -f $file  && $file=~/(_template\.pkg)$/i ) 
+		{
+		print "$winpath ";
+		system "attrib -R $winpath";
+		if ( not ( open (FR, $winpath) ) )
+			{
+			print "Error: Couldn't open $winpath file to read\n";
+			return;
+			}
+		binmode FR;
+		my $buf="";
+		my $length = 0;
+		$length = -s $winpath;
+		read( FR, $buf, $length );
+		close FR;
+		if ( $qtversionchnage == 1 )
+			{
+			$buf =~s/\,\s*\,\s*\,\s*\,\s*\{\"Qt\"\}/$qtversion \{\"Qt\"\}/si;
+			}
+		if ( $targetchnage == 1 )
+			{
+			$buf =~s/\$\(PLATFORM\)\/\$\(TARGET\)/$target/si;
+			}
+	    
+	    if ( not ( open (FW, ">$winpath") ) )
+			{
+			print "\n***Error: Couldn't open $winpath file to write\n";
+			return;
+			}
+		binmode FW;		
+		print FW $buf;
+	    close FW;		
+		
+		print "\r\n";
+		}
+	}
+
+sub checkCmdLine()
+	{
+	my $numArgs = $#ARGV + 1;
+	if ( $numArgs == 0 )
+		{
+		$qtversionchnage = 1;
+		}
+	else
+		{
+		foreach my $argnum ( 0 .. $#ARGV ) 
+			{
+			my $argName = lc $ARGV[$argnum];
+			if ( $argName eq $qtversionarg )
+				{
+				$qtversionchnage = 1;
+				}
+			elsif ( $argName eq $targetarg )
+				{
+				$targetchnage = 1;
+				}
+			elsif ( $argName eq $modulearg )
+				{
+				$module = 1;
+				}
+			elsif ( $argName eq $delmodulearg )
+				{
+				$delmodule = 1;
+				}
+			else
+				{
+				die "\n***Error: Bad arguments\n";
+				}
+			}
+		}
+	}
+	
+sub moduleSis()
+	{
+	my $file=$_;
+	my $winpath=$File::Find::name;
+	$winpath=~s/\//\\/g;	
+
+	
+	if( -f $file  && $file=~/(.*test.*_template\.pkg)$/i ) 
+		{
+		print "$winpath ";
+		system "attrib -R $winpath";
+		if ( not ( open (FR, $winpath) ) )
+			{
+			print "Error: Couldn't open $winpath file to read\n";
+			return;
+			}
+		binmode FR;
+		my $buf="";
+		my $length = 0;
+		$length = -s $winpath;
+		read( FR, $buf, $length );
+		close FR;
+		$buf =~s/\,\s*\,\s*\,\s*\,\s*\{\"Qt\"\}/$qtversion \{\"Qt\"\}/si;
+		$buf =~s/\$\(PLATFORM\)\/\$\(TARGET\)/$target/si;
+	    
+	    if ( not ( open (FW, ">$winpath") ) )
+			{
+			print "Error: Couldn't open $winpath file to write\n";
+			return;
+			}
+		binmode FW;		
+		print FW $buf;
+	    close FW;				
+		print "\r\n";
+		
+		my $pkgname = sisName( $winpath );
+		
+		if ( not ( open (FWM2, ">>$modulebatpath") ) )
+			{			
+			print "Error: Couldn't open $modulebatpath file to append\n";
+			return;
+			}
+		binmode FWM2;		
+		print FWM2 "makesis $winpath $pkgname\.SIS\r\n";
+		print FWM2 "signsis $pkgname\.SIS $pkgname\.SISX $ccert $ckey\r\n";
+		close FWM2;	
+		}	
+	}
+		
+sub sisName()
+	{
+	my $path = shift;
+	my $name = "";
+	if ( $path =~ /\\(\w+)\.pkg/i )
+		{
+		$name = $1;
+		}
+	return $name;
+	}
+	
+sub delModuleSis()
+	{
+	my $file=$_;
+	my $winpath=$File::Find::name;
+	$winpath=~s/\//\\/g;	
+
+	
+	if( -f $file  && $file=~/(_template\.pkg)$/i && ( $file=~/^(t_)/i || $file=~/test/i ) ) 
+		{
+		print "Deleting: ";
+		print "$winpath ";
+		system "attrib -R $winpath";
+		system "del /S/Q $winpath";
+		print "\r\n";
+		}	
+	}	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/sis/stubs/activitymanager_stub.pkg	Wed Mar 24 03:15:43 2010 +0200
@@ -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: 
+;
+; ------------------------------------------------------------------------------
+; 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
+#{"activitymanager"},(0x200267B4),1,0,0,TYPE=SA
+
+;Localized Vendor Name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+;"" - "Z:\sys\bin\activityserviceinstaller.exe"
+"" - "Z:\sys\bin\activityserviceplugin.dll"
+"" - "Z:\resource\qt\plugins\activityserviceplugin.qtplugin"
+
+""    - "Z:\sys\bin\activitylauncher.exe"
+""    - "Z:\resource\apps\activitylauncher.rsc"
+""    - "Z:\private\10003a3f\import\apps\activitylauncher_reg.rsc"
+
+""    - "Z:\sys\bin\hsactivitydbserver.exe"
+""    - "Z:\resource\apps\hsactivitydbserver.rsc"
+""    - "Z:\private\10003a3f\import\apps\hsactivitydbserver_reg.rsc"
+
+""    - "Z:\sys\bin\hsactivitydbclient.dll"
+
+""    - "Z:\sys\bin\hbactivityplugin.dll"
+"" -  "Z:\resource\qt\plugins\hbactivityplugin.qtplugin"
\ No newline at end of file
Binary file activitymanager/sis/stubs/activitymanager_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activitymanager/sis/stubs/createstubs.bat	Wed Mar 24 03:15:43 2010 +0200
@@ -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
--- a/contentstorage/caclient/caclient.pro	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/caclient.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -51,7 +51,8 @@
         -laknicon \
         -lcharconv \
         -lfbscli \
-        -lbitgdi
+        -lbitgdi \
+        -lxqutils
 include(caclient_s60.pri)
 include(cahandler.pri)
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/inc/caclient_defines.h	Wed Mar 24 03:15:43 2010 +0200
@@ -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: caclient_defines.h
+ *
+ */
+ 
+const char APPLICATION_UID_ATTRIBUTE_NAME[]  = "application:uid";
+const char APPLICATION_ENTRY_TYPE_NAME[] = "application";
+const char WIDGET_ENTRY_TYPE_NAME[] = "widget";
+const char URL_ENTRY_TYPE_NAME[] = "url";
+const char TEMPLATED_APPLICATION_ENTRY_TYPE_NAME[] = "templatedApplication";
\ No newline at end of file
--- a/contentstorage/caclient/inc/caitemmodellist.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/inc/caitemmodellist.h	Wed Mar 24 03:15:43 2010 +0200
@@ -49,6 +49,7 @@
     void insert(int row, int id);
     void remove(int id);
     const int &operator[](int row) const;
+    QList<int> orderedIdList();
 
 private:
 
--- a/contentstorage/caclient/installs_win32.pri	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/installs_win32.pri	Wed Mar 24 03:15:43 2010 +0200
@@ -16,7 +16,7 @@
 
 # take path from common.pri
 cadb.path = $$DESTDIR
-cadb.files = ./../castorage/data/castoragedb 
+cadb.files = ./../castorage/data/castorage.db 
 cadb.CONFIG += no_build
 
 INSTALLS += cadb
--- a/contentstorage/caclient/s60/inc/caobjectadapter.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/s60/inc/caobjectadapter.h	Wed Mar 24 03:15:43 2010 +0200
@@ -38,6 +38,7 @@
 class HbIcon;
 class CFbsBitmap;
 
+
 /**
  *  CaObjectAdapter
  *
@@ -75,22 +76,6 @@
         CCaInnerQuery &toQuery);
 
     /**
-     * Wraps a QString internal buffer into TPtrC object.
-     * The returned object is valid until QString internal buffer changes
-     * or the object is destroyed.
-     * @param string QString.
-     * @return descriptor.
-     */
-    static const TPtrC convertToDescriptor(const QString &string);
-
-    /**
-     * Converts descriptor to QString.
-     * @param des descriptor.
-     * @return QString.
-     */
-    static QString convertToString(const TDesC &des);
-
-    /**
      * Converts inner entry table to QList of pointers to entries.
      * @param fromEntriesArray an array containing inner entries
      * for conversion.
@@ -156,31 +141,6 @@
         CCaInnerNotifierFilter &to);
 
     /**
-     * @return  uid attribute name
-     */
-    static const QString applicationUidAttributeName();
-
-    /**
-     * @return  application entry type name
-     */
-    static const QString applicationEntryTypeName();
-
-    /**
-     * @return  widget entry type name
-     */
-    static const QString widgetEntryTypeName();
-
-    /**
-     * @return  url entry type name
-     */
-    static const QString urlEntryTypeName();
-
-    /**
-     * @return  template application entry type name
-     */
-    static const QString templateApplicationEntryTypeName();
-
-    /**
      * Set entry id.
      * @param entry entry.
      * @param id entry id.
--- a/contentstorage/caclient/s60/src/caobjectadapter.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/s60/src/caobjectadapter.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -26,6 +26,7 @@
 #include <HbIcon>
 #include <QBitmap>
 #include <QDebug>
+#include <XQConversions>
 
 #include "cadef.h"
 #include "caobjectadapter.h"
@@ -36,6 +37,7 @@
 #include "camenuiconutility.h"
 #include "canotifierfilter.h"
 #include "cainnernotifierfilter.h"
+#include "caclient_defines.h"
 
 static  QImage::Format TDisplayMode2Format(TDisplayMode mode)
 {
@@ -81,28 +83,34 @@
     TDisplayMode displayMode = aBitmap->DisplayMode();
 
     // QImage format must match to bitmap format
-    QImage image(data, size.iWidth, size.iHeight, TDisplayMode2Format(displayMode));
+    QImage image(data, size.iWidth, size.iHeight, TDisplayMode2Format(
+        displayMode));
     aBitmap->EndDataAccess();
 
-    // No data copying happens because image format matches native OpenVG format.
+    // No data copying happens because
+    // image format matches native OpenVG format.
     // So QPixmap actually points to CFbsBitmap data.
     return QPixmap::fromImage(image);
 }
 
-// -----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 //
-// -----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 void CaObjectAdapter::convertL(const CaEntry &fromEntry,
                                CCaInnerEntry &toEntry)
 {
     toEntry.SetId(fromEntry.id());
 
-    toEntry.SetTextL(convertToDescriptor(fromEntry.text()));
+    toEntry.SetTextL(
+        XQConversions::qStringToS60Desc(fromEntry.text())->Des());
 
-    toEntry.SetDescriptionL(convertToDescriptor(fromEntry.description()));
+    toEntry.SetDescriptionL(
+        XQConversions::qStringToS60Desc(fromEntry.description())->Des());
+    toEntry.SetDescriptionL(
+        XQConversions::qStringToS60Desc(fromEntry.description())->Des());
 
     toEntry.SetEntryTypeNameL(
-        convertToDescriptor(fromEntry.entryTypeName()));
+        XQConversions::qStringToS60Desc(fromEntry.entryTypeName())->Des());
 
     toEntry.SetFlags(static_cast<TUint>(fromEntry.flags()));
 
@@ -112,21 +120,24 @@
         fromEntry.iconDescription();
 
     toEntry.SetIconDataL(
-        convertToDescriptor(fromIconDescription.filename()),
-        convertToDescriptor(fromIconDescription.skinId()),
-        convertToDescriptor(fromIconDescription.applicationId())
-        );
+        XQConversions::qStringToS60Desc(
+            fromIconDescription.filename())->Des(),
+        XQConversions::qStringToS60Desc(
+            fromIconDescription.skinId())->Des(),
+        XQConversions::qStringToS60Desc(
+            fromIconDescription.applicationId())->Des());
 
     const QMap<QString, QString> attributesMap = fromEntry.attributes();
 
     foreach(QString key, attributesMap.keys()) {
-        if (key == applicationUidAttributeName()) {
+        if (key == APPLICATION_UID_ATTRIBUTE_NAME) {
             const TInt32 uid = attributesMap.value(key).toInt();
             toEntry.SetUid(uid);
         } else {
             toEntry.AddAttributeL(
-                convertToDescriptor(key),
-                convertToDescriptor(attributesMap.value(key)));
+                XQConversions::qStringToS60Desc(key)->Des(),
+                XQConversions::qStringToS60Desc(
+                    attributesMap.value(key))->Des());
         }
     }
 }
@@ -154,7 +165,7 @@
     CleanupStack::PushL(sourceList);
 
     foreach(const QString str, list) {
-        sourceList->AppendL(convertToDescriptor(str));
+        sourceList->AppendL(XQConversions::qStringToS60Desc(str)->Des());
     }
 
     toQuery.SetEntryTypeNames(sourceList);
@@ -166,28 +177,31 @@
     Qt::SortOrder sortOrder;
     fromQuery.getSort(sortAttr, sortOrder);
     toQuery.SetSort(CaObjectAdapter::getSortCode(sortAttr, sortOrder));
-    
+
     const QMap<QString, QString> attributesMap = fromQuery.attributes();
 
     foreach(QString key, attributesMap.keys()) {
-            toQuery.AddAttributeL(
-                convertToDescriptor(key),
-                convertToDescriptor(attributesMap.value(key)));
+        toQuery.AddAttributeL(
+            XQConversions::qStringToS60Desc(key)->Des(),
+            XQConversions::qStringToS60Desc(
+                attributesMap.value(key))->Des());
     }
 }
 
 //----------------------------------------------------------------------------
 //
 //----------------------------------------------------------------------------
-void CaObjectAdapter::convert(const CCaInnerEntry &fromEntry,
-                              CaEntry &toEntry)
+void CaObjectAdapter::convert(
+        const CCaInnerEntry &fromEntry, CaEntry &toEntry)
 {
     toEntry.setId(fromEntry.GetId());
 
-    toEntry.setText(convertToString(fromEntry.GetText()));
+    toEntry.setText(XQConversions::s60DescToQString(fromEntry.GetText()));
 
-    toEntry.setDescription(convertToString(fromEntry.GetDescription()));
-    toEntry.setEntryTypeName(convertToString(fromEntry.GetEntryTypeName()));
+    toEntry.setDescription(
+        XQConversions::s60DescToQString(fromEntry.GetDescription()));
+    toEntry.setEntryTypeName(
+        XQConversions::s60DescToQString(fromEntry.GetEntryTypeName()));
 
     toEntry.setFlags(static_cast<EntryFlag>(fromEntry.GetFlags()));
 
@@ -196,48 +210,34 @@
 
     CaIconDescription iconDescription;
     iconDescription.setId(icon.iId);
-    iconDescription.setFilename(convertToString(icon.iFileName));
-    iconDescription.setSkinId(convertToString(icon.iSkinId));
-    iconDescription.setApplicationId(convertToString(icon.iApplicationId));
+    iconDescription.setFilename(
+        XQConversions::s60DescToQString(icon.iFileName));
+    iconDescription.setSkinId(
+        XQConversions::s60DescToQString(icon.iSkinId));
+    iconDescription.setApplicationId(
+        XQConversions::s60DescToQString(icon.iApplicationId));
 
     toEntry.setIconDescription(iconDescription);
 
     const RCaEntryAttrArray &attributesArray = fromEntry.GetAttributes();
 
-    if (toEntry.entryTypeName() == applicationEntryTypeName()
-            || toEntry.entryTypeName() == widgetEntryTypeName()) {
-        toEntry.setAttribute(applicationUidAttributeName(),
-                             QString::number(fromEntry.GetUid()));
+    if (toEntry.entryTypeName() == APPLICATION_ENTRY_TYPE_NAME
+            || toEntry.entryTypeName() == WIDGET_ENTRY_TYPE_NAME) {
+        toEntry.setAttribute(APPLICATION_UID_ATTRIBUTE_NAME,
+            QString::number(fromEntry.GetUid()));
     }
 
     const int attributesArrayCount = attributesArray.Count();
 
     for (int i = 0; i < attributesArrayCount; ++i) {
         const CCaEntryAttribute *const attribute = attributesArray[i];
-        toEntry.setAttribute(convertToString(attribute->Name()),
-                             convertToString(attribute->Value()));
+        toEntry.setAttribute(
+            XQConversions::s60DescToQString(attribute->Name()),
+            XQConversions::s60DescToQString(attribute->Value()));
     }
 }
 
 //----------------------------------------------------------------------------
-// !!! Warning: returns wrapper to internal QString representation which may
-// get invalid before returned TPtrC object gets out of scope
-//----------------------------------------------------------------------------
-const TPtrC CaObjectAdapter::convertToDescriptor(const QString &string)
-{
-    const TPtrC result(reinterpret_cast<const TUint16 *>(string.utf16()));
-    return result;
-}
-
-//----------------------------------------------------------------------------
-//
-//----------------------------------------------------------------------------
-QString CaObjectAdapter::convertToString(const TDesC &des)
-{
-    return QString::fromUtf16(des.Ptr(), des.Length());
-}
-
-//----------------------------------------------------------------------------
 //
 //----------------------------------------------------------------------------
 void CaObjectAdapter::convertL(const CaNotifierFilter &notifierFilter,
@@ -270,13 +270,12 @@
     const QStringList stringList = notifierFilter.getTypeNames();
 
     foreach(QString str, stringList) {
-        typeNames->AppendL(convertToDescriptor(str));
+        typeNames->AppendL(XQConversions::qStringToS60Desc(str)->Des());
     }
 
     source.SetTypeNames(typeNames);
 
     CleanupStack::Pop(typeNames);
-
 }
 //----------------------------------------------------------------------------
 //
@@ -358,50 +357,7 @@
     return error;
 }
 
-//----------------------------------------------------------------------------
-//
-//----------------------------------------------------------------------------
-const QString CaObjectAdapter::applicationUidAttributeName()
-{
-    const static QString name("application:uid");
-    return name;
-}
 
-//----------------------------------------------------------------------------
-//
-//----------------------------------------------------------------------------
-const QString CaObjectAdapter::applicationEntryTypeName()
-{
-    const static QString name("application");
-    return name;
-}
-
-//----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-const QString CaObjectAdapter::widgetEntryTypeName()
-{
-    const static QString name("widget");
-    return name;
-}
-
-//----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-const QString CaObjectAdapter::urlEntryTypeName()
-{
-    const static QString name("url");
-    return name;
-}
-
-//----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-const QString CaObjectAdapter::templateApplicationEntryTypeName()
-{
-    const static QString name("templatedApplication");
-    return name;
-}
 // -----------------------------------------------------------------------------
 // copying compressed bitmap
 //----------------------------------------------------------------------------
@@ -434,9 +390,21 @@
     if (icon.isNull() || !(icon.size().isValid())) {
         QString filename(entry.iconDescription().filename());
         if (!filename.isEmpty()) {
-            icon = HbIcon(filename);
+            
+            // TODO:
+            // work-around for HbIcon::size() method locking files if returns 
+            // default size, error id: ou1cimx1#279208 Case: mcl06HsDo07 - 
+            // "Cannot delete file" when trying to uninstall sisx file
+            
+            if (entry.entryTypeName() == XQConversions::s60DescToQString(KCaTypeWidget)) {
+                icon = QIcon(filename);
+                qWarning("Widget icon created by QIcon, as work-around for HbIcon::size");
+            } else {           
+                icon = HbIcon(filename);
+            }
         }
-    }
+    }    
+    
     //try to load symbian icon from multi-bitmap (mbm, mbg)
     if (icon.isNull() || !(icon.size().isValid())) {
         CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
@@ -449,13 +417,13 @@
 
             //need to disable compression to properly convert the bitmap
             AknIconUtils::DisableCompression(aknIcon->Bitmap());
-            AknIconUtils::SetSize(aknIcon->Bitmap(), TSize(size.width(),
-                                  size.height()), EAspectRatioPreservedAndUnusedSpaceRemoved);
+            AknIconUtils::SetSize(
+                aknIcon->Bitmap(), TSize(size.width(), size.height()),
+                EAspectRatioPreservedAndUnusedSpaceRemoved);
             if (aknIcon->Bitmap()->Header().iCompression
                     == ENoBitmapCompression) {
                 pixmap = fromSymbianCFbsBitmap(aknIcon->Bitmap());
-                QPixmap mask = fromSymbianCFbsBitmap(
-                                   aknIcon->Mask());
+                QPixmap mask = fromSymbianCFbsBitmap(aknIcon->Mask());
                 pixmap.setAlphaChannel(mask);
             } else { // we need special handling for icons in 9.2 (NGA)
                 // let's hope that in future it will be in QT code
--- a/contentstorage/caclient/s60/src/caqtsfhandlerloader.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/s60/src/caqtsfhandlerloader.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -24,7 +24,7 @@
 
 #include "cahandler.h"
 #include "caqtsfhandlerloader.h"
-#include "caobjectadapter.h"
+#include "caclient_defines.h"
 #include "caapphandler.h"
 #include "caurlhandler.h"
 #include "catapphandler.h" 
@@ -59,13 +59,12 @@
 
     CaHandler *implementation(0);
 
-    if (entryTypeName == CaObjectAdapter::applicationEntryTypeName()
-        || entryTypeName == CaObjectAdapter::widgetEntryTypeName()) {
+    if (entryTypeName == APPLICATION_ENTRY_TYPE_NAME
+        || entryTypeName == WIDGET_ENTRY_TYPE_NAME) {
         implementation = new CaS60HandlerAdapter<CCaAppHandler>;
-    } else if (entryTypeName == CaObjectAdapter::urlEntryTypeName()) {
+    } else if (entryTypeName == URL_ENTRY_TYPE_NAME) {
         implementation = new CaS60HandlerAdapter<CCaUrlHandler>;
-    } else if (entryTypeName == 
-               CaObjectAdapter::templateApplicationEntryTypeName()) {
+    } else if (entryTypeName == TEMPLATED_APPLICATION_ENTRY_TYPE_NAME) {
         implementation = new CaTappHandler;
     }
 
--- a/contentstorage/caclient/src/caitemmodel.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/src/caitemmodel.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -706,17 +706,19 @@
     mEntries.updateEntry(id);
 
     QList<int> ids = mService->getEntryIds(mQuery);
-    if (mEntries.indexOf(id) >= 0 && ids.indexOf(id)
-            == mEntries.indexOf(id)) {
+    if (mEntries.indexOf(id) >= 0 
+           && 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();
     } else {
-        if (mParentEntry && id == mParentEntry->id()) {
-            updateParentEntry();
-            m_q->reset();
-        } else {
-            updateLayout();
-        }
+        updateModel();
     }
     CACLIENTTEST_FUNC_EXIT("CaItemModelPrivate::updateItemData");
 }
@@ -751,11 +753,25 @@
     int entriesCount = mEntries.count();
     if (entriesCount) {
         int lastRow = itemsList.indexOf(mEntries[entriesCount - 1]);
-        if (itemsList.count() == entriesCount && lastRow == (entriesCount
-                - 1)) {
+        if (itemsList.count() == entriesCount) {
             //count is same and last item is in same position
             //so we update whole model
-            updateModel();
+            bool orderChanged(false);
+            while (entriesCount) {
+                if (itemsList.indexOf(mEntries[entriesCount - 1]) 
+                        != (entriesCount - 1)) {
+                    orderChanged = true;
+                    break;
+                }
+                entriesCount--;
+            }
+            if (orderChanged) {
+                updateLayout();
+            }
+            else {
+                updateModel();
+            }
+            
         } else if ((itemsList.count() - entriesCount) == 1 && lastRow
                    == entriesCount) {
             //just one item added - collection
@@ -773,15 +789,15 @@
                 i++;
             }
         } else {
-            //some items were inserted or reordered,
-            //so we update layout and emit signal with row number
+            //some items were inserted
+            //so we update model and emit signal with row number
             //of first moved/added item
             //signal is needed to scroll a view to proper position after
             //some items were added
-            updateLayout();
+            updateModel();
             emit m_q->scrollTo(lastRow + 1,
                                QAbstractItemView::PositionAtTop);
-        }
+        } 
     } else {
         updateModel();
     }
@@ -815,9 +831,8 @@
         mEntries.remove(id);
         m_q->endRemoveRows();
     } else {
-        updateLayout();
+        updateModel();
     }
-    
     CACLIENTTEST_FUNC_EXIT("CaItemModelPrivate::removeItem");
 }
 
@@ -843,13 +858,45 @@
 
 /*!
  Layout update
+ NOTE: this method should be called only if the entries get rearranged
+ and do not change their contents!
  */
 void CaItemModelPrivate::updateLayout()
 {
     CACLIENTTEST_FUNC_ENTRY("CaItemModelPrivate::updateLayout");
     m_q->layoutAboutToBeChanged();
+
+    // get the ID list from before the update
+    QList<int> oldOrderedIdList = mEntries.orderedIdList();
+
+    // do the update, the entries should only get rearranged
     mEntries.updateEntries(mQuery);
-    updateParentEntry();
+
+    // get the new ID list after the entries got rearranged
+    QList<int> newOrderedIdList = mEntries.orderedIdList();
+    // this list will contain the new position indices
+    QList<int> newPositionsList;
+    int entry;
+    foreach (entry, oldOrderedIdList) {
+        newPositionsList << newOrderedIdList.indexOf(entry);
+    }
+
+    // now check which items in the previous persistent index list changed
+    // their positions, make new indices for them and store in the new
+    // persistent index list
+    QModelIndexList oldPersistentIndexList = m_q->persistentIndexList();
+    QModelIndexList newPersistentIndexList;
+    QModelIndex index;
+    foreach (index, oldPersistentIndexList) {
+        newPersistentIndexList <<
+            m_q->createIndex(
+                newPositionsList.at(index.row()),
+                0,
+                index.internalPointer());
+    }
+
+    m_q->changePersistentIndexList(oldPersistentIndexList, newPersistentIndexList);
+
     m_q->layoutChanged();
     CACLIENTTEST_FUNC_EXIT("CaItemModelPrivate::updateLayout");
 }
--- a/contentstorage/caclient/src/caitemmodellist.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/src/caitemmodellist.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -170,3 +170,12 @@
 {
     return mOrderedList[row];
 }
+
+/*!
+ Returns on ordered list of entry IDs
+ \retval Copy of the internal ID list
+ */
+QList<int> CaItemModelList::orderedIdList()
+{
+    return mOrderedList;
+}
--- a/contentstorage/caclient/stub/src/caclientproxy.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/caclient/stub/src/caclientproxy.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -36,7 +36,7 @@
 
 const char *DATABASE_CONNECTION_NAME = "CaService";
 const char *DATABASE_TYPE = "QSQLITE";
-const char *DATABASE_NAME = "castoragedb";
+const char *DATABASE_NAME = "castorage.db";
 
 static QSqlDatabase dbConnection()
 {
@@ -605,7 +605,6 @@
         whereStatement.append(" AND ").append(QString().setNum(
                 query.entryRoles())) .append(" | EN_ROLE == ").append(
                     QString().setNum(query.entryRoles()));
-    //TODO: by uid???
 
     if (query.entryTypeNames().count()) {
         whereStatement.append(" AND EN_TYPE_NAME IN (");
@@ -617,11 +616,48 @@
         whereStatement.append(") ");
     }
 
+    QString whereAttributes;
+    if (query.attributes().count()) {
+        QMap<QString, QString> attributes = query.attributes();
+        QMapIterator<QString, QString> atrIt(attributes);
+        int j = 1;
+        while (atrIt.hasNext()) {
+            atrIt.next();
+
+            // at1.AT_NAME = 'Attribute_Name_1' AND at1.AT_VALUE = 'Attribute_VALUE_1'
+            whereAttributes.append(" AND ").append(
+            " at").append(QString().setNum(j)).append(".AT_NAME = \'").append(
+            atrIt.key()).append("\' ").append(
+            " AND ").append(
+            " at").append(QString().setNum(j)).append(".AT_VALUE = \'").append(
+            atrIt.value()).append("\' ");
+
+            j++;
+        }
+        whereStatement.append(whereAttributes);
+
+    }
+
+    whereStatement.append(" GROUP BY ENTRY_ID ");
+
+    QString leftJoins;
+    if (query.attributes().count()) {
+        for (int j=1; j<=query.attributes().count(); j++) {
+            // LEFT JOIN CA_ATTRIBUTE as at1 ON ENTRY_ID = at1.AT_ENTRY_ID
+            leftJoins.append(
+            " LEFT JOIN CA_ATTRIBUTE as at").append(QString().setNum(j)).append(
+            " ON ENTRY_ID = at").append(QString().setNum(j)).append(" .AT_ENTRY_ID ");
+        }
+    }
+
     QSqlQuery sqlquery(db);
     if (query.parentId() == 0) {
         // sort
-        QString queryString("SELECT ENTRY_ID from CA_ENTRY where 1=1 ");
+        QString queryString("SELECT ENTRY_ID from CA_ENTRY ");
+        queryString.append(leftJoins);
+        queryString.append(" where 1=1 ");
         queryString.append(whereStatement);
+
         modifyQueryForSortOrder(queryString, query, false);
         if (query.count() > 0)
             queryString.append(" LIMIT ").append(query.count());
@@ -636,11 +672,13 @@
             }
         }
     } else {
-        QString
-        queryString(
-            "SELECT ENTRY_ID FROM CA_ENTRY \
-        LEFT JOIN CA_GROUP_ENTRY ON GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID  = ? ");
-        queryString.append(whereStatement);
+
+        QString queryString("SELECT ENTRY_ID FROM CA_ENTRY ");
+        QString queryString2(" LEFT JOIN CA_GROUP_ENTRY ON GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID  = ? ");
+        queryString2.append(whereStatement);
+        queryString.append(leftJoins);
+        queryString.append(queryString2);
+
         modifyQueryForSortOrder(queryString, query, true);
         if (query.count() > 0)
             queryString.append(" LIMIT ").append(query.count());
@@ -752,9 +790,9 @@
     return error;
 }
 
-/*!
- //TODO:
- */
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
 void CaClientProxy::modifyQueryForSortOrder(QString &queryString,
         const CaQuery &query, bool parent) const
 {
@@ -802,9 +840,9 @@
 
 }
 
-/*!
- //TODO:
- */
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
 bool CaClientProxy::setIconInDb(CaEntry *entryClone) const
 {
     //set icon information into db
@@ -848,9 +886,9 @@
     return success;
 }
 
-/*!
- //TODO:
- */
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
 bool CaClientProxy::setEntryInDb(CaEntry *entryClone) const
 {
     QSqlQuery query(dbConnection());
@@ -902,9 +940,9 @@
     return success;
 }
 
-/*!
- //TODO:
- */
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
 bool CaClientProxy::setAttributesInDb(CaEntry *entryClone) const
 {
     bool success = true;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/inc/catasklist.h	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,98 @@
+/*
+ * 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 CATASKLIST_H
+#define CATASKLIST_H
+
+// INCLUDES
+
+#include<w32std.h>
+#include<apgtask.h>
+
+// CLASS DECLARATION
+
+/**
+*  Class for finding out about running applications.
+*
+*  This is a modification of the original CAknTaskList class, which
+*  differs in that it does not discriminate applications based on their
+*  window group priority.
+*/
+class CCaTaskList : public CBase
+    {
+public:
+
+	/**
+    * Factory function
+    * @param aWsSession an open session to the window server, often from CEikonEnv::WsSession()
+    * @return a new fully constructed instance of CCaTaskList
+    */
+    static CCaTaskList* NewL( RWsSession& aWsSession );
+
+    /**
+    * Factory function
+    * @param aWsSession an open session to the window server, often from CEikonEnv::WsSession()
+    * @return a new fully constructed instance of CCaTaskList, which is on the cleanup stack
+    */
+
+    static CCaTaskList* NewLC( RWsSession& aWsSession );
+    /**
+    * Destructor.
+    */
+    ~CCaTaskList();
+
+    /**
+    * Refresh the window group array
+    */
+    void UpdateListL();
+
+    /**
+    * Accessor for the window group array
+    * @return an array containing the window groups of running applications.
+    */
+    const RArray<RWsSession::TWindowGroupChainInfo>& WgArray() const;
+
+    /**
+    * Find an application with the requested UID 3, which is running as a root application
+    * @param aAppUid the UID 3 of the target application.
+    * @return a TApaTask which refers to the running instance of the application.
+    * if the application is not running, the TApaTask's Exists() function will return EFalse.
+    */
+    TApaTask FindRootApp( TUid aAppUid ) const;
+
+    /**
+    * Query whether an application's window group is running as a root application.
+    * @param aWgId the window group identifier of the target application.
+    * @return ETrue if this window group is running as a root window group.
+    */
+    TBool IsRootWindowGroup( TInt aWgId ) const;
+
+private:
+
+    CCaTaskList( RWsSession& aWsSession );
+
+    void ConstructL();
+
+private:
+
+    RWsSession& iWs;
+
+    RArray<RWsSession::TWindowGroupChainInfo> iWgs;
+
+    };
+
+#endif
--- a/contentstorage/cahandler/app/src/caapphandler.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/cahandler/app/src/caapphandler.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -27,6 +27,7 @@
 #include "caapphandler.h"
 #include "cainnerentry.h"
 #include "cauninstalloperation.h"
+#include"catasklist.h"
 
 #include "cautils.h"
 #include "cadef.h"
@@ -49,9 +50,9 @@
 CCaAppHandler *CCaAppHandler::NewL()
 {
     CCaAppHandler *handler = new(ELeave) CCaAppHandler();
-    CleanupStack::PushL(handler);
+    CleanupStack::PushL( handler );
     handler->ConstructL();
-    CleanupStack::Pop(handler);
+    CleanupStack::Pop( handler );
     return handler;
 }
 
@@ -73,40 +74,113 @@
 {
 }
 
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCaAppHandler::HandleCommandL(
+        CCaInnerEntry &aEntry, const TDesC8 &aCommand )
+{
+    if( aCommand == KCaCmdOpen()
+            && aEntry.GetEntryTypeName() == KCaTypeApp() )
+        {
+        TInt viewId(-1);
+        TBuf<KCaMaxAttrValueLen> viewIdValue;
+        if( aEntry.FindAttribute( KCaAttrView(), viewIdValue ) )
+            {
+            if( MenuUtils::GetTUint( viewIdValue, (TUint &) viewId )
+                    != KErrNone )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            }
+        LaunchApplicationL(
+                TUid::Uid( aEntry.GetUid() ), KNullDesC8(), viewId );
+        }
+    else if ( aCommand == KCaCmdClose()
+            && aEntry.GetEntryTypeName() == KCaTypeApp() )
+        {
+        CloseApplicationL( aEntry );
+        }
+    else if ( aCommand == KCaCmdRemove()
+               && ( aEntry.GetEntryTypeName() == KCaTypeApp()
+                   || aEntry.GetEntryTypeName() == KCaTypeWidget() ) )
+        {
+        if ( iUninstallOperation && iUninstallOperation->IsActive() )
+            {
+            User::Leave( KErrInUse );
+            }
+        delete iUninstallOperation;
+        iUninstallOperation = NULL;
+        iUninstallOperation = CCaUninstallOperation::NewL( aEntry );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+}
 
 // ---------------------------------------------------------------------------
 //
 // ---------------------------------------------------------------------------
 //
-void CCaAppHandler::HandleCommandL(CCaInnerEntry &aEntry,
-                                   const TDesC8 &aCommand)
+void CCaAppHandler::LaunchApplicationL(
+        const TUid aUid, const TDesC8 &aParam, TInt aViewId )
 {
-    if (aCommand == KCaCmdOpen() && aEntry.GetEntryTypeName()
-            == KCaTypeApp()) {
-        TInt viewId(-1);
-        TBuf<KCaMaxAttrValueLen> viewIdValue;
-        if (aEntry.FindAttribute(KCaAttrView(), viewIdValue)) {
-            if (MenuUtils::GetTUint(viewIdValue, (TUint &) viewId)
-                    != KErrNone) {
-                User::Leave(KErrCorrupt);
-            }
+    if( aViewId > 0 && iEikEnv )
+        {
+        TUid viewId = TUid::Uid( aViewId );
+        TVwsViewId view( aUid, viewId );
+        iEikEnv->EikAppUi()->ActivateViewL( view );
         }
-        LaunchApplicationL(TUid::Uid(aEntry.GetUid()), KNullDesC8(),
-                           viewId);
-    } else if (aCommand == KCaCmdClose() && aEntry.GetEntryTypeName()
-               == KCaTypeApp()) {
-        CloseApplicationL(aEntry);
-    } else if (aCommand == KCaCmdRemove()
-               && (aEntry.GetEntryTypeName() == KCaTypeApp()
-                   || aEntry.GetEntryTypeName() == KCaTypeWidget())) {
-        if (iUninstallOperation && iUninstallOperation->IsActive()) {
-            User::Leave(KErrInUse);
+    else
+        {
+        RWsSession wsSession;
+        User::LeaveIfError( wsSession.Connect() );
+        CleanupClosePushL<RWsSession>( wsSession );
+
+        CCaTaskList* taskList = CCaTaskList::NewLC( wsSession );
+        TApaTask task = taskList->FindRootApp( aUid );
+        CleanupStack::PopAndDestroy( taskList );
+
+        if( task.Exists() )
+            {
+            task.BringToForeground();
+            }
+        else
+            {
+            TApaAppInfo appInfo;
+            TApaAppCapabilityBuf capabilityBuf;
+            RApaLsSession appArcSession;
+            User::LeaveIfError( appArcSession.Connect() );
+            CleanupClosePushL<RApaLsSession>( appArcSession );
+
+            User::LeaveIfError( appArcSession.GetAppInfo( appInfo, aUid ) );
+            User::LeaveIfError( appArcSession.GetAppCapability(
+                                   capabilityBuf, aUid ) );
+
+            TApaAppCapability &caps = capabilityBuf();
+            TFileName appName = appInfo.iFullName;
+            CApaCommandLine *cmdLine = CApaCommandLine::NewLC();
+            cmdLine->SetExecutableNameL( appName );
+
+            if( caps.iLaunchInBackground )
+                {
+                cmdLine->SetCommandL( EApaCommandBackground );
+                }
+            else
+                {
+                cmdLine->SetCommandL( EApaCommandRun );
+                }
+
+            cmdLine->SetTailEndL( aParam );
+
+            User::LeaveIfError( appArcSession.StartApp( *cmdLine ) );
+
+            CleanupStack::PopAndDestroy( cmdLine );
+            CleanupStack::PopAndDestroy( &appArcSession );
         }
-        delete iUninstallOperation;
-        iUninstallOperation = NULL;
-        iUninstallOperation = CCaUninstallOperation::NewL(aEntry);
-    } else {
-        User::Leave(KErrNotSupported);
+        CleanupStack::PopAndDestroy( &wsSession );
     }
 }
 
@@ -114,85 +188,33 @@
 //
 // ---------------------------------------------------------------------------
 //
-void CCaAppHandler::LaunchApplicationL(const TUid aUid,
-                                       const TDesC8 &aParam, TInt aViewId)
+void CCaAppHandler::CloseApplicationL( CCaInnerEntry &aEntry )
 {
-    if (aViewId > 0 && iEikEnv) {
-        TUid viewId = TUid::Uid(aViewId);
-        TVwsViewId view(aUid, viewId);
-        iEikEnv->EikAppUi()->ActivateViewL(view);
-    } else {
-        RWsSession wsSession;
-        User::LeaveIfError(wsSession.Connect());
-        CleanupClosePushL<RWsSession> (wsSession);
-
-        CAknTaskList *taskList = CAknTaskList::NewL(wsSession);
-        TApaTask task = taskList->FindRootApp(aUid);
-        delete taskList;
-
-        if (task.Exists()) {
-            task.BringToForeground();
-        } else {
-            TApaAppInfo appInfo;
-            TApaAppCapabilityBuf capabilityBuf;
-            RApaLsSession appArcSession;
-            User::LeaveIfError(appArcSession.Connect());
-            CleanupClosePushL<RApaLsSession> (appArcSession);
+    RWsSession wsSession;
+    User::LeaveIfError( wsSession.Connect() );
+    CleanupClosePushL<RWsSession>( wsSession );
 
-            User::LeaveIfError(appArcSession.GetAppInfo(appInfo, aUid));
-            User::LeaveIfError(appArcSession.GetAppCapability(
-                                   capabilityBuf, aUid));
-
-            TApaAppCapability &caps = capabilityBuf();
-            TFileName appName = appInfo.iFullName;
-            CApaCommandLine *cmdLine = CApaCommandLine::NewLC();
-            cmdLine->SetExecutableNameL(appName);
+    if( ( aEntry.GetFlags() & ERunning )
+            && !( aEntry.GetFlags() & ESystem ) )
+        {
+        RBuf value;
+        CleanupClosePushL( value );
+        value.CreateL( KCaMaxAttrValueLen );
+        if( aEntry.FindAttribute( KCaAttrWindowGroupId, value ) )
+            {
+            TInt wgId( KErrNotFound );
+            TLex16 parser( value );
+            if( KErrNone == parser.Val( wgId ) && wgId > 0 )
+                {
+                TWsEvent event;
+                event.SetTimeNow();
+                event.SetType( KAknShutOrHideApp );
+                wsSession.SendEventToWindowGroup( wgId, event );
+                }
+            }
+        CleanupStack::PopAndDestroy( &value );
+    }
 
-            if (caps.iLaunchInBackground) {
-                cmdLine->SetCommandL(EApaCommandBackground);
-            } else {
-                cmdLine->SetCommandL(EApaCommandRun);
-            }
-
-            cmdLine->SetTailEndL(aParam);
-
-            User::LeaveIfError(appArcSession.StartApp(*cmdLine));
-
-            CleanupStack::PopAndDestroy(cmdLine);
-            CleanupStack::PopAndDestroy(&appArcSession);
-        }
-        CleanupStack::PopAndDestroy(&wsSession);
-    }
+    CleanupStack::PopAndDestroy( &wsSession );
 }
 
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CCaAppHandler::CloseApplicationL(CCaInnerEntry &aEntry)
-{
-    RWsSession wsSession;
-    User::LeaveIfError(wsSession.Connect());
-    CleanupClosePushL<RWsSession> (wsSession);
-
-    if ((aEntry.GetFlags() & ERunning) &&
-            (!(aEntry.GetFlags() & ESystem))) {
-        RBuf value;
-        CleanupClosePushL(value);
-        value.CreateL(KCaMaxAttrValueLen);
-        if (aEntry.FindAttribute(KCaAttrWindowGroupId, value)) {
-            TInt wgId(KErrNotFound);
-            TLex16 parser(value);
-            if (KErrNone == parser.Val(wgId) && wgId > 0) {
-                TWsEvent event;
-                event.SetTimeNow();
-                event.SetType(KAknShutOrHideApp);
-                wsSession.SendEventToWindowGroup(wgId, event);
-            }
-        }
-        CleanupStack::PopAndDestroy(&value);
-    }
-
-    CleanupStack::PopAndDestroy(&wsSession);
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/src/catasklist.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -0,0 +1,93 @@
+/*
+ * 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<apgwgnam.h>
+
+#include"catasklist.h"
+
+CCaTaskList* CCaTaskList::NewL( RWsSession& aWsSession )
+    {
+    CCaTaskList* self = NewLC( aWsSession );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CCaTaskList* CCaTaskList::NewLC( RWsSession& aWsSession )
+    {
+    CCaTaskList* self = new(ELeave) CCaTaskList( aWsSession );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CCaTaskList::CCaTaskList( RWsSession& aWsSession )
+: iWs(aWsSession)
+    {
+    }
+
+void CCaTaskList::ConstructL()
+    {
+    UpdateListL();
+    }
+
+CCaTaskList::~CCaTaskList()
+    {
+    iWgs.Close();
+    }
+
+void CCaTaskList::UpdateListL()
+    {
+    User::LeaveIfError( iWs.WindowGroupList( &iWgs ) );
+    }
+
+
+TApaTask CCaTaskList::FindRootApp( TUid aAppUid ) const
+    {
+    TApaTask task( iWs );
+    task.SetWgId(0);        // initialise task to non-existant task
+    // wgId = 0 tells FindAppByUid to start looking for apps
+    TInt wgId(0);
+    FOREVER
+        {
+        CApaWindowGroupName::FindByAppUid( aAppUid, iWs, wgId );
+        // KErrNotFound means that no more apps can be found
+        if( wgId == KErrNotFound )
+            break;
+        if( IsRootWindowGroup( wgId ) )
+            {
+            // Found a root wg with the right app UID, return it.
+            task.SetWgId( wgId );
+            break;
+            }
+        }
+    return task;
+    }
+
+TBool CCaTaskList::IsRootWindowGroup( TInt aWgId ) const
+    {
+    TInt count = iWgs.Count();
+    for( TInt i=0; i<count; i++ )
+        {
+        const RWsSession::TWindowGroupChainInfo& info = iWgs[i];
+        // find the window group id and check that it has no parent
+        if ( info.iId == aWgId )
+        	{
+            return ( info.iParentId <= 0 );
+        	}
+        }
+    return EFalse;
+    }
--- a/contentstorage/cahandler/app/src/cauninstalloperation.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/cahandler/app/src/cauninstalloperation.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -182,6 +182,7 @@
 //
 void CCaUninstallOperation::RunL()
 {
+    iUninstaller.Close();
 }
 
 // ---------------------------------------------------------------------------
--- a/contentstorage/cahandler/inc/cas60handleradapter.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/cahandler/inc/cas60handleradapter.h	Wed Mar 24 03:15:43 2010 +0200
@@ -24,7 +24,7 @@
 #include <QScopedPointer>
 #include <QString>
 #include <utf.h>
-#include <xqconversions.h>
+#include <XQConversions>
 
 #include "cainnerentry.h"
 #include "cahandler.h"
@@ -36,18 +36,10 @@
 public:
     int execute(const CaEntry &entry, const QString &commandName) {
 
-        TPtrC16 commandNameDesC16(
-            reinterpret_cast<const TUint16 *>(commandName.utf16()));
-
-        QScopedPointer<HBufC8> commandNameDesc8;
+        QScopedPointer<HBufC8> commandNameDesc8(XQConversions::qStringToS60Desc8(commandName));
+        QScopedPointer<CCaInnerEntry> innerEntry(NULL);
 
         TRAPD(result,
-              commandNameDesc8.reset(CnvUtfConverter::ConvertFromUnicodeToUtf7L(
-                                         commandNameDesC16, false)));
-
-        QScopedPointer<CCaInnerEntry> innerEntry(NULL);
-
-        TRAP(result,
              innerEntry.reset(CCaInnerEntry::NewL());
              CaObjectAdapter::convertL(entry, *innerEntry);
 
@@ -59,4 +51,5 @@
     }
 };
 
+
 #endif
--- a/contentstorage/cahandler/tapp/src/catapphandler.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/cahandler/tapp/src/catapphandler.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -38,6 +38,7 @@
  */
 CaTappHandler::CaTappHandler(QObject *parent)
 {
+	Q_UNUSED(parent);
     mAiwMgr = new XQApplicationManager();
 }
 
--- a/contentstorage/casrv/caappscanner/src/casrvappscanner.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/caappscanner/src/casrvappscanner.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -751,10 +751,10 @@
         attrVal.CreateL( KCaMaxAttrValueLen );
         aEntry->FindAttribute( KCaAttrLongName, attrVal );
         if( attrVal.Compare( info.iCaption ) != KErrNone
-                || aEntry->GetText().Compare( info.iShortCaption )
+                || aEntry->GetText().Compare( info.iCaption )
                         != KErrNone )
             {
-            aEntry->SetTextL( info.iShortCaption );
+            aEntry->SetTextL( info.iCaption );
             aEntry->AddAttributeL( KCaAttrLongName, info.iCaption );
             changed = ETrue;
             }
--- a/contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -99,10 +99,7 @@
     {
     QString locale = QLocale::system().name();
     QString filename = QString( "contentstorage_" ) + locale;
-    if( !LoadTranslator( filename ) )
-        {
-        //User::Leave(KErrNotFound); TODO what here
-        }
+    LoadTranslator( filename );
     TPtrC ptrLocale( reinterpret_cast<const TText*>( locale.constData() ) );
     TBuf<KCaMaxAttrNameLen> propertyValue;
     // trap is here to assure deletion of qtranslator in case code leaves
--- a/contentstorage/casrv/carunningappmonitor/src/carunningappmonitor.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/carunningappmonitor/src/carunningappmonitor.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -214,7 +214,6 @@
         {
         UpdateRunningAppStorageL();
         }
-    //TODO should we handle any event that will cancel observation?
     }
 
 // -----------------------------------------------------------------------------
--- a/contentstorage/casrv/cawidgetscanner/data/cawidgetscanner.rss	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/data/cawidgetscanner.rss	Wed Mar 24 03:15:43 2010 +0200
@@ -31,7 +31,7 @@
 RESOURCE REGISTRY_INFO theInfo
 	{
 	// UID for the DLL
-        dll_uid = 0x20028706;// TODO: change to proper uid
+        dll_uid = 0x20028706;
 	// Declare array of interface info
 	interfaces = 
 		{
@@ -44,7 +44,7 @@
                                 // Info for Widget
 				IMPLEMENTATION_INFO
 					{
-                                        implementation_uid = 0x20028707;// TODO: change to proper uid
+                                        implementation_uid = 0x20028707;
                                         version_no         = 1;
                                         display_name       = "Widget";
                                         default_data       = "WIDGET";
--- a/contentstorage/casrv/cawidgetscanner/group/cawidgetscanner.mmp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/group/cawidgetscanner.mmp	Wed Mar 24 03:15:43 2010 +0200
@@ -20,7 +20,7 @@
 
 TARGET          cawidgetscanner.dll
 TARGETTYPE		PLUGIN
-UID				0x10009D8D 0x20028706 // TODO: change to proper uid
+UID				0x10009D8D 0x20028706
 CAPABILITY		CAP_ECOM_PLUGIN
 
 LANG			SC
--- a/contentstorage/casrv/cawidgetscanner/inc/cawidgetdescription.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/inc/cawidgetdescription.h	Wed Mar 24 03:15:43 2010 +0200
@@ -108,6 +108,18 @@
     void SetLibraryL( const TDesC& aLibrary );
 
     /*
+     * Path setter
+     * @param aLibrary widget library
+     */
+    void SetPathL( const TDesC& aPath );
+    
+    /*
+     * Path getter
+     * @return widget library
+     */
+    TPtrC GetPath( ) const;
+    
+    /*
      * Missing flag setter
      * @param aMissing flag
      */
@@ -264,7 +276,11 @@
      */
     RBuf iIconUri;
 
-
+    /*
+     * Widget library. Own
+     */
+    RBuf iPath;
+    
     /*
      * Widget library. Own
      */
--- a/contentstorage/casrv/cawidgetscanner/inc/cawidgetscannerparser.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/inc/cawidgetscannerparser.h	Wed Mar 24 03:15:43 2010 +0200
@@ -122,7 +122,7 @@
     void SetUriL( TXmlEngElement & aElement, CCaWidgetDescription * aWidget );
 
     /**
-     * Sets widgets library
+     * Sets widgets library and path created from library
      * @param aElement xml element
      * @param aPackageUid package uid
      * @param aWidget widget to set value
--- a/contentstorage/casrv/cawidgetscanner/inc/widgetscannerutils.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/inc/widgetscannerutils.h	Wed Mar 24 03:15:43 2010 +0200
@@ -24,6 +24,7 @@
 #include <driveinfo.h>
 
 // CONSTANTS
+_LIT(KAttrWidgetPath, "widget:path");
 _LIT(KAttrWidgetLibrary, "widget:library");
 _LIT(KAttrWidgetUri, "widget:uri");
 _LIT(KSlash, "/");
--- a/contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -74,6 +74,9 @@
     //library
     iLibrary.CreateL( KCaMaxAttrValueLen );
     aEntry->FindAttribute( KAttrWidgetLibrary, iLibrary );
+    //path
+    iPath.CreateL( KCaMaxAttrValueLen );
+    aEntry->FindAttribute( KAttrWidgetPath, iPath );
     //uri
     iUri.CreateL( KCaMaxAttrValueLen );
     aEntry->FindAttribute( KAttrWidgetUri, iUri );
@@ -146,6 +149,7 @@
     iUri.Close();
     iIconUri.Close();
     iLibrary.Close();
+    iPath.Close();
     iModificationTime.Close();
     }
 
@@ -335,7 +339,23 @@
     {
     return iLibrary;
     }
-
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TPtrC CCaWidgetDescription::GetPath( ) const
+    {
+    return iPath;
+    }
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CCaWidgetDescription::SetPathL( const TDesC& aPath )
+    {
+	iPath.Close();
+	iPath.CreateL(aPath);
+    }
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -421,14 +441,12 @@
         {
         entry->SetFlags( EVisible );
         }
-
     if ( iPackageUid )
         {
         TBuf<KMaxUidName> uidDesc;
         uidDesc.AppendNum( iPackageUid,EHex );
         entry->AddAttributeL( KCaPackageUid, uidDesc );
         }
-
     if ( iEntryId != KNoId )
         {
         entry->SetId( iEntryId );
@@ -449,7 +467,10 @@
             entry->SetFlags( entry->GetFlags() & ~ERemovable );
             }
         }
-
+    if ( iPath != KNullDesC )
+        {
+        entry->AddAttributeL(KAttrWidgetPath, iPath);
+        }
     if ( iTitle != KNullDesC )
         {
         entry->SetTextL(iTitle);
--- a/contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -280,7 +280,7 @@
 }
 
 // ----------------------------------------------------------------------------
-//
+//    keep in mind that setLibrary also setsPath
 // ----------------------------------------------------------------------------
 //
 void CCaWidgetScannerParser::SetLibraryL( TXmlEngElement & aElement,
@@ -293,6 +293,10 @@
     if( attributeValue->Compare( KNullDesC ) != 0 )
         {
         HBufC *libraryPath = GetManifestDirectoryPathLC( aPackageUid );
+
+        //set path for hs to use, trim last 2 chars (doubleslash)
+        aWidget->SetPathL(libraryPath->Mid(0,libraryPath->Length()-1));
+        
         libraryPath->ReAllocL(
             libraryPath->Length() + attributeValue->Length());
 
Binary file contentstorage/castorage/data/castorage.db has changed
Binary file contentstorage/castorage/data/castoragedb has changed
--- a/contentstorage/castorage/data/castoragedb_create.sql	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/data/castoragedb_create.sql	Wed Mar 24 03:15:43 2010 +0200
@@ -211,7 +211,7 @@
 INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) 
 VALUES ( 'Version', '00001' );
 INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) 
-VALUES ( 'Language', 'en_GB' );
+VALUES ( 'Language', '' );
 INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE ) 
 VALUES ( 'QMfile', 'db_textmap_' );
 
--- a/contentstorage/castorage/data/castoragedb_variant.bat	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/data/castoragedb_variant.bat	Wed Mar 24 03:15:43 2010 +0200
@@ -1,5 +1,21 @@
+@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
 @echo off
-del castoragedb
-sqlite3 castoragedb ".read castoragedb_create.sql"
-sqlite3 castoragedb ".genfkey --exec"
-sqlite3 castoragedb ".read castoragedb_variant.sql"
+
+del castorage.db
+sqlite3 castorage.db ".read castoragedb_create.sql"
+sqlite3 castorage.db ".genfkey --exec"
+sqlite3 castorage.db ".read castoragedb_variant.sql"
--- a/contentstorage/castorage/data/castoragedb_variant_test.bat	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/data/castoragedb_variant_test.bat	Wed Mar 24 03:15:43 2010 +0200
@@ -1,5 +1,21 @@
+@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
 @echo off
-del castoragedb
-sqlite3 castoragedb ".read castoragedb_create.sql"
-sqlite3 castoragedb ".genfkey --exec"
-sqlite3 castoragedb ".read castoragedb_variant_test.sql"
+
+del castorage.db
+sqlite3 castorage.db ".read castoragedb_create.sql"
+sqlite3 castorage.db ".genfkey --exec"
+sqlite3 castorage.db ".read castoragedb_variant_test.sql"
--- a/contentstorage/castorage/inc/caconsts.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/inc/caconsts.h	Wed Mar 24 03:15:43 2010 +0200
@@ -18,7 +18,7 @@
 #ifndef CACONSTS_H_
 #define CACONSTS_H_
 
-_LIT( KDbName, "castoragedb" );
+_LIT( KDbName, "castorage.db" );
 _LIT( KCDrive, "c:" );
 _LIT( KZDrive, "z:" );
 _LIT( KDoubleSlash, "\\" );
--- a/contentstorage/castorage/inc/cadebug.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/inc/cadebug.h	Wed Mar 24 03:15:43 2010 +0200
@@ -46,14 +46,14 @@
 #endif
 
 /**
- * TODO
- *
- * @param aData
+ * Prints given descriptor to debug log file.
+ * @param aData descriptor with data.
  */
 static void DoOutput( TDesC8& aData );
 
 /**
- * TODO
+ * Prints given descriptor to debug log file.
+ * @param aFmt descriptor with data.
  */
 static void DebugStringNarrowL( const char* aFmt, ... )
     {
@@ -71,7 +71,8 @@
     }
 
 /**
- * TODO
+ * Prints given descriptor to debug log file.
+ * @param aFmt descriptor with data.
  */
 static void DebugStringWideL( const char* aFmt, ... )
     {
@@ -93,7 +94,8 @@
     }
 
 /**
- * TODO
+ * Prints given time containinf descriptor to log file.
+ * @param aBuf descriptor with time information.
  */
 static void DebugBufferL( const TDesC8& aBuf )
     {
@@ -101,7 +103,8 @@
     }
 
 /**
- * TODO
+ * Prints given time containinf descriptor to log file.
+ * @param aBuf descriptor with time information.
  */
 static void DebugBufferL( const TDesC& aBuf )
     {
@@ -109,7 +112,8 @@
     }
 
 /**
- * TODO
+ * Prints given time to log file.
+ * @param aTime time to print.
  */
 static void DebugTimeL( const TTime& aTime )
     {
@@ -123,7 +127,8 @@
     }
 
 /**
- * TODO
+ * Prints given descriptor to debug log file.
+ * @param aData descriptor with data.
  */
 static void DoOutput( TDesC8& aData )
     {
@@ -135,7 +140,8 @@
 #ifdef _KQTI_MENU_TRACE_PERFORMANCE
 
 /**
- * TODO
+ * Prints given descriptor to preformance log file.
+ * @param aData descriptor with data.
  */
 static void DoOutputPerf(TDesC8& aData)
     {
@@ -146,7 +152,8 @@
     }
 
 /**
- * TODO
+ * Formats string for performance debug output.
+ * @param aFmt string for debug output.
  */
 static void DebugStringNarrowPerfL( const char* aFmt, ... )
     {
--- a/contentstorage/castorage/inc/casqlcommands.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/inc/casqlcommands.h	Wed Mar 24 03:15:43 2010 +0200
@@ -137,16 +137,19 @@
 FROM CA_ENTRY LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID \
 WHERE ENTRY_ID IN ( %S )" );
 
-_LIT( KSQLGetList, "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, EN_ROLE, \
+_LIT( KSQLGetList1, "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 FROM \
-CA_ENTRY LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID " );
+IC_SKIN_ID, IC_APP_ID FROM CA_ENTRY " );
 
-_LIT( KSQLGetListByParentId, "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, \
+_LIT( KSQLGetList2, "LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID " );
+
+
+_LIT( KSQLGetListByParentId1, "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, \
-GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION FROM CA_ENTRY  \
-LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID LEFT JOIN CA_GROUP_ENTRY ON \
+GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION FROM CA_ENTRY " );
+
+_LIT( KSQLGetListByParentId2, "LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID LEFT JOIN CA_GROUP_ENTRY ON \
 GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID = :GE_GROUP_ID %S " );
 
 //Get all attributes by entry id
@@ -248,6 +251,14 @@
 _LIT( KAnd, " AND " );
 _LIT( KLimit, " LIMIT ");
 _LIT( KSingleQuotes, "\'" );
+_LIT( KDot, "." );
+_LIT( KEqual, " = ");
+_LIT( KEmpty, "" );
+_LIT( KGroupBy, " GROUP BY " );
+_LIT( KAt, " at" );
+_LIT( KLeftJoinCaAttrubute1, " LEFT JOIN CA_ATTRIBUTE as at" );
+_LIT( KLeftJoinCaAttrubute2, " ON ENTRY_ID = at" );
+_LIT( KLeftJoinCaAttrubute3, ".AT_ENTRY_ID " );
 
 _LIT( KSQLSortOrderNameAsc, " ORDER BY EN_TEXT ASC" );
 _LIT( KSQLSortOrderNameDesc, " ORDER BY EN_TEXT DESC" );
--- a/contentstorage/castorage/src/casqlitestorage.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/src/casqlitestorage.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -24,6 +24,7 @@
 #include "caarraycleanup.inl"
 #include "calocalizationentry.h"
 #include "cainternaltypes.h"
+#include "cadef.h"
 
 // ---------------------------------------------------------------------------
 // CCASqLiteStorage::CCpStorageEngine()
@@ -51,12 +52,25 @@
 
     User::LeaveIfError( CreatePrivateDirPath( iPrivatePathCDrive, KCDrive,
             KNullDesC ) );
+    
 
     if( iSqlDb.Open( iPrivatePathCDriveDb, &KSqlDbConfig ) )
         {
         //we could not load data base from C-drive lets try Rom
         LoadDataBaseFromRomL();
         }
+    else
+        {
+        TBuf<KCaMaxAttrNameLen> versionValue;
+        DbPropertyL(KCaDbPropVersion, versionValue);
+        ASSERT(versionValue.Length()>0);
+        if( versionValue.CompareC( KCaDbVersion ) )
+            {
+            // database loaded from C: is obsolete, load from Z:
+            iSqlDb.Close();
+            LoadDataBaseFromRomL();
+            }
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -75,7 +89,7 @@
 
     if( !( BaflUtils::FileExists( iRfs, iPrivatePathZDriveDb ) ) )
         {
-        User::Panic( _L("fatal error - castoragedb not exists in ROM"),
+        User::Panic( _L("fatal error - castorage.db not exists in ROM"),
                 KErrNotFound );
         }
     else
@@ -186,29 +200,6 @@
         CleanupStack::PopAndDestroy( sqlGetAttributesQuery );
         }
     
-    if( aQuery->GetAttributes().Count() )
-        {
-        for( int i=aResultContainer.Count()-1; i>=0; i--)
-            {
-            for( int j=0; j<aQuery->GetAttributes().Count(); j++ )
-                {
-                const TPtrC attrNameFromQuery( aQuery->GetAttributes()[j]->Name() );
-                const TPtrC attrValueFromQuery( aQuery->GetAttributes()[j]->Value() );
-                
-                TBuf16<KCaMaxAttrValueLen> value;
-                aResultContainer[i]->FindAttribute( attrNameFromQuery, value );
-                                
-                if( value.CompareC( attrValueFromQuery ) )
-                    {
-                    // remove from results
-                    delete aResultContainer[i];
-                    aResultContainer.Remove( i );
-                    break;
-                    }
-                }
-            }
-        }
-    
     //  set entries if proper order if they were fetched by ids
     if( aQuery->GetIds().Count() > 0 )
         {
@@ -246,7 +237,6 @@
 void CCaSqLiteStorage::GetEntriesIdsL( const CCaInnerQuery* aQuery,
         RArray<TInt>& aResultIdArray )
     {
-    /*
     CCaSqlQuery* sqlGetEntriesIdsQuery = CCaSqlQuery::NewLC( iSqlDb );
     CaSqlQueryCreator::CreateGetEntriesQueryL( aQuery,
             sqlGetEntriesIdsQuery );
@@ -255,17 +245,7 @@
     sqlGetEntriesIdsQuery->ExecuteL( aResultIdArray,
             CCaSqlQuery::EEntryTable );
     CleanupStack::PopAndDestroy( sqlGetEntriesIdsQuery );
-    */
-    RPointerArray<CCaInnerEntry> resultContainer;
-    CleanupResetAndDestroyPushL( resultContainer );
-    GetEntriesL( aQuery, resultContainer );
-    for( TInt i=0; i<resultContainer.Count(); i++ )
-        {
-        int id = resultContainer[i]->GetId();
-        aResultIdArray.AppendL( id );
-        }
-    
-    CleanupStack::PopAndDestroy( &resultContainer );
+
     }
 
 // ---------------------------------------------------------------------------
@@ -836,7 +816,6 @@
         case TCaOperationParams::EAppend:
         default:
             {
-            //            TODO: do nothing when default
             break;
             }
         }
--- a/contentstorage/castorage/src/casqlquery.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/src/casqlquery.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -664,19 +664,16 @@
     TInt rowCount(0);
     while( iStatement.Next() == KSqlAtRow )
         {
-        TInt entryId = iStatement.
-            ColumnInt( ColumnIndexL( iStatement, KColumnEntryId ) );
-        TInt role = iStatement.
-            ColumnInt( ColumnIndexL( iStatement, KColumnEnRole ) );
-        //        TODO get NULL ???
-        TInt32 uid = 
-        iStatement.ColumnInt( ColumnIndexL( iStatement, KColumnEnUid ) ) 
-        ? iStatement.ColumnInt( ColumnIndexL( iStatement, KColumnEnUid ) )
-        : 0;
-        TUint flags = iStatement.ColumnInt( ColumnIndexL( iStatement,
-                KColumnEnFlags ) );
-        TInt idIcon = iStatement.ColumnInt( ColumnIndexL( iStatement,
-                KColumnEnIdIcon ) );
+        TInt entryId = iStatement.ColumnInt( 
+        		ColumnIndexL( iStatement, KColumnEntryId ) );
+        TInt role = iStatement.ColumnInt( 
+        		ColumnIndexL( iStatement, KColumnEnRole ) );
+        TInt32 uid = iStatement.ColumnInt( 
+        		ColumnIndexL( iStatement, KColumnEnUid ) );
+        TUint flags = iStatement.ColumnInt( 
+        		ColumnIndexL( iStatement, KColumnEnFlags ) );
+        TInt idIcon = iStatement.ColumnInt( 
+        		ColumnIndexL( iStatement, KColumnEnIdIcon ) );
         
         TPtrC text;
         User::LeaveIfError( iStatement. ColumnText( ColumnIndexL(
--- a/contentstorage/castorage/src/casqlquerycreator.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/castorage/src/casqlquerycreator.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -668,26 +668,115 @@
                 &typeNameWhereStatement );
         CleanupStack::PopAndDestroy( &typeNameWhereStatement );
         }
+    
+    if( aQuery->GetAttributes().Count() )
+        {
+        RBuf whereAttributes;
+        whereAttributes.CleanupClosePushL();
+        whereAttributes.CreateL( KEmpty );
+        
+        for( TInt j=1; j <= aQuery->GetAttributes().Count(); j++ )
+            {
+            // at1.AT_NAME = 'Attribute_Name_1' AND at1.AT_VALUE = 'Attribute_VALUE_1'
+            TPtrC atrName( aQuery->GetAttributes().operator [](j-1)->Name() );
+            TPtrC atrValue( aQuery->GetAttributes().operator [](j-1)->Value() );
+
+            whereAttributes.ReAllocL( whereAttributes.Length() + 2 * KAnd().Length() + 
+                    4 * KSingleQuotes().Length() +
+                    2 * KMaxIntNumLength + 
+                    2 * KAt().Length() + 2 * KDot().Length() + 2 * KEqual().Length() +
+                    KColumnAttrName().Length() + KColumnAttrValue().Length() +
+                    atrName.Length() + atrValue.Length() );
+            
+            whereAttributes.Append( KAnd );
+            
+            whereAttributes.Append( KAt );
+            whereAttributes.AppendNum( j );
+            whereAttributes.Append( KDot );
+            whereAttributes.Append( KColumnAttrName );
+            whereAttributes.Append( KEqual );
+            whereAttributes.Append( KSingleQuotes );
+            whereAttributes.Append( atrName );
+            whereAttributes.Append( KSingleQuotes );
+            
+            whereAttributes.Append( KAnd );
+            
+            whereAttributes.Append( KAt );
+            whereAttributes.AppendNum( j );
+            whereAttributes.Append( KDot );
+            whereAttributes.Append( KColumnAttrValue );
+            whereAttributes.Append( KEqual );
+            whereAttributes.Append( KSingleQuotes );
+            whereAttributes.Append( atrValue );
+            whereAttributes.Append( KSingleQuotes );
+            
+            }
+        
+        whereStatement.ReAllocL( whereStatement.Length() + whereAttributes.Length() );
+        whereStatement.Append( whereAttributes );
+        
+        CleanupStack::PopAndDestroy( &whereAttributes );
+        }
+
+    RBuf leftJoins;
+    leftJoins.CleanupClosePushL();
+    leftJoins.CreateL( KEmpty );
+    if( aQuery->GetAttributes().Count() )
+        {
+        for( TInt j=1; j <= aQuery->GetAttributes().Count(); j++ )
+            {
+            // LEFT JOIN CA_ATTRIBUTE as at1 ON ENTRY_ID = at1.AT_ENTRY_ID
+            leftJoins.ReAllocL( leftJoins.Length() + 
+                    KLeftJoinCaAttrubute1().Length() + KMaxIntNumLength +
+                    KLeftJoinCaAttrubute2().Length() + KMaxIntNumLength +
+                    KLeftJoinCaAttrubute3().Length()
+                    );
+            
+            leftJoins.Append( KLeftJoinCaAttrubute1 );
+            leftJoins.AppendNum( j );
+            leftJoins.Append( KLeftJoinCaAttrubute2 );
+            leftJoins.AppendNum( j );
+            leftJoins.Append( KLeftJoinCaAttrubute3 );
+            }
+        }
+    
+    
+    whereStatement.ReAllocL( whereStatement.Length() + 
+            KGroupBy().Length() + KColumnEntryId().Length() );
+    whereStatement.Append( KGroupBy );
+    whereStatement.Append( KColumnEntryId );
 
     TInt groupId = aQuery->GetParentId();
     RBuf query;
     query.CleanupClosePushL();
     if( groupId > 0 )
         {
-        query.CreateL( KSQLGetListByParentId().Length()
-                + whereStatement.Length() - 2 );
-        query.AppendFormat( KSQLGetListByParentId, &whereStatement );
+        RBuf getListByParentId2withWhere;
+        getListByParentId2withWhere.CleanupClosePushL();
+        getListByParentId2withWhere.CreateL( KSQLGetListByParentId2().Length() + whereStatement.Length() );
+        getListByParentId2withWhere.AppendFormat( KSQLGetListByParentId2, &whereStatement );
+        
+        query.ReAllocL( KSQLGetListByParentId1().Length() +  leftJoins.Length() +
+                getListByParentId2withWhere.Length() );
+        query.Append( KSQLGetListByParentId1 );
+        query.Append( leftJoins );
+        query.Append( getListByParentId2withWhere );
+        CleanupStack::PopAndDestroy( &getListByParentId2withWhere );
         }
     else
         {
-        query.CreateL( KSQLGetList().Length() );
-        query.Append( KSQLGetList );
+        query.CreateL( KSQLGetList1().Length() );
+        query.Append( KSQLGetList1 );
+        query.ReAllocL( query.Length() + leftJoins.Length() + KSQLGetList2().Length() );
+        query.Append( leftJoins );
+        query.Append( KSQLGetList2 );
         if( whereStatement.Length() >= KAnd().Length() )
             {
             TPtrC ptrWhereStatement( whereStatement.Right(
                     whereStatement.Length() - KAnd().Length() ) );
-            query.ReAllocL( KSQLGetList().Length() + KWhere().Length()
+            query.ReAllocL( query.Length() +  KWhere().Length()
                     + ptrWhereStatement.Length() );
+
             query.Append( KWhere );
             query.Append( ptrWhereStatement );
             }
@@ -707,6 +796,7 @@
 
     aSqlQuery->SetQueryL( query );
     CleanupStack::PopAndDestroy( &query );
+    CleanupStack::PopAndDestroy( &leftJoins );
     CleanupStack::PopAndDestroy( &whereStatement );
     }
 
--- a/contentstorage/cautils/src/cainnerquery.cpp	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/cautils/src/cainnerquery.cpp	Wed Mar 24 03:15:43 2010 +0200
@@ -128,8 +128,7 @@
     {
     iEntryTypeNames = new ( ELeave ) CDesC16ArrayFlat( KDefaultGranularity );
     iParentId = -1;
-    //    TODO Item | Group
-    iRole = CCaInnerQuery::Item | CCaInnerQuery::Group;
+    iRole = Item | Group;
     }
 
 // ---------------------------------------------------------------------------
@@ -194,7 +193,6 @@
 //
 EXPORT_C void CCaInnerQuery::SetEntryTypeNames( CDesC16ArrayFlat* aArray )
     {
-    //TODO: Quickt setter for now, probably sth more convinient needed
     ASSERT( aArray );
     delete iEntryTypeNames;
     iEntryTypeNames = aArray;
--- a/contentstorage/group/group.pro	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/group/group.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -19,9 +19,9 @@
 #Exporting ibys
 BLD_INF_RULES.prj_exports += \
      "$${LITERAL_HASH}ifndef CONTENT_ARSENAL_STORAGE_UT" \
-     "../castorage/data/castoragedb z:/private/20022F90/castoragedb" \
+     "../castorage/data/castorage.db z:/private/20022F90/castorage.db" \
      "$${LITERAL_HASH}else " \
-     "../castorage/data/castoragedb z:/castoragedb" \
+     "../castorage/data/castorage.db z:/castorage.db" \
      "$${LITERAL_HASH}endif" \
      "../data/backup_registration.xml z:/private/20022F90/backup_registration.xml"
 
--- a/contentstorage/inc/cadef.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/inc/cadef.h	Wed Mar 24 03:15:43 2010 +0200
@@ -12,7 +12,7 @@
  * Contributors:
  *
  * Description:  Definition of different constants
- *  Version     : %version: 10.1.6 % << Don't touch! Updated by Synergy at check-out.
+ *  Version     : %version: 10.1.7 % << Don't touch! Updated by Synergy at check-out.
  *
  */
 
@@ -22,6 +22,12 @@
 #include <e32base.h>
 #include "cainternaltypes.h"
 
+
+// database version
+_LIT( KCaDbVersion, "00001" ); 
+
+
+
 // ---------------------------------------------------------
 //Ca constants
 
--- a/contentstorage/inc/casrvdef.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/inc/casrvdef.h	Wed Mar 24 03:15:43 2010 +0200
@@ -35,8 +35,6 @@
 const TInt KInputPosition2 = 1;
 const TInt KOutputPosition = 2;
 
-//TODO: move to another location so that server have access to it
-// Opcodes used in message passing between client and server
 enum TCaServerRequests
     {
     EContentArsenalGetList_GetSize = 100,
--- a/contentstorage/srvinc/cainstallnotifier.h	Tue Mar 23 23:55:55 2010 +0200
+++ b/contentstorage/srvinc/cainstallnotifier.h	Wed Mar 24 03:15:43 2010 +0200
@@ -85,7 +85,7 @@
      * @param aNotifier Reference to notifier interface.
      * @param aNotificationType Notification type.
      */
-    static CCaInstallNotifier* NewL( MCaInstallListener& aListener,
+IMPORT_C static CCaInstallNotifier* NewL( MCaInstallListener& aListener,
             TNotificationType aNotificationType );
 
     /**
--- a/homescreensrv.pro	Tue Mar 23 23:55:55 2010 +0200
+++ b/homescreensrv.pro	Wed Mar 24 03:15:43 2010 +0200
@@ -23,6 +23,7 @@
             homescreensrv_plat \
             screensavermodel \
             bagetmodel \
+            activitymanager \
             tsrc
 
 CONFIG += ordered
--- a/rom/homescreensrv_core.iby	Tue Mar 23 23:55:55 2010 +0200
+++ b/rom/homescreensrv_core.iby	Wed Mar 24 03:15:43 2010 +0200
@@ -31,7 +31,6 @@
 file=ABI_DIR\BUILD_DIR\casathandler.dll     SHARED_LIB_DIR\casathandler.dll
 file=ABI_DIR\BUILD_DIR\castorage.dll     SHARED_LIB_DIR\castorage.dll
 file=ABI_DIR\BUILD_DIR\MenuInterface.dll     SHARED_LIB_DIR\MenuInterface.dll
-ECOM_PLUGIN( castockhandlerplugins.dll, castockhandlerplugins.rsc )
 file=ABI_DIR\BUILD_DIR\casrvmanager.dll     SHARED_LIB_DIR\casrvmanager.dll
 ECOM_PLUGIN( casatmonitor.dll, casatmonitor.rsc )
 ECOM_PLUGIN( caappscanner.dll, caappscanner.rsc )
@@ -39,7 +38,7 @@
 ECOM_PLUGIN( calocalizerscanner.dll, calocalizerscanner.rsc )
 ECOM_PLUGIN( carunningappmonitor.dll, carunningappmonitor.rsc )
 
-data=ZPRIVATE\20022F90\castoragedb          private\20022F90\castoragedb
+data=ZPRIVATE\20022F90\castorage.db          private\20022F90\castorage.db
 
 // ---- appfoundation --------------------------------------------
 
--- a/sis/homescreensrv.pkg	Tue Mar 23 23:55:55 2010 +0200
+++ b/sis/homescreensrv.pkg	Wed Mar 24 03:15:43 2010 +0200
@@ -137,7 +137,7 @@
 "/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/castockhandlerplugins.dll" - "c:/sys/bin/castockhandlerplugins.dll"
-"/epoc32/data/z/private/20022F90/castoragedb" - "c:/private/20022F90/castoragedb"
+"/epoc32/data/z/private/20022F90/castorage.db" - "c:/private/20022F90/castorage.db"
 "/epoc32/data/z/resource/plugins/castockhandlerplugins.rsc"-"c:/resource/plugins/castockhandlerplugins.rsc"
 
 ; ---- appfoundation --------------------------------------------