Revision: 201011
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 14:54:01 +0300
changeset 36 cdae8c6c3876
parent 35 f9ce957a272c
child 39 4e8ebe173323
Revision: 201011 Kit: 201015
homescreenapp/common.pri
homescreenapp/examples/contentpublishclient/contentpublishclient.pro
homescreenapp/examples/contentpublishclient/inc/contentpublishclient.h
homescreenapp/examples/contentpublishclient/sis/contentpublishclient.pkg
homescreenapp/examples/contentpublishclient/src/contentpublishclient.cpp
homescreenapp/examples/contentpublishclient/src/main.cpp
homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/helloworldwidgetplugin.pro
homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.s60xml
homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.xml
homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.xml_for_sisx
homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/src/helloworldwidgetplugin.cpp
homescreenapp/examples/helloworldwidgetplugin/sis/helloworldwidgetplugin.bat
homescreenapp/examples/helloworldwidgetplugin/sis/helloworldwidgetplugin.pkg
homescreenapp/homescreenapp.pro
homescreenapp/hsapplication/conf/base/confml/data.confml
homescreenapp/hsapplication/conf/base/confml/homescreen_view.confml
homescreenapp/hsapplication/conf/base/confml/homescreendb.confml
homescreenapp/hsapplication/conf/base/implml/homescreendb.implml
homescreenapp/hsapplication/conf/base/implml/homescreendb_templates/create.sql
homescreenapp/hsapplication/conf/base/implml/homescreendb_templates/fill.sql
homescreenapp/hsapplication/conf/base/root.confml
homescreenapp/hsapplication/conf/product_1/confml/data.confml
homescreenapp/hsapplication/conf/product_1/root.confml
homescreenapp/hsapplication/conf/product_1_root.confml
homescreenapp/hsapplication/conf/product_2/root.confml
homescreenapp/hsapplication/conf/product_2_root.confml
homescreenapp/hsapplication/conf/root.confml
homescreenapp/hsapplication/conf/variant_1_of_product_1/root.confml
homescreenapp/hsapplication/conf/variant_1_of_product_1_root.confml
homescreenapp/hsapplication/conf/variant_2_of_product_1/root.confml
homescreenapp/hsapplication/conf/variant_2_of_product_1_root.confml
homescreenapp/hsapplication/conf/variant_3_of_product_1/root.confml
homescreenapp/hsapplication/conf/variant_3_of_product_1_root.confml
homescreenapp/hsapplication/conf/variant_4_of_product_1/root.confml
homescreenapp/hsapplication/conf/variant_4_of_product_1_root.confml
homescreenapp/hsapplication/conf/variant_5_of_product_1/root.confml
homescreenapp/hsapplication/conf/variant_5_of_product_1_root.confml
homescreenapp/hsapplication/hsapplication.pri
homescreenapp/hsapplication/hsapplication.pro
homescreenapp/hsapplication/inc/hshomescreen.h
homescreenapp/hsapplication/inc/hshomescreenclientserviceprovider.h
homescreenapp/hsapplication/installs_symbian.pri
homescreenapp/hsapplication/installs_win.pri
homescreenapp/hsapplication/ipc_service_conf.xml
homescreenapp/hsapplication/loc/Homescreen_v0 5.xls
homescreenapp/hsapplication/resource_s60/homescreen.db
homescreenapp/hsapplication/resource_s60/homescreendb
homescreenapp/hsapplication/resource_win/homescreen.db
homescreenapp/hsapplication/resource_win/homescreendb
homescreenapp/hsapplication/src/hshomescreen.cpp
homescreenapp/hsapplication/src/hshomescreenclientserviceprovider.cpp
homescreenapp/hsapplication/src/main.cpp
homescreenapp/hscontentpublishplugin/hscontentpublishplugin.pri
homescreenapp/hscontentpublishplugin/hscontentpublishplugin.pro
homescreenapp/hscontentpublishplugin/inc/hscontentpublishplugin.h
homescreenapp/hscontentpublishplugin/inc_symbian/hshomescreenclient.h
homescreenapp/hscontentpublishplugin/inc_win/hshomescreenclient.h
homescreenapp/hscontentpublishplugin/resource/hscontentpublishplugin.s60xml
homescreenapp/hscontentpublishplugin/resource/hscontentpublishplugin.xml
homescreenapp/hscontentpublishplugin/src/hscontentpublishplugin.cpp
homescreenapp/hscontentpublishplugin/src/hshomescreenclient_symbian.cpp
homescreenapp/hscontentpublishplugin/src/hshomescreenclient_win.cpp
homescreenapp/hsdomainmodel/hsdomainmodel.pri
homescreenapp/hsdomainmodel/inc/hscontentpublishhandler.h
homescreenapp/hsdomainmodel/inc/hscontentservice.h
homescreenapp/hsdomainmodel/inc/hsdatabase.h
homescreenapp/hsdomainmodel/inc/hsdomainmodeldatastructures.h
homescreenapp/hsdomainmodel/inc/hsipcchannel.h
homescreenapp/hsdomainmodel/inc/hsipcchannelclient.h
homescreenapp/hsdomainmodel/inc/hsipcchannelhost.h
homescreenapp/hsdomainmodel/inc/hsipcconnectiondispatcher.h
homescreenapp/hsdomainmodel/inc/hsipcserver.h
homescreenapp/hsdomainmodel/inc/hspage.h
homescreenapp/hsdomainmodel/inc/hspagedata.h
homescreenapp/hsdomainmodel/inc/hsscene.h
homescreenapp/hsdomainmodel/inc/hsscene_p.h
homescreenapp/hsdomainmodel/inc/hsscenedata.h
homescreenapp/hsdomainmodel/inc/hswallpaper.h
homescreenapp/hsdomainmodel/inc/hswallpaper_p.h
homescreenapp/hsdomainmodel/inc/hswidgetdata.h
homescreenapp/hsdomainmodel/inc/hswidgethost.h
homescreenapp/hsdomainmodel/inc/hswidgetpresentationdata.h
homescreenapp/hsdomainmodel/src/hscontentpublishhandler.cpp
homescreenapp/hsdomainmodel/src/hscontentservice.cpp
homescreenapp/hsdomainmodel/src/hsdatabase.cpp
homescreenapp/hsdomainmodel/src/hsipcchannel.cpp
homescreenapp/hsdomainmodel/src/hsipcchannelclient.cpp
homescreenapp/hsdomainmodel/src/hsipcchannelhost.cpp
homescreenapp/hsdomainmodel/src/hsipcconnectiondispatcher.cpp
homescreenapp/hsdomainmodel/src/hsipcserver.cpp
homescreenapp/hsdomainmodel/src/hspage.cpp
homescreenapp/hsdomainmodel/src/hspagedata.cpp
homescreenapp/hsdomainmodel/src/hsscene.cpp
homescreenapp/hsdomainmodel/src/hsscenedata.cpp
homescreenapp/hsdomainmodel/src/hsshortcutservice.cpp
homescreenapp/hsdomainmodel/src/hswallpaper.cpp
homescreenapp/hsdomainmodel/src/hswidgetdata.cpp
homescreenapp/hsdomainmodel/src/hswidgethost.cpp
homescreenapp/hsdomainmodel/src/hswidgetpresentationdata.cpp
homescreenapp/hshomescreenclientplugin/hshomescreenclientplugin.pri
homescreenapp/hshomescreenclientplugin/hshomescreenclientplugin.pro
homescreenapp/hshomescreenclientplugin/inc/hshomescreenclient.h
homescreenapp/hshomescreenclientplugin/inc/hshomescreenclientplugin.h
homescreenapp/hshomescreenclientplugin/resource/hshomescreenclientplugin.s60xml
homescreenapp/hshomescreenclientplugin/resource/hshomescreenclientplugin.xml
homescreenapp/hshomescreenclientplugin/src/hshomescreenclient.cpp
homescreenapp/hshomescreenclientplugin/src/hshomescreenclientplugin.cpp
homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/inc/t_hshomescreenclientplugin.h
homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/sis/gen_sisx.bat
homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/sis/t_hshomescreenclientplugin.pkg
homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/src/t_hshomescreenclientplugin.cpp
homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/t_hshomescreenclientplugin.pri
homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/t_hshomescreenclientplugin.pro
homescreenapp/hshomescreenclientplugin/tsrc/tsrc.pro
homescreenapp/hsmenucontentpublish/hsmenucontentpublish.pro
homescreenapp/hsmenucontentpublish/inc/hsmenucontentpublish.h
homescreenapp/hsmenucontentpublish/inc/hsmenucontentpublish_p.h
homescreenapp/hsmenucontentpublish/inc/hsmenucontentpublishplugin.h
homescreenapp/hsmenucontentpublish/resource/hsmenucontentpublish.s60xml
homescreenapp/hsmenucontentpublish/resource/hsmenucontentpublish.xml
homescreenapp/hsmenucontentpublish/src/hsmenucontentpublish.cpp
homescreenapp/hsmenucontentpublish/src/hsmenucontentpublishplugin.cpp
homescreenapp/hsutils/inc/hsmenueventfactory.h
homescreenapp/hsutils/inc/hspageindicator.h
homescreenapp/hsutils/inc/hspageindicatoritem.h
homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h
homescreenapp/hsutils/src/hsmenueventfactory.cpp
homescreenapp/hsutils/src/hspageindicator.cpp
homescreenapp/hsutils/src/hspageindicatoritem.cpp
homescreenapp/hsutils/src/hstrashbinwidget.cpp
homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp
homescreenapp/hsutils/src/xqaiwgetimageclient.cpp
homescreenapp/inc/hsapp_defs.h
homescreenapp/inc/hsapp_defs.inl
homescreenapp/rom/homescreenapp_core.iby
homescreenapp/rom/homescreenapp_resources.iby
homescreenapp/runtimeplugins/hsdefaultruntimeplugin/inc/hsdefaultruntime.h
homescreenapp/runtimeplugins/hsdefaultruntimeplugin/resource/hsdefaultruntimeplugin.s60xml
homescreenapp/runtimeplugins/hsdefaultruntimeplugin/resource/hsdefaultruntimeplugin.xml
homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsdefaultruntime.cpp
homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsdefaultruntimeplugin.cpp
homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro
homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice.h
homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp
homescreenapp/sis/homescreenapp.pkg
homescreenapp/sis/homescreenapp_ut_hs.pkg
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallappsstate.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hscollectionstate.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hshomescreenstatecommon.h
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlestate.h
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlewidget.h
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsselectbackgroundstate.h
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlewidget.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsselectbackgroundstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.qrc
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddtohomescreenstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsappschecklist.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsarrangestate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsmenustates_global.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hspreviewhswidgetstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsappschecklist.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsarrangestate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hscollectionnamedialog.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hspreviewhswidgetstate.cpp
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsclockwidgetplugin.s60xml
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsclockwidgetplugin.xml
homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsclockwidget.cpp
homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsclockwidgetplugin.cpp
homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/inc/hsanalogclockstyleplugin.h
homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/resource/hsanalogclockwidget.css
homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/src/hsanalogclockstyleplugin.cpp
homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidgetplugin.s60xml
homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidgetplugin.xml
homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidget.cpp
homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidgetplugin.cpp
layers.sysdef.xml
package_definition.xml
taskswitcherapp/common.pri
taskswitcherapp/rom/tsapplication_core.iby
taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/src/tsdefaultruntime.cpp
taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/src/tsdefaultruntimeplugin.cpp
taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/tsdefaultruntimeplugin.pro
taskswitcherapp/sis/stubs/taskswitcher_stub.pkg
taskswitcherapp/sis/stubs/taskswitcher_stub.sis
taskswitcherapp/sis/taskswitcher.pkg
taskswitcherapp/taskswitcherapp.pro
taskswitcherapp/tsapplication/tsapplication.pro
taskswitcherapp/tsserviceplugin/inc/s60/tsexternalactivationwatcher_p.h
taskswitcherapp/tsserviceplugin/inc/tsclosedapplicationsfiltermodel.h
taskswitcherapp/tsserviceplugin/inc/tsdeactivation.h
taskswitcherapp/tsserviceplugin/inc/tsexternalactivationwatcher.h
taskswitcherapp/tsserviceplugin/inc/tspresentation.h
taskswitcherapp/tsserviceplugin/inc/tsrecentapplicationsmodel.h
taskswitcherapp/tsserviceplugin/inc/tstasksgriditem.h
taskswitcherapp/tsserviceplugin/inc/win/tsexternalactivationwatcher_p.h
taskswitcherapp/tsserviceplugin/resource/tsexternalactivation.qcrml
taskswitcherapp/tsserviceplugin/src/s60/tsexternalactivationwatcher_p.cpp
taskswitcherapp/tsserviceplugin/src/s60/tslongpresswatcher_p.cpp
taskswitcherapp/tsserviceplugin/src/tsactivation.cpp
taskswitcherapp/tsserviceplugin/src/tsclosedapplicationsfiltermodel.cpp
taskswitcherapp/tsserviceplugin/src/tsdeactivation.cpp
taskswitcherapp/tsserviceplugin/src/tsdocumentloader.cpp
taskswitcherapp/tsserviceplugin/src/tsexternalactivationwatcher.cpp
taskswitcherapp/tsserviceplugin/src/tsitemprovider.cpp
taskswitcherapp/tsserviceplugin/src/tslongpresswatcher.cpp
taskswitcherapp/tsserviceplugin/src/tspresentation.cpp
taskswitcherapp/tsserviceplugin/src/tsrecentapplicationsmodel.cpp
taskswitcherapp/tsserviceplugin/src/tsserviceplugin.cpp
taskswitcherapp/tsserviceplugin/src/tstaskpopuphandler.cpp
taskswitcherapp/tsserviceplugin/src/tstasksgriditem.cpp
taskswitcherapp/tsserviceplugin/src/win/tsexternalactivationwatcher_p.cpp
taskswitcherapp/tsserviceplugin/tsrc/t_tsitemprovider/data/castorage.db
taskswitcherapp/tsserviceplugin/tsrc/t_tsitemprovider/data/castoragedb
taskswitcherapp/tsserviceplugin/tsserviceplugin.pro
--- a/homescreenapp/common.pri	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/common.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -103,7 +103,7 @@
     message(Remove "contains(MOBILITY, serviceframework)" after the QtSF refactorig is done!)
         
     !contains(MOBILITY, serviceframework):qtplugins.sources += resource/$${TARGET}.manifest
-    contains(MOBILITY, serviceframework):BLD_INF_RULES.prj_exports += "resource/$${TARGET}.s60xml z:$$qtplugins.path/$${TARGET}.xml"
+    contains(MOBILITY, serviceframework):BLD_INF_RULES.prj_exports += "resource/$${TARGET}.xml z:$$qtplugins.path/$${TARGET}.xml"
     
     for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin z:$$qtplugins.path/$$basename(qtplugin)"
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/contentpublishclient/contentpublishclient.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Example of home screen content publishing client
+#
+
+TEMPLATE = app
+
+CONFIG +=  mobility console debug
+
+MOBILITY = serviceframework
+
+HEADERS += ./inc/*.h
+SOURCES += ./src/*.cpp
+
+INCLUDEPATH += ./inc
+
+QT += xml
+
+symbian: {
+    SYMBIAN_PLATFORMS = WINSCW ARMV5
+    # this should remove localization for test application
+    load(hb.prf)
+    CONFIG -= symbian_i18n
+    TARGET.UID3 = 0x20022F74
+    TARGET.CAPABILITY = CAP_APPLICATION AllFiles TrustedUI
+    TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+    LIBS += -lefsrv
+} else {
+    error("Only Symbian supported!")
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/contentpublishclient/inc/contentpublishclient.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Example of home screen content publishing client
+*
+*/
+
+#include <QObject>
+
+#include <qservicemanager.h>
+
+QTM_USE_NAMESPACE
+
+class ContentPublishClient: public QObject
+{
+    Q_OBJECT
+    
+public:
+    ContentPublishClient(QServiceManager &manager, QObject *parent=0 );
+    ~ContentPublishClient();
+    bool load();
+    
+public slots:
+    void addWidget();
+
+private:
+    QObject* mService;
+    QServiceManager* mManager;    
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/contentpublishclient/sis/contentpublishclient.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,38 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"contentpublishclient"},(0x20022F74),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+ 
+"/epoc32/release/armv5/urel/contentpublishclient.exe"                         - "c:/sys/bin/contentpublishclient.exe"
+"/epoc32/data/z/private/10003a3f/import/apps/contentpublishclient_reg.rsc"    - "c:/private/10003a3f/import/apps/contentpublishclient_reg.rsc"
+"/epoc32/data/z/resource/apps/contentpublishclient.rsc"                       - "c:/resource/apps/contentpublishclient.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/contentpublishclient/src/contentpublishclient.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Example of home screen content publishing client
+*
+*/
+
+#include <qservicefilter.h>
+#include <qserviceinterfacedescriptor.h>
+
+#include <QMetaObject>
+#include <QMetaMethod>
+
+#include "contentpublishclient.h"
+
+/*!
+    \ingroup group_content_publish_client
+    \class ContentPublishClient
+    \brief Example implementation for home screen content publish client.
+
+    ContentPublishClient is derived from QObject and implements 
+    needed functions for the home screen content publish client. 
+*/
+
+/*!
+    Constructor.
+*/
+ContentPublishClient::ContentPublishClient(QServiceManager &manager, QObject *parent)
+    : QObject(parent),
+      mManager(&manager)
+{
+}
+
+/*!
+    Destructor
+*/
+ContentPublishClient::~ContentPublishClient()
+{
+}
+
+/*!
+    Loads service interface
+*/
+bool ContentPublishClient::load()
+{    
+    QServiceFilter filter("com.nokia.symbian.IHomeScreenClient");
+    filter.setServiceName("hshomescreenclientplugin");
+    QList<QServiceInterfaceDescriptor> interfaces = mManager->findInterfaces(filter);
+
+    if(interfaces.isEmpty()) {
+        QServiceManager::Error error = mManager->error();
+        return false;
+    }
+    qDebug() << interfaces.first().interfaceName()
+             << interfaces.first().serviceName()
+             <<  interfaces.first().isValid();
+
+    mService = mManager->loadInterface(interfaces.first());
+        
+    return (mService);
+}
+
+/*!
+    Adds widget utilizing service interface and invoke call
+*/
+void ContentPublishClient::addWidget()
+{   
+    QByteArray signature = QMetaObject::normalizedSignature("addWidget(QString,QVariantHash)");
+    int methodIndex = mService->metaObject()->indexOfMethod(signature);   
+    QMetaMethod method = mService->metaObject()->method(methodIndex);
+    bool retVal(false);
+
+    QString widget = "hsclockwidgetplugin";
+    
+    bool ret = method.invoke( mService,
+                              Qt::DirectConnection,
+                              Q_RETURN_ARG(bool, retVal),
+                              Q_ARG(QString,widget),
+                              Q_ARG(QVariantHash,QVariantHash()));
+                    
+    if(!ret){
+        qDebug()<< "method invoke failed!";
+    }
+    if(!retVal){
+        qDebug() << "addWidget() failed!!";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/contentpublishclient/src/main.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Example of home screen content publishing client
+*
+*/
+
+#include <HbApplication>
+#include <HbMainWindow>
+#include <HbView>
+#include <HbPushButton>
+
+#include <QDir>
+
+#include "contentpublishclient.h"
+
+int main(int argc, char *argv[])
+{
+	// Initialization
+    HbApplication app(argc, argv);
+
+    QString path = QDir::toNativeSeparators(QDir("z:\\hsresources\\plugins\\homescreenclientplugin\\").absolutePath());
+    QString fullFileName = path + "\\hshomescreenclientplugin.xml";
+    
+    QServiceManager manager;
+    
+    if(QFile::exists(fullFileName)) {
+        QCoreApplication::addLibraryPath(path);
+        manager.addService(fullFileName);
+    }
+    
+    // Create main window.
+    HbMainWindow* mainWindow = new HbMainWindow();
+
+    // Create content publisher client
+	ContentPublishClient contentPublishClient(manager);
+	
+    QString buttonString = "Create widget";
+    if(!contentPublishClient.load()) {
+        buttonString = "Open failed";
+    }
+
+    HbPushButton* button = new HbPushButton(buttonString);
+
+	// Add view
+    mainWindow->addView(button);
+    
+    contentPublishClient.connect(button, SIGNAL(pressed()), SLOT(addWidget()));
+    
+    // Show main window
+    mainWindow->show();
+
+    return app.exec();
+}
--- a/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/helloworldwidgetplugin.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/helloworldwidgetplugin.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -21,14 +21,11 @@
 HEADERS += ./inc/*.h
 SOURCES += ./src/*.cpp
 
-DESTDIR = $${EPOCROOT}epoc32/data/c/private/20022F35/import/widgetregistry/20022F7E
-win32: PLUGIN_SUBDIR = /hsresources/import/widgetregistry/20022F7E
-symbian: PLUGIN_SUBDIR = /private/20022F35/import/widgetregistry/20022F7E
-include(../../../common.pri)
-
 INCLUDEPATH += ./inc               
 
 symbian: {
+
+    DESTDIR = /private/20022F35/import/widgetregistry/20022F7E
     INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 
     TARGET.UID3 = 0x20022F7E
@@ -36,18 +33,32 @@
     TARGET.CAPABILITY = ALL -TCB
     
     plugins.path = $${DESTDIR}
-    plugins.sources = $${TARGET}.dll
+    plugins.sources = $${TARGET}.dll 
     
     widgetResources.path = $${DESTDIR}
     widgetResources.sources += resource/$${TARGET}.xml    
     widgetResources.sources += resource/$${TARGET}.manifest
     widgetResources.sources += resource/$${TARGET}.png
-    
+        
     DEPLOYMENT += plugins \
                   widgetResources
 }
 
+win32: {
 
-exportResources(./resource/*.manifest, $$PLUGIN_SUBDIR)
-exportResources(./resource/*.png, $$PLUGIN_SUBDIR)
-exportResources(./resource/*.xml, $$PLUGIN_SUBDIR)
+    CONFIG(debug, debug|release) {
+      SUBDIRPART = debug
+    } else {
+      SUBDIRPART = release
+    }    
+    
+    PLUGIN_SUBDIR = /hsresources/import/widgetregistry/20022F7E
+    
+    DESTDIR = $$PWD/../../../../../bin/$${SUBDIRPART}/$${PLUGIN_SUBDIR}
+
+    manifest.path = $${DESTDIR}
+    manifest.files = ./resource/*.manifest ./resource/*.xml ./resource/*.png
+    
+    INSTALLS += manifest    
+    
+}
--- a/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.s60xml	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<service>
-    <name>helloworldwidgetplugin</name>
-    <filepath>c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.qtplugin</filepath>
-    <description>Example widget</description>
-    <interface>
-        <name>com.nokia.IHomeScreenWidget</name>
-        <version>1.0</version>
-        <description>Example of home screen widget</description>
-        <capabilities></capabilities>
-        <customproperty key="iconuri">helloworldwidgetplugin.png</customproperty>
-        <customproperty key="title">HelloWorld</customproperty>
-    </interface>
-</service>
--- a/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>helloworldwidgetplugin</filepath>
     <description>Example widget</description>
     <interface>
-        <name>com.nokia.IHomeScreenWidget</name>
+        <name>com.nokia.symbian.IHomeScreenWidget</name>
         <version>1.0</version>
         <description>Example of home screen widget</description>
         <capabilities></capabilities>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/resource/helloworldwidgetplugin.xml_for_sisx	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service>
+    <name>helloworldwidgetplugin</name>
+    <filepath>c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.qtplugin</filepath>
+    <description>Example widget</description>
+    <interface>
+        <name>com.nokia.symbian.IHomeScreenWidget</name>
+        <version>1.0</version>
+        <description>Example of home screen widget</description>
+        <capabilities></capabilities>
+        <customproperty key="iconuri">helloworldwidgetplugin.png</customproperty>
+        <customproperty key="title">HelloWorld</customproperty>
+    </interface>
+</service>
--- a/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/src/helloworldwidgetplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/examples/helloworldwidgetplugin/helloworldwidgetplugin/src/helloworldwidgetplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -62,7 +62,7 @@
         <filepath>helloworldwidgetplugin</filepath>
         <description>Example widget</description>
         <interface>
-            <name>com.nokia.IHomeScreenWidget</name>
+            <name>com.nokia.symbian.IHomeScreenWidget</name>
             <version>1.0</version>
             <description>Example of home screen widget</description>
             <capabilities></capabilities>
@@ -88,9 +88,9 @@
     CONFIG += plugin mobility hb
     MOBILITY = serviceframework
     
-    HEADERS += ./inc/*.h
-    SOURCES += ./src/*.cpp
-    
+    HEADERS += ./inc/ .h
+    SOURCES += ./src/ .cpp
+  
     DESTDIR = $${EPOCROOT}epoc32/data/c/private/20022F35/import/widgetregistry/20022F7E
     
     INCLUDEPATH += ./inc               
@@ -136,7 +136,7 @@
     Q_UNUSED(context);
     Q_UNUSED(session);
 
-    if (descriptor.interfaceName() == QLatin1String("com.nokia.IHomeScreenWidget")) {
+    if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IHomeScreenWidget")) {
         return new HelloWorldWidget();
     } else {
         return 0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/examples/helloworldwidgetplugin/sis/helloworldwidgetplugin.bat	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,30 @@
+@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
+
+if exist helloworldwidgetplugin.sisx del helloworldwidgetplugin.sisx
+
+makesis helloworldwidgetplugin.pkg
+signsis helloworldwidgetplugin.sis helloworldwidgetplugin.sisx ../../../sis/rd.cer ../../../sis/rd-key.pem
+
+if exist helloworldwidgetplugin.sisx (
+echo helloworldwidgetplugin.sisx creation SUCCEEDED
+del helloworldwidgetplugin.sis
+)
+
+if not exist helloworldwidgetplugin.sisx (
+echo helloworldwidgetplugin.sisx creation FAILED
+)
\ No newline at end of file
--- a/homescreenapp/examples/helloworldwidgetplugin/sis/helloworldwidgetplugin.pkg	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/examples/helloworldwidgetplugin/sis/helloworldwidgetplugin.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -34,9 +34,9 @@
 [0x1028315F],0,0,0,{"S60ProductID"}
  
 "/epoc32/release/armv5/urel/helloworldwidgetplugin.dll"                                           - "c:/sys/bin/helloworldwidgetplugin.dll"
-"/epoc32/data/c/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.qtplugin"  - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.qtplugin"
-"/epoc32/data/c/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.manifest"  - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.manifest"
-"/epoc32/data/c/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.xml"       - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.xml"
-"/epoc32/data/c/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.png"       - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.png"
+"/epoc32/data/z/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.qtplugin"  - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.qtplugin"
+"/epoc32/data/z/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.manifest"  - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.manifest"
+"../helloworldwidgetplugin/resource/helloworldwidgetplugin.xml_for_sisx"                          - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.xml"
+"/epoc32/data/z/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.png"       - "c:/private/20022F35/import/widgetregistry/20022F7E/helloworldwidgetplugin.png"
 
 "/epoc32/release/armv5/urel/helloworldwidgetplugininstaller.exe"                                  - "c:/sys/bin/helloworldwidgetplugininstaller.exe", FR, RB, RW
--- a/homescreenapp/homescreenapp.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/homescreenapp.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -23,8 +23,11 @@
             stateplugins \
             widgetplugins \
             hsapplication \
-            hscontentpublishplugin \
-            ./../tsrc
+            hsmenucontentpublish
+
+symbian:SUBDIRS  += hshomescreenclientplugin
+
+SUBDIRS  += ./../tsrc
 
 CONFIG += ordered
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/confml/data.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2" name="data">
+  <confml:data>
+    <confml:HomeScreenDbSettings>
+      <confml:landscapeWallpaper/>
+      <confml:portraitWallpaper/>
+      <confml:maximumPageCount>8</confml:maximumPageCount>
+      <confml:defaultPageId map="HomeScreenDbSettings/Pages[@key='1']"/>
+      <confml:Widgets extensionPolicy="replace"><confml:id>1</confml:id><confml:uri>hsclockwidgetplugin</confml:uri><confml:pageId>1</confml:pageId></confml:Widgets>
+      <confml:Widgets><confml:id>2</confml:id><confml:uri>hsdialerwidgetplugin</confml:uri><confml:pageId>1</confml:pageId></confml:Widgets>
+      <confml:Pages extensionPolicy="replace"><confml:id>1</confml:id><confml:indexPosition>0</confml:indexPosition></confml:Pages>
+      <confml:Pages><confml:id>2</confml:id><confml:indexPosition>1</confml:indexPosition></confml:Pages>
+      <confml:Pages><confml:id>3</confml:id><confml:indexPosition>2</confml:indexPosition></confml:Pages>
+      <confml:WidgetPresentations extensionPolicy="append"><confml:key>portrait</confml:key><confml:x>15</confml:x><confml:y>80</confml:y><confml:width>150</confml:width><confml:height>150</confml:height><confml:zValue>0.0</confml:zValue><confml:widgetId map="HomeScreenDbSettings/Widgets[@key='1']"></confml:widgetId></confml:WidgetPresentations>
+      <confml:WidgetPresentations><confml:key>landscape</confml:key><confml:x>15</confml:x><confml:y>80</confml:y><confml:width>150</confml:width><confml:height>150</confml:height><confml:zValue>0.0</confml:zValue><confml:widgetId map="HomeScreenDbSettings/Widgets[@key='1']"></confml:widgetId></confml:WidgetPresentations>
+      <confml:WidgetPresentations><confml:key>portrait</confml:key><confml:x>136</confml:x><confml:y>276</confml:y><confml:width>81</confml:width><confml:height>81</confml:height><confml:zValue>0.0</confml:zValue><confml:widgetId map="HomeScreenDbSettings/Widgets[@key='2']"></confml:widgetId></confml:WidgetPresentations>
+      <confml:WidgetPresentations><confml:key>landscape</confml:key><confml:x>136</confml:x><confml:y>176</confml:y><confml:width>81</confml:width><confml:height>81</confml:height><confml:zValue>0.0</confml:zValue><confml:widgetId map="HomeScreenDbSettings/Widgets[@key='2']"></confml:widgetId></confml:WidgetPresentations>
+      <confml:WidgetPreferences extensionPolicy="replace"><confml:key>clockType</confml:key><confml:value>Analog</confml:value><confml:widgetId>1</confml:widgetId></confml:WidgetPreferences>
+    </confml:HomeScreenDbSettings>
+  </confml:data>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/confml/homescreen_view.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2">
+  <confml:view name="HomeScreen customisation view">
+    <confml:group name="HomeScreen customisation">
+      <confml:desc>HomeScreen specific customisation</confml:desc>
+      <confml:group name="Scene settings">
+        <confml:desc>scene specific settings</confml:desc>
+        <confml:setting ref="HomeScreenDbSettings/portraitWallpaper"/>
+        <confml:setting ref="HomeScreenDbSettings/landscapeWallpaper"/>
+        <confml:setting ref="HomeScreenDbSettings/maximumPageCount"/>
+        <confml:setting ref="HomeScreenDbSettings/defaultPageId"/>        
+      </confml:group>
+      <confml:group name="Pages">
+        <confml:desc>Sample Description</confml:desc>
+        <confml:setting ref="HomeScreenDbSettings/Pages"/>
+      </confml:group>
+      <confml:group name="HomeScreen widgets">
+        <confml:desc>HomeScreen specific widgets</confml:desc>
+        <confml:setting ref="HomeScreenDbSettings/Widgets"/>
+        <confml:setting ref="HomeScreenDbSettings/WidgetPreferences"/>
+        <confml:setting ref="HomeScreenDbSettings/WidgetPresentations"/>
+      </confml:group>
+    </confml:group>
+  </confml:view>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/confml/homescreendb.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2" name="HomeScreen database settings">
+  <confml:feature ref="HomeScreenDbSettings" name="HomeScreen database settings">
+    <confml:setting ref="portraitWallpaper" name="Portrait wallpaper" type="string"/>
+    <confml:setting ref="landscapeWallpaper" name="Landscape wallpaper" type="string"/>
+    <confml:setting ref="maximumPageCount" name="Maximum number of pages" type="int"/>
+    <confml:setting ref="defaultPageId" name="Default page ID" type="selection"> <confml:option map="HomeScreenDbSettings/Pages"/>    
+    </confml:setting>
+    <confml:setting ref="Pages" mapKey="id" mapValue="id" name="Pages" type="sequence">
+      <confml:setting ref="id" name="ID" type="int"/>
+      <confml:setting ref="indexPosition" name="Index Position" type="int"/>
+    </confml:setting>
+    <confml:setting ref="Widgets" mapKey="id" mapValue="id" name="Widgets" type="sequence">
+      <confml:setting ref="id" name="ID" type="int"/>
+      <confml:setting ref="uri" name="URI" type="string"/>
+      <confml:setting ref="pageId" name="Page ID" type="selection">
+        <confml:option map="HomeScreenDbSettings/Pages"/>
+      </confml:setting>
+    </confml:setting>
+    <confml:setting ref="WidgetPresentations" name="Widget presentations" type="sequence">
+      <confml:setting ref="key" name="Key" type="string"/>
+      <confml:setting ref="x" name="X position" type="real"/>
+      <confml:setting ref="y" name="Y position" type="real"/>
+      <confml:setting ref="width" name="Width" type="real"/>
+      <confml:setting ref="height" name="Height" type="real"/>
+      <confml:setting ref="zValue" name="Z value" type="real"/>
+      <confml:setting ref="widgetId" name="Widget ID" type="selection">
+        <confml:option map="HomeScreenDbSettings/Widgets"/>
+      </confml:setting>
+    </confml:setting>
+    <confml:setting ref="WidgetPreferences" name="Widget preferences" type="sequence">
+      <confml:setting ref="key" name="Key" type="string"/>
+      <confml:setting ref="value" name="Value" type="string"/>
+      <confml:setting ref="widgetId" name="Widget ID" type="selection">
+        <confml:option map="HomeScreenDbSettings/Widgets"/>
+      </confml:setting>
+    </confml:setting>
+  </confml:feature>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/implml/homescreendb.implml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<container xmlns="http://www.symbianfoundation.org/xml/implml/1">
+    <tag name="target" value="rofs3"/>
+    
+    <!--
+    Override the setting refs so that modifying HomeScreenDbSettings
+    causes the execution of both the TemplateML and CommandML
+    implementations. Otherwise the TemplateML implementation would be
+    executed only if the settings have been changed, and the CommandML
+    implementation would be executed every time.
+    -->
+    <settingRefsOverride>
+        <settingRef value="HomeScreenDbSettings"/>
+    </settingRefsOverride>
+    
+    <!-- TemplateML implementation to create the .sql files -->
+    <templateml xmlns="http://www.s60.com/xml/templateml/1">
+        <output dir="private/20022f35/sql/" file="create.sql" encoding="UTF-8">
+            <template file="homescreendb_templates/create.sql"></template>
+        </output>
+        <output dir="private/20022f35/sql/" file="fill.sql" encoding="UTF-8">
+            <template file="homescreendb_templates/fill.sql"/>
+        </output>
+    </templateml>
+    
+    <!-- CommandML implementation to create the database using the .sql files -->
+    <commandml xmlns="http://www.s60.com/xml/commandml/1">
+        <command executable="sqlite3" shell="true" cwd="%CONE_OUT_ABSOLUTE%/private/20022f35/sql">
+            <argument value='../homescreen.db ".read create.sql"'/>
+        </command>
+        <command executable="sqlite3" shell="true" cwd="%CONE_OUT_ABSOLUTE%/private/20022f35/sql">
+            <argument value='../homescreen.db ".genfkey --exec"'/>
+        </command>
+        <command executable="sqlite3" shell="true" cwd="%CONE_OUT_ABSOLUTE%/private/20022f35/sql">
+            <argument value='../homescreen.db ".read fill.sql"'/>
+        </command>
+    </commandml>
+</container>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/implml/homescreendb_templates/create.sql	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,38 @@
+DROP TABLE IF EXISTS Scene;
+CREATE TABLE Scene (
+  id INTEGER PRIMARY KEY,
+  portraitWallpaper TEXT,
+  landscapeWallpaper TEXT,
+  defaultPageId INTEGER,
+  maximumPageCount INTEGER);
+
+DROP TABLE IF EXISTS Pages;
+CREATE TABLE Pages (
+  id INTEGER PRIMARY KEY,  
+  indexPosition INTEGER);
+
+DROP TABLE IF EXISTS Widgets;
+CREATE TABLE Widgets (
+  id INTEGER PRIMARY KEY,
+  uri TEXT,  
+  pageId INTEGER);
+
+DROP TABLE IF EXISTS WidgetPresentations;
+CREATE TABLE WidgetPresentations (
+  key TEXT,
+  x REAL,
+  y REAL,
+  width REAL,
+  height REAL,
+  zValue REAL,	
+  widgetId INTEGER,
+  UNIQUE(widgetId, key) ON CONFLICT REPLACE,
+  FOREIGN KEY(widgetId) REFERENCES Widgets(id) ON DELETE CASCADE);
+
+DROP TABLE IF EXISTS WidgetPreferences;
+CREATE TABLE WidgetPreferences (
+  key TEXT,
+  value TEXT,
+  widgetId INTEGER,
+  UNIQUE(widgetId, key) ON CONFLICT REPLACE,
+  FOREIGN KEY(widgetId) REFERENCES Widgets(id) ON DELETE CASCADE);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/implml/homescreendb_templates/fill.sql	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,39 @@
+{%- set portraitWallpaper = feat_tree.HomeScreenDbSettings.portraitWallpaper._value or '' -%}
+{%- set landscapeWallpaper = feat_tree.HomeScreenDbSettings.landscapeWallpaper._value or '' -%}
+{%- set defaultPageId = feat_tree.HomeScreenDbSettings.defaultPageId._value -%}
+{%- set maximumPageCount = feat_tree.HomeScreenDbSettings.maximumPageCount._value -%}
+INSERT INTO Scene (portraitWallpaper, landscapeWallpaper, defaultPageId, maximumPageCount) VALUES ('{{portraitWallpaper}}', '{{landscapeWallpaper}}', {{defaultPageId}}, {{maximumPageCount}});
+
+{% for index in range(feat_tree.HomeScreenDbSettings.Pages._value|length) -%}
+    {%- set id = feat_tree.HomeScreenDbSettings.Pages.id._value[index] -%}
+    {%- set indexPosition = feat_tree.HomeScreenDbSettings.Pages.indexPosition._value[index] -%}
+    INSERT INTO Pages (id, indexPosition) VALUES ({{id}}, {{indexPosition}});
+{% endfor %}
+
+{% for index in range(feat_tree.HomeScreenDbSettings.Widgets._value|length) -%}
+    {%- set id = feat_tree.HomeScreenDbSettings.Widgets.id._value[index] -%}
+    {%- set uri = feat_tree.HomeScreenDbSettings.Widgets.uri._value[index] or '' -%}
+    {%- set pageId = feat_tree.HomeScreenDbSettings.Widgets.pageId._value[index] -%}
+    
+    INSERT INTO Widgets (id, uri, pageId) VALUES ({{id}}, '{{uri}}', {{pageId}});
+{% endfor %}
+
+{% for index in range(feat_tree.HomeScreenDbSettings.WidgetPresentations._value|length) -%}
+    {%- set key = feat_tree.HomeScreenDbSettings.WidgetPresentations.key._value[index] or '' -%}
+    {%- set x = feat_tree.HomeScreenDbSettings.WidgetPresentations.x._value[index] -%}
+    {%- set y = feat_tree.HomeScreenDbSettings.WidgetPresentations.y._value[index] -%}
+    {%- set width = feat_tree.HomeScreenDbSettings.WidgetPresentations.width._value[index] -%}
+    {%- set height = feat_tree.HomeScreenDbSettings.WidgetPresentations.height._value[index] -%}
+    {%- set zValue = feat_tree.HomeScreenDbSettings.WidgetPresentations.zValue._value[index] -%}
+    {%- set widgetId = feat_tree.HomeScreenDbSettings.WidgetPresentations.widgetId._value[index] -%}
+    
+    INSERT INTO WidgetPresentations (key, x, y, width, height, zValue, widgetId) VALUES ('{{key}}', {{x}}, {{y}}, {{width}}, {{height}}, {{zValue}}, {{widgetId}});
+{% endfor %}
+
+{% for index in range(feat_tree.HomeScreenDbSettings.WidgetPreferences._value|length) -%}
+    {%- set key = feat_tree.HomeScreenDbSettings.WidgetPreferences.key._value[index] or '' -%}
+    {%- set value = feat_tree.HomeScreenDbSettings.WidgetPreferences.value._value[index] -%}
+    {%- set widgetId = feat_tree.HomeScreenDbSettings.WidgetPreferences.widgetId._value[index] -%}
+    
+    INSERT INTO WidgetPreferences (key, value, widgetId) VALUES ('{{key}}', '{{value}}', {{widgetId}});
+{% endfor %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/base/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="confml/homescreendb.confml"/>
+  <xi:include href="confml/homescreen_view.confml"/>
+  <xi:include href="confml/data.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/product_1/confml/data.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2" name="data">
+  <confml:data>
+    <confml:HomeScreenDbSettings>
+      <confml:DefaultPageId map="HomeScreenDbSettings/Pages[@key='1']"/>
+      <confml:LandscapeWallpaper></confml:LandscapeWallpaper>
+      <confml:PortraitWallpaper></confml:PortraitWallpaper>
+      <confml:Pages extensionPolicy="replace"><confml:Id>1</confml:Id><confml:PageIndex>0</confml:PageIndex></confml:Pages>
+      <confml:Pages><confml:Id>2</confml:Id><confml:PageIndex>1</confml:PageIndex></confml:Pages>
+      <confml:Pages><confml:Id>3</confml:Id><confml:PageIndex>2</confml:PageIndex></confml:Pages>
+      <confml:Widgets extensionPolicy="replace"><confml:Id>1</confml:Id><confml:Uri>hsclockwidgetplugin</confml:Uri><confml:PageId>1</confml:PageId></confml:Widgets>
+      <confml:Widgets><confml:Id>2</confml:Id><confml:Uri>hsdialerwidgetplugin</confml:Uri><confml:PageId>1</confml:PageId></confml:Widgets>
+      <confml:WidgetPreferences extensionPolicy="replace"><confml:Key>clockType</confml:Key><confml:Value>Analog</confml:Value><confml:WidgetId>1</confml:WidgetId></confml:WidgetPreferences>
+      <confml:WidgetPresentations extensionPolicy="append"><confml:Key>portrait</confml:Key><confml:XPosition>27</confml:XPosition><confml:YPosition>92</confml:YPosition><confml:Width>167.5</confml:Width><confml:Height>167.5</confml:Height><confml:ZValue>0.0</confml:ZValue><confml:WidgetId map="HomeScreenDbSettings/Widgets[@key='1']"></confml:WidgetId></confml:WidgetPresentations>
+      <confml:WidgetPresentations><confml:Key>landscape</confml:Key><confml:XPosition>10</confml:XPosition><confml:YPosition>75</confml:YPosition><confml:Width>150</confml:Width><confml:Height>150</confml:Height><confml:ZValue>0.0</confml:ZValue><confml:WidgetId map="HomeScreenDbSettings/Widgets[@key='1']"></confml:WidgetId></confml:WidgetPresentations>
+      <confml:WidgetPresentations><confml:Key>portrait</confml:Key><confml:XPosition>136</confml:XPosition><confml:YPosition>276</confml:YPosition><confml:Width>81</confml:Width><confml:Height>81</confml:Height><confml:ZValue>0.0</confml:ZValue><confml:WidgetId map="HomeScreenDbSettings/Widgets[@key='2']"></confml:WidgetId></confml:WidgetPresentations>
+      <confml:WidgetPresentations><confml:Key>landscape</confml:Key><confml:XPosition>136</confml:XPosition><confml:YPosition>176</confml:YPosition><confml:Width>81</confml:Width><confml:Height>81</confml:Height><confml:ZValue>0.0</confml:ZValue><confml:WidgetId map="HomeScreenDbSettings/Widgets[@key='2']"></confml:WidgetId></confml:WidgetPresentations>
+    </confml:HomeScreenDbSettings>
+  </confml:data>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/product_1/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="confml/data.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/product_1_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_1/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/product_2/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/product_2_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_2/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_1_of_product_1/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_1_of_product_1_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_1/root.confml"/>
+  <xi:include href="variant_1_of_product_1/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_2_of_product_1/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_2_of_product_1_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_1/root.confml"/>
+  <xi:include href="variant_2_of_product_1/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_3_of_product_1/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_3_of_product_1_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_1/root.confml"/>
+  <xi:include href="variant_3_of_product_1/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_4_of_product_1/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_4_of_product_1_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_1/root.confml"/>
+  <xi:include href="variant_4_of_product_1/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_5_of_product_1/root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/conf/variant_5_of_product_1_root.confml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<confml:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:confml="http://www.s60.com/xml/confml/2" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.s60.com/xml/confml/2 http://www.s60.com/xml/confml/1#//confml2 http://www.w3.org/2001/XInclude http://www.s60.com/xml/confml/1#//include">
+  <xi:include href="base/root.confml"/>
+  <xi:include href="product_1/root.confml"/>
+  <xi:include href="variant_5_of_product_1/root.confml"/>
+</confml:configuration>
\ No newline at end of file
--- a/homescreenapp/hsapplication/hsapplication.pri	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/hsapplication.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -14,5 +14,10 @@
 # Description:
 #
 
-HEADERS += ./inc/*.h
-SOURCES += ./src/*.cpp
+HEADERS += ./inc/hshomescreen.h
+SOURCES += ./src/hshomescreen.cpp \
+           ./src/main.cpp
+symbian:{
+    HEADERS += ./inc/hshomescreenclientserviceprovider.h
+    SOURCES += ./src/hshomescreenclientserviceprovider.cpp 
+}
--- a/homescreenapp/hsapplication/hsapplication.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/hsapplication.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -18,7 +18,7 @@
 
 include(../common.pri)
 
-LIBS += -lhsutils
+LIBS += -lhsutils -lhsdomainmodel
 CONFIG += console
 
 QT += xml
@@ -34,7 +34,8 @@
 
 INCLUDEPATH += . \
                ./inc \
-                ../hsutils/inc
+                ../hsutils/inc \
+                ../hsdomainmodel/inc
 
 TRANSLATIONS = homescreen.ts
 
@@ -49,6 +50,11 @@
     appkey:DEFINES += S60APP_KEY
     LIBS += -lefsrv
     include(installs_symbian.pri)
+
+    CONFIG += service
+    LIBS +=  -lxqservice -lxqserviceutil 
+           
+    SERVICE.FILE = ipc_service_conf.xml
 }
 
 win32: {
--- a/homescreenapp/hsapplication/inc/hshomescreen.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/inc/hshomescreen.h	Fri Apr 16 14:54:01 2010 +0300
@@ -20,11 +20,20 @@
 
 #include <QObject>
 #include "hstest_global.h"
+#ifdef Q_OS_SYMBIAN
+#include "hshomescreenclientserviceprovider.h"
+#endif
 
 HOMESCREEN_TEST_CLASS(t_hsapplication)
 
 class QStateMachine;
 
+namespace QtMobility {
+    class QServiceManager;
+}
+using QtMobility::QServiceManager;
+
+
 class HsHomeScreen : public QObject
 {
     Q_OBJECT
@@ -44,8 +53,8 @@
     bool eventFilter(QObject *watched, QEvent *event);
 
 private:
-    void registerServicePlugins();
-    void registerServicePlugins(const QString &root);
+    void registerServicePlugins(QServiceManager &serviceManager);
+    void registerServicePlugins(const QString &root, QServiceManager &serviceManager);
 
 private slots:
     void onRuntimeStarted();
@@ -56,7 +65,10 @@
 
 private:
     QStateMachine *mRuntime;
-
+#ifdef Q_OS_SYMBIAN
+    //Service provider for QtHighway 
+    HsHomeScreenClientServiceProvider *mHomeScreenClientServiceProvider;
+#endif
     HOMESCREEN_TEST_FRIEND_CLASS(t_hsapplication)
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/inc/hshomescreenclientserviceprovider.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HSHOMESCREENCLIENTSERVICEPROVIDER_H
+#define HSHOMESCREENCLIENTSERVICEPROVIDER_H
+
+#include <xqserviceprovider.h>
+#include <QVariant>
+
+class HsHomeScreenClientServiceProvider : public XQServiceProvider
+{
+    Q_OBJECT
+public:
+    HsHomeScreenClientServiceProvider( QObject *parent = 0 );
+    ~HsHomeScreenClientServiceProvider();
+
+    
+public slots:
+    bool addWidget(const QString &uri,const QVariantHash &preferences);
+    
+private:
+    
+};
+
+#endif
--- a/homescreenapp/hsapplication/installs_symbian.pri	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/installs_symbian.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -17,7 +17,7 @@
 deploy.path = z:
 
 exports1.path = /private/20022F35
-exports1.sources += resource_s60/homescreendb
+exports1.sources += resource_s60/homescreen.db
 for(export1, exports1.sources):BLD_INF_RULES.prj_exports += "./$$export1 $$deploy.path$$exports1.path/$$basename(export1)"
 
 exports2.path = /private/20022f35/wallpapers
--- a/homescreenapp/hsapplication/installs_win.pri	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/installs_win.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -22,7 +22,7 @@
 
 homescreendb.CONFIG += no_build
 homescreendb.path = $$DESTDIR
-homescreendb.files = ./resource_win/homescreendb
+homescreendb.files = ./resource_win/homescreen.db
 
 wallpapers.CONFIG += no_build
 wallpapers.path = $$DESTDIR/wallpapers
@@ -46,4 +46,4 @@
                                  ./themes/theme2/hs_trashbin_nonactive.svg
 
 INSTALLS += kqtihswallpapers homescreendb wallpapers themeableimagesfortheme11 themeableimagesfortheme12 themeableimagesfortheme2
-PRE_TARGETDEPS += install_kqtihswallpapers install_homescreendb install_wallpapers
\ No newline at end of file
+PRE_TARGETDEPS += install_kqtihswallpapers install_homescreendb install_wallpapers
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/ipc_service_conf.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<service name="com.nokia.services.hsapplication"  filepath="must-not-be-empty" >
+  <description>Homescreen client service provider</description>
+  <interface name="IHomeScreenClient" version="1.0" capabilities="">
+    <description>Homescreen client service interface</description>
+  </interface>
+</service>
\ No newline at end of file
Binary file homescreenapp/hsapplication/loc/Homescreen_v0 5.xls has changed
Binary file homescreenapp/hsapplication/resource_s60/homescreen.db has changed
Binary file homescreenapp/hsapplication/resource_s60/homescreendb has changed
Binary file homescreenapp/hsapplication/resource_win/homescreen.db has changed
Binary file homescreenapp/hsapplication/resource_win/homescreendb has changed
--- a/homescreenapp/hsapplication/src/hshomescreen.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/src/hshomescreen.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -26,7 +26,9 @@
 
 #include "hshomescreen.h"
 #include "hstest_global.h"
-
+#ifdef Q_OS_SYMBIAN
+#include "hshomescreenclientserviceprovider.h"
+#endif
 QTM_USE_NAMESPACE
 
 /*!
@@ -44,24 +46,41 @@
 HsHomeScreen::HsHomeScreen(QObject *parent)
   : QObject(parent),
     mRuntime(0)
+#ifdef Q_OS_SYMBIAN
+    ,mHomeScreenClientServiceProvider(0)
+#endif
 {
     HSTEST_FUNC_ENTRY("HS::HsHomeScreen::HsHomeScreen");
 
-    registerServicePlugins();
+    QServiceManager serviceManager;
+
+    registerServicePlugins(serviceManager);
+    
+    QServiceFilter filter("com.nokia.symbian.IHomeScreenRuntime");
+    QList<QServiceInterfaceDescriptor> interfaces = serviceManager.findInterfaces(filter);
 
-    QServiceManager manager;
-    QServiceFilter filter("com.nokia.homescreen.runtime.HsRuntime");
-    QList<QServiceInterfaceDescriptor> interfaces = manager.findInterfaces(filter);
-    QObject *interface = manager.loadInterface(interfaces.first().interfaceName());
-    mRuntime = qobject_cast<QStateMachine*>(interface);
+    if (interfaces.isEmpty()) {
+        emit exit();
+        return;
+    }
+
+    QObject *object = serviceManager.loadInterface(interfaces.first().interfaceName());
+    mRuntime = qobject_cast<QStateMachine *>(object);
+
     if (mRuntime) {
         mRuntime->setParent(this);
         connect(mRuntime, SIGNAL(started()), SLOT(onRuntimeStarted()));
         connect(mRuntime, SIGNAL(stopped()), SLOT(onRuntimeStopped()));
-        hbInstance->allMainWindows().at(0)->installEventFilter(this);
+        hbInstance->allMainWindows().first()->installEventFilter(this);
+#ifdef Q_OS_SYMBIAN
+        mHomeScreenClientServiceProvider = new HsHomeScreenClientServiceProvider;
+        mHomeScreenClientServiceProvider->setParent(this);
+#endif
     } else {
+        delete object;
         emit exit();
     }
+
     HSTEST_FUNC_EXIT("HS::HsHomeScreen::HsHomeScreen");
 }
 
@@ -98,8 +117,11 @@
 void HsHomeScreen::stop()
 {
 	if (mRuntime && mRuntime->isRunning()) {
-		QMetaObject::invokeMethod(mRuntime, "event_exit");
-	}
+        QEventLoop eventLoop;
+        connect(mRuntime, SIGNAL(finished()), &eventLoop, SLOT(quit()));
+        QMetaObject::invokeMethod(mRuntime, "event_exit", Qt::QueuedConnection);
+        eventLoop.exec();
+    }
 }
 
 /*!
@@ -132,7 +154,7 @@
 /*!
     Registers service plugins pre-installed on the device.
 */
-void HsHomeScreen::registerServicePlugins()
+void HsHomeScreen::registerServicePlugins(QServiceManager &serviceManager)
 {
     HSTEST_FUNC_ENTRY("HS::HsHomeScreen::registerServicePlugins()");
     QStringList pluginPaths;
@@ -152,13 +174,13 @@
             QString driveLetter = drive.absolutePath();
             QString path = driveLetter + pluginPath;
             if(QDir(path).exists()) {
-                registerServicePlugins(path);
+                registerServicePlugins(path, serviceManager);
             }
         }
 #endif
         //Check plugin path relative to current dir
         if(QDir(pluginPath).exists()) {
-            registerServicePlugins(pluginPath);
+            registerServicePlugins(pluginPath, serviceManager);
         }
     }
     HSTEST_FUNC_EXIT("HS::HsHomeScreen::registerServicePlugins()");
@@ -169,14 +191,14 @@
     directory. All directories containing plugins are added to
     application's library paths at the same time.
 */
-void HsHomeScreen::registerServicePlugins(const QString &root)
+void HsHomeScreen::registerServicePlugins(const QString &root, QServiceManager &serviceManager)
 {
     HSTEST_FUNC_ENTRY("HS::HsHomeScreen::registerServicePlugins(const QString &)");
-    QDir dir = QDir(root);
+    QDir dir(root);
     QFileInfoList fileInfos = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
 
     foreach (QFileInfo fileInfo, fileInfos) {
-        registerServicePlugins(fileInfo.absoluteFilePath());
+        registerServicePlugins(fileInfo.absoluteFilePath(), serviceManager);
     }
 
     fileInfos = dir.entryInfoList(QStringList("*.xml"));
@@ -185,11 +207,13 @@
         //Plugin dll and xml are in the same directory
         QApplication::addLibraryPath(root);
         qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Directory added to application's library paths: ")
-                 << root;
-        QServiceManager manager;
+                 << root;        
         foreach(QFileInfo fileInfo, fileInfos) {
-            manager.addService(fileInfo.absoluteFilePath());
-            qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Plugin registered: ") + fileInfo.fileName();
+            if (serviceManager.addService(fileInfo.absoluteFilePath())) {
+                qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Plugin registered: ") + fileInfo.fileName();
+            } else {
+                qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Plugin FAILED to register: ") + fileInfo.fileName();
+            }
         }
     }
     HSTEST_FUNC_EXIT("HS::HsHomeScreen::registerServicePlugins(const QString &)");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsapplication/src/hshomescreenclientserviceprovider.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main class for HsHomeScreenClientServiceProvider library.
+*
+*/
+
+#include "hshomescreenclientserviceprovider.h"
+
+#include "hsscene.h"
+#include "hspage.h"
+#include "hsdomainmodeldatastructures.h"
+#include "hswidgethost.h"
+
+const char INTERFACE_NAME[] = "com.nokia.services.hsapplication.IHomeScreenClient";
+
+HsHomeScreenClientServiceProvider::HsHomeScreenClientServiceProvider(QObject* parent)
+: XQServiceProvider(INTERFACE_NAME,parent)
+{
+    publishAll();
+}
+
+HsHomeScreenClientServiceProvider::~HsHomeScreenClientServiceProvider()
+{
+}
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+
+// this should be moved to HsContentService class 
+
+bool HsHomeScreenClientServiceProvider::addWidget(const QString &uri,const QVariantHash &preferences)
+{
+
+    HsWidgetData widgetData;
+    widgetData.uri = uri;
+
+    QScopedPointer<HsWidgetHost> widget(HsWidgetHost::createInstance(widgetData,preferences));
+
+    if (!widget.data()) {
+        return false;
+    }
+    HsPage* activePage = HsScene::instance()->activePage();
+    if (!widget->load() || !activePage->addNewWidget(widget.data())) {
+        widget->deleteFromDatabase();
+        return false;
+    }
+    HsWidgetHost* taken = widget.take();
+    taken->initializeWidget();
+    taken->showWidget();
+    activePage->layoutNewWidgets();
+
+    return true;
+}
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
+
--- a/homescreenapp/hsapplication/src/main.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsapplication/src/main.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -14,6 +14,7 @@
 * Description:  Main.
 *
 */
+
 #include <QTranslator>
 #include <QMessageBox>
 #include <hbapplication.h>
@@ -36,6 +37,12 @@
 #include <e32debug.h>
 #include <apgwgnam.h>
 
+
+void loadTranslationFilesOnSymbian(QTranslator &hsTranslator, QTranslator &alTranslator);
+void copyWallpapersFromRom();
+void copyHsDatabaseFileFromRom();
+void createPrivateFolder();
+
 // it is temporary class used for getting notifcation about APA messages
 // it is used for processing message send by AVKON to activate Menu
 class HsMessageObserver: public MCoeMessageObserver {
@@ -54,14 +61,12 @@
 {
     CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(eikonEnv->WsSession());
     wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down
-    wgName->SetCaptionL(_L("HsApplication"));
+    wgName->SetCaptionL(_L("hsapplication"));
     wgName->SetAppUid(TUid::Uid(0x20022F35));
     wgName->SetWindowGroupName(eikonEnv->RootWin());
     CleanupStack::PopAndDestroy();
 }
 
-
-
 void myMessageOutput(QtMsgType type, const char *msg)
 {
     switch (type) {
@@ -86,12 +91,9 @@
 
 #endif //Q_OS_SYMBIAN
 
-
-
+/*!
 
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
+*/
 int main(int argc, char *argv[])
 {
 #ifdef Q_OS_SYMBIAN
@@ -111,107 +113,31 @@
 
     HsAppTranslator *appTranslator = HsAppTranslator::instance();
     appTranslator->setLanguage();
-
+    
     // add translator for homescreen and application library
-    QString locale = QLocale::system().name();
-
     QTranslator hsTranslator;
-    QString hsTrFile = QString("homescreen_") + locale;
-
     QTranslator alTranslator;
-    QString alTrFile = QString("hsapplibrary_") + locale;
 #ifdef Q_OS_SYMBIAN
     // TRAP is must here, otherwise it crashes
-TRAP_IGNORE(
-    bool hsLoaded(false);
-    hsLoaded = hsTranslator.load(hsTrFile, QString("z:/") + TR_FILE_PATH);
-    if (!hsLoaded)
-        hsTranslator.load(hsTrFile, QString("c:/") + TR_FILE_PATH);
-
-    bool alLoaded(false);
-    alLoaded = alTranslator.load(alTrFile, QString("z:/") + TR_FILE_PATH);
-    if (!alLoaded)
-        alTranslator.load(alTrFile, QString("c:/") + TR_FILE_PATH);
-);
+    TRAP_IGNORE( loadTranslationFilesOnSymbian(hsTranslator, alTranslator) );
 #else
+    QString locale = QLocale::system().name();
+    QString hsTrFile = QString("homescreen_") + locale;
     hsTranslator.load(hsTrFile, QString(TR_FILE_PATH) );
+    QString alTrFile = QString("hsapplibrary_") + locale;
     alTranslator.load(alTrFile, QString(TR_FILE_PATH) );
 #endif //Q_OS_SYMBIAN
-    app.installTranslator(&hsTranslator);
-    app.installTranslator(&alTranslator);
-
+    qApp->installTranslator(&hsTranslator);
+    qApp->installTranslator(&alTranslator);
+    
 #ifdef Q_OS_SYMBIAN
-    QFile file("c:/private/20022f35/homescreendb");
-    //If DB file does not exist copy default DB from z: (ROM)
-    if(!file.exists()) {
-        HSTEST("HS::main() - homescreendb not in c:");
-        file.setFileName("z:/private/20022f35/homescreendb");
-        if(!file.exists()) {
-            HSTEST("HS::main() - homescreendb not in ROM!");
-        }
-        else {
-            HSTEST("HS::main() - homescreendb found from z:");
-            //We need to first create private folder if not exists
-            QDir dir("c:/private/20022f35/");
-            if(!dir.exists()) {
-                HSTEST("HS::main() - c:/private/20022f35/ does not exist.");
-                RFs fsSession;
-                if(fsSession.Connect() != KErrNone){
-                    HSTEST("HS::main() - Homescreen private dir creation failed!");
-                }
-                fsSession.CreatePrivatePath(EDriveC);
-                HSTEST("HS::main() - c:/private/20022f35/ created.");
-                fsSession.Close();
-                if(!dir.exists()) {
-                    HSTEST("HS::main() - c:/private/20022f35/ creation failed.");
-                }
-            }
-            HSTEST("HS::main() - c:/private/20022f35/ exists.");
-            //Copy DB from z: to c:
-            if (!file.copy("c:/private/20022f35/homescreendb")) {
-                HSTEST("HS::main() - homescreendb copy from ROM to c: failed!");
-            }
-            HSTEST("HS::main() - homescreendb copied from ROM to c:!");
-            file.setFileName("c:/private/20022f35/homescreendb");
-            if(!file.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
-                HSTEST("HS::main() - homescreendb ReadWrite permission settings on c: failed!");
-            }
-            HSTEST("HS::main() - homescreendb permission set to ReadWrite!");
-        }
-    }
-#ifdef __WINS__
-    else if(!file.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
-        HSTEST("HS::main() - homescreendb ReadWrite permission settings on emulator's c: failed!");
-    }
+    copyHsDatabaseFileFromRom();
+    copyWallpapersFromRom();
 #endif
-    {
-    QDir dir("c:/private/20022f35/wallpapers");
-    if(!dir.exists()) {
-        dir.mkpath("c:/private/20022f35/wallpapers/");
-        QDir dir2("z:/private/20022f35/wallpapers");
-        dir2.setFilter(QDir::Files);
-        QStringList files = dir2.entryList();
-        foreach(QString file, files)
-        {
-            QString targetFile("c:/private/20022f35/wallpapers/" + file);
-            QFile::copy(dir2.absoluteFilePath(file), targetFile);
-            qDebug() << "image copied" << dir2.absoluteFilePath(file);
-            QFile createdFile(targetFile);
-            if(!createdFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
-                qDebug() << "read write permission set failed for file" << targetFile;
-            }
-        }
-
-    }
-
-
-    }
-
-#endif //Q_OS_SYMBIAN
-
+    
     HbMainWindow window;
-    window.setViewSwitchingEnabled(false);
-    
+    window.setRenderHint(QPainter::SmoothPixmapTransform);
+        
     HsHomeScreen hs;
     QObject::connect(&app, SIGNAL(aboutToQuit()) ,&hs, SLOT(stop()));
     QObject::connect(&hs, SIGNAL(exit()), &app, SLOT(quit()),Qt::QueuedConnection);
@@ -232,11 +158,116 @@
     HSTEST("HS::main() call app.exec");
     try {
         app.exec();
-
     } catch(...) {
         HSTEST("HS::main() app.exec() catch");
     }
     return 0;
 }
 
+#ifdef Q_OS_SYMBIAN
 
+/*!
+ * Creates private folder to c: drive if not exists yet.
+ */
+void createPrivateFolder()
+{
+    QDir dir("c:/private/20022f35/");
+    if(!dir.exists()) {
+        HSTEST("HS::main() - c:/private/20022f35/ does not exist.");
+        RFs fsSession;
+        if(fsSession.Connect() != KErrNone){
+            HSTEST("HS::main() - Homescreen private dir creation failed!");
+        }
+        fsSession.CreatePrivatePath(EDriveC);
+        HSTEST("HS::main() - c:/private/20022f35/ created.");
+        fsSession.Close();
+        if(!dir.exists()) {
+            HSTEST("HS::main() - c:/private/20022f35/ creation failed.");
+        }
+    }
+    HSTEST("HS::main() - c:/private/20022f35/ exists.");
+}
+
+/*!
+ * Copies homescreen database from rom if database does not exist on c: drive
+ */
+void copyHsDatabaseFileFromRom()
+{
+    QFile file("c:/private/20022f35/homescreen.db");
+    //If DB file does not exist copy default DB from z: (ROM)
+    if(!file.exists()) {
+        HSTEST("HS::main() - homescreen.db not in c:");
+        file.setFileName("z:/private/20022f35/homescreen.db");
+        if(!file.exists()) {
+            HSTEST("HS::main() - homescreen.db not in ROM!");
+        } else {
+            HSTEST("HS::main() - homescreen.db found from z:");
+            createPrivateFolder();
+            //Copy DB from z: to c:
+            if (!file.copy("c:/private/20022f35/homescreen.db")) {
+                HSTEST("HS::main() - homescreen.db copy from ROM to c: failed!");
+            }
+            HSTEST("HS::main() - homescreen.db copied from ROM to c:!");
+            file.setFileName("c:/private/20022f35/homescreen.db");
+            if(!file.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
+                HSTEST("HS::main() - homescreen.db ReadWrite permission settings on c: failed!");
+            }
+            HSTEST("HS::main() - homescreen.db permission set to ReadWrite!");
+        }
+    }
+#ifdef __WINS__
+    else if(!file.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
+        HSTEST("HS::main() - homescreen.db ReadWrite permission settings on emulator's c: failed!");
+    }
+#endif
+    
+}
+
+/*!
+ * Copies homescreen wallpapers from rom if wallpaper directory does not exist on c: drive
+ */
+void copyWallpapersFromRom()
+{
+    QDir dir("c:/private/20022f35/wallpapers");
+    if(!dir.exists()) {
+        dir.mkpath("c:/private/20022f35/wallpapers/");
+        QDir dir2("z:/private/20022f35/wallpapers");
+        dir2.setFilter(QDir::Files);
+        QStringList files = dir2.entryList();
+        foreach(QString file, files)
+        {
+            QString targetFile("c:/private/20022f35/wallpapers/" + file);
+            if ( QFile::copy(dir2.absoluteFilePath(file), targetFile) ) {
+                qDebug() << "image copied" << dir2.absoluteFilePath(file);
+            } 
+            QFile createdFile(targetFile);
+            if(!createdFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
+                qDebug() << "read write permission set failed for file" << targetFile;
+            }
+        }
+    }
+}
+
+/*!
+ * Load translation files.
+ */
+void loadTranslationFilesOnSymbian(QTranslator &hsTranslator, QTranslator &alTranslator)
+{
+    bool hsLoaded(false);
+    QString locale = QLocale::system().name();
+    QString hsTrFile = QString("homescreen_") + locale;
+    hsLoaded = hsTranslator.load(hsTrFile, QString("z:/") + TR_FILE_PATH);
+    if (!hsLoaded) {
+        hsTranslator.load(hsTrFile, QString("c:/") + TR_FILE_PATH);
+    }
+
+    bool alLoaded(false);
+    QString alTrFile = QString("hsapplibrary_") + locale;
+    alLoaded = alTranslator.load(alTrFile, QString("z:/") + TR_FILE_PATH);
+    if (!alLoaded) {
+        alTranslator.load(alTrFile, QString("c:/") + TR_FILE_PATH);
+    }
+    
+}
+
+#endif
--- a/homescreenapp/hscontentpublishplugin/hscontentpublishplugin.pri	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description:
-#
-
-
-HEADERS += ./inc/hscontentpublishplugin.h
-SOURCES += ./src/hscontentpublishplugin.cpp
-
-
-win32:{
-    HEADERS += ./inc_win/hshomescreenclient.h
-    SOURCES += ./src/hshomescreenclient_win.cpp
-    
-}
-
-symbian:{
-    HEADERS += ./inc_symbian/hshomescreenclient.h
-    SOURCES += ./src/hshomescreenclient_symbian.cpp
-
-}
-
-
--- a/homescreenapp/hscontentpublishplugin/hscontentpublishplugin.pro	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description:
-#
-
-TEMPLATE = lib
-CONFIG += plugin hb mobility console
-MOBILITY = serviceframework
-
-PLUGIN_SUBDIR = /hsresources/plugins/contentpublish
-
-include (../common.pri)
-
-win32:{
-LIBS += -lhsdomainmodel \
-        -lhsutils
-}
-QT += xml sql network
-
-DEPENDPATH += ./inc \
-              ./inc_win \
-              ./inc_symbian \
-              ./src
-INCLUDEPATH += ./inc \
-               ./inc_win \
-              ./inc_symbian \
-             ../hsutils/inc \
-             ../hsdomainmodel/inc \
-
-symbian: {
-    TARGET.UID3 = 0x20022F72
-    LIBS += -lxqservice
-}
-
-
-include(hscontentpublishplugin.pri)
--- a/homescreenapp/hscontentpublishplugin/inc/hscontentpublishplugin.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Default runtime provider.
-*
-*/
-
-#ifndef HSCONTENTPUBLISHPLUGIN_H
-#define HSCONTENTPUBLISHPLUGIN_H
-
-#include <QObject>
-#include <qserviceplugininterface.h>
-
-QTM_USE_NAMESPACE
-
-class HsContentPublishPlugin : public QObject, public QServicePluginInterface
-{
-    Q_OBJECT
-    Q_INTERFACES(QtMobility::QServicePluginInterface)
-
-public:
-    QObject *createInstance(const QServiceInterfaceDescriptor &descriptor,
-                            QServiceContext *context,
-                            QAbstractSecuritySession *session);
-};
-
-#endif //HSCONTENTPUBLISHPLUGIN_H
--- a/homescreenapp/hscontentpublishplugin/inc_symbian/hshomescreenclient.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Default implementation of the home screen runtime.
-*
-*/
-
-#ifndef HSCONTENTPUBLISH_H
-#define HSCONTENTPUBLISH_H
-
-#include <QObject>
-#include <QVariant>
-
-
-class XQServiceRequest;
-
-class HsContentPublish : public QObject
-{
-    Q_OBJECT
-
-public:
-    HsContentPublish(QObject *parent = 0);
-    virtual ~HsContentPublish();
-    Q_INVOKABLE bool open();
-    Q_INVOKABLE bool close();
-public slots:
-    bool addWidgetToHomescreen(const QString &uri, const QVariantMap &preferences = QVariantMap());
-
-private:
-    XQServiceRequest* sndAsync;
-};
-
-#endif
--- a/homescreenapp/hscontentpublishplugin/inc_win/hshomescreenclient.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Default implementation of the home screen runtime.
-*
-*/
-
-#ifndef HSCONTENTPUBLISH_H
-#define HSCONTENTPUBLISH_H
-
-#include <QObject>
-#include <QVariant>
-
-class HsIpcChannelClient;
-
-class HsContentPublish : public QObject
-{
-    Q_OBJECT
-
-public:
-    HsContentPublish(QObject *parent = 0);
-    virtual ~HsContentPublish();
-    Q_INVOKABLE bool open();
-    Q_INVOKABLE bool close();
-public slots:
-    bool addWidgetToHomescreen(const QString &uri, const QVariantMap &preferences = QVariantMap());
-
-private:
-    HsIpcChannelClient *mChannel;
-};
-
-#endif
--- a/homescreenapp/hscontentpublishplugin/resource/hscontentpublishplugin.s60xml	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<service>
-    <name>hscontentpublishplugin</name>
-    <filepath>z:/hsresources/plugins/contentpublish/hscontentpublishplugin.qtplugin</filepath>
-    <description>Homescreen Content Publish Plugin</description>
-    <interface>
-        <name>com.nokia.homescreen.contentpublish</name>
-        <version>1.0</version>
-        <description>Content publish api for client processes </description>
-        <capabilities></capabilities>
-    </interface>
-</service>
--- a/homescreenapp/hscontentpublishplugin/resource/hscontentpublishplugin.xml	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<service>
-    <name>hscontentpublishplugin</name>
-    <filepath>hscontentpublishplugin</filepath>
-    <description>Homescreen Content Publish Plugin</description>
-    <interface>
-        <name>com.nokia.homescreen.contentpublish</name>
-        <version>1.0</version>
-        <description>Content publish api for client processes </description>
-        <capabilities></capabilities>
-    </interface>
-</service>
\ No newline at end of file
--- a/homescreenapp/hscontentpublishplugin/src/hscontentpublishplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Default runtime plugin.
-*
-*/
-
-#include <qserviceinterfacedescriptor.h>
-#include <qabstractsecuritysession.h>
-#include <qservicecontext.h>
-
-#include "hscontentpublishplugin.h"
-#include "hshomescreenclient.h"
-
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT
-
-QObject *HsContentPublishPlugin::createInstance(const QServiceInterfaceDescriptor &descriptor,
-                                                QServiceContext *context,
-                                                QAbstractSecuritySession *session)
-{
-    Q_UNUSED(context);
-    Q_UNUSED(session);
-
-    if (descriptor.interfaceName() == QLatin1String("com.nokia.homescreen.contentpublish")) {
-        return new HsContentPublish(this);
-    } else {
-        return 0;
-    }
-}
-
-Q_EXPORT_PLUGIN2(hscontentpublishplugin, HsContentPublishPlugin)
-
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
--- a/homescreenapp/hscontentpublishplugin/src/hshomescreenclient_symbian.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Content publishing implementation
-*
-*/
-#include "hshomescreenclient.h"
-#include <xqservicerequest.h>
-
-
-
-HsContentPublish::HsContentPublish(QObject *parent)
-    :QObject(parent)
-{
- 
-}
-HsContentPublish::~HsContentPublish()
-{
-
-}
-
-bool HsContentPublish::open()
-{
-  
-    return true;
-}
-
-bool HsContentPublish::close()
-{
-  
-    return true;
-}
-
-bool HsContentPublish::addWidgetToHomescreen(
-    const QString &uri, 
-    const QVariantMap &preferences)
-{
-    XQServiceRequest snd("com.nokia.services.hshomescreenclient",
-                        "bool addWidget(QString, QVariantMap)");
-    snd << uri;
-    snd << preferences;
-    QVariant retValue;
-    bool res=snd.send(retValue);
-    if (!res) {
-        int returnvalue = snd.latestError();
-    }
-    return res;
-}
-
-
--- a/homescreenapp/hscontentpublishplugin/src/hshomescreenclient_win.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Content publishing implementation
-*
-*/
-#include <QDebug>
-#include "hshomescreenclient.h"
-#include "hsipcchannelclient.h"
-
-const char SERVERNAME[] = "hs_content_publish";
-
-HsContentPublish::HsContentPublish(QObject *parent)
-    :QObject(parent),mChannel(new HsIpcChannelClient())
-{
-    mChannel->setParent(this);
- 
-}
-HsContentPublish::~HsContentPublish()
-{
-
-}
-
-bool HsContentPublish::open()
-{
-    if(!mChannel->isConnected() && !mChannel->waitForOpenConnection(SERVERNAME)){
-        return false;
-    }
-    return true;
-}
-
-bool HsContentPublish::close()
-{
-    if( mChannel->isConnected() && !mChannel->waitForCloseConnection()){
-        qDebug()<< "HsContentPublish connection failed";
-        return false;
-    }
-    return true;
-}
-
-bool HsContentPublish::addWidgetToHomescreen(
-    const QString &uri, 
-    const QVariantMap &preferences)
-{
-    if(!open()){
-        return false;
-    }
-    // format message
-    QVariantMap message;
-    message.insert("messageType",QString("addWidget"));
-    message.insert("uri",uri);
-    message.insert("preferences",preferences);
-    if(!mChannel->waitForSendMessage(message)){
-        qDebug()<< "HsContentPublish sendMessageWait failed";
-        return false;
-    }
-    // get reply
-    QVariantMap reply;
-    if(!mChannel->waitForReadMessage(reply)){
-        qDebug()<< "HsContentPublish reply wait failed";
-        return false;
-    }
-    QString replyResult = reply.value("result").toString();
-    if( replyResult != QLatin1String("true")){
-        qDebug()<< "HsContentPublish reply result: " << replyResult;
-        return false;
-    }
-   
-    return true;
-}
-
--- a/homescreenapp/hsdomainmodel/hsdomainmodel.pri	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/hsdomainmodel.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -13,48 +13,24 @@
 #
 # Description:
 #
-HEADERS +=  ./inc/hscontentservice.h \
-                       ./inc/hsdatabase.h  \ 
-                       ./inc/hsdomainmodel_global.h  \
-                       ./inc/hspage.h \  
-                        ./inc/hspagedata.h \  
-                        ./inc/hsscene.h \
-                        ./inc/hsscene_p.h \ 
-                        ./inc/hsscenedata.h \
-                        ./inc/hsshortcutservice.h \
-                         ./inc/hsshortcutservice_p.h \
-                         ./inc/hswallpaper.h \
-                        ./inc/hswallpaper_p.h \
-                        ./inc/hswidgetdata.h \                      
-                          ./inc/hswidgethost.h \  
-                           ./inc/hswidgetpresentationdata.h 
+
+HEADERS += ./inc/hscontentservice.h \
+           ./inc/hsdomainmodeldatastructures.h \
+           ./inc/hsdatabase.h  \                        
+           ./inc/hsdomainmodel_global.h  \
+           ./inc/hspage.h \  
+           ./inc/hsscene.h \
+           ./inc/hsshortcutservice.h \
+           ./inc/hsshortcutservice_p.h \
+           ./inc/hswallpaper.h \
+           ./inc/hswidgethost.h
                                
-SOURCES += ./src/hscontentservice.cpp   \
-                        ./src/hsdatabase.cpp  \
-                        ./src/hspage.cpp  \
-                        ./src/hspagedata.cpp  \
-                        ./src/hsscene.cpp \
-                        ./src/hsscenedata.cpp \
-                        ./src/hsshortcutservice.cpp \   
-                       ./src/hswallpaper.cpp \ 
-                       ./src/hswidgetdata.cpp \       
-                       ./src/hswidgethost.cpp \       
-                       ./src/hswidgetpresentationdata.cpp 
+SOURCES += ./src/hscontentservice.cpp   \           
+           ./src/hsdatabase.cpp  \                        
+           ./src/hspage.cpp  \
+           ./src/hsscene.cpp \                        
+           ./src/hsshortcutservice.cpp \   
+           ./src/hswallpaper.cpp \ 
+           ./src/hswidgethost.cpp
                               
-win32:{
-HEADERS +=  ./inc/hscontentpublishhandler.h \
-                        ./inc/hsipcchannel.h \
-                        ./inc/hsipcchannelclient.h \
-                        ./inc/hsipcchannelhost.h \
-                        ./inc/hsipcconnectiondispatcher.h \   
-                        ./inc/hsipcserver.h     
-                      
-SOURCES +=  ./src/hscontentpublishhandler.cpp \
-                        ./src/hsipcchannel.cpp \
-                        ./src/hsipcchannelclient.cpp \
-                        ./src/hsipcchannelhost.cpp \
-                        ./src/hsipcconnectiondispatcher.cpp \   
-                        ./src/hsipcserver.cpp 
 
-}
-
--- a/homescreenapp/hsdomainmodel/inc/hscontentpublishhandler.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#ifndef HSCONTENTPUBLISHHANDLER_H
-#define HSCONTENTPUBLISHHANDLER_H
-
-#include <QObject>
-#include <QVariant>
-#include "hsdomainmodel_global.h"
-
-class HsIpcChannelHost;
-class HSDOMAINMODEL_EXPORT HsContentPublishHandler : public QObject
-{
-    Q_OBJECT
-
-public:
-    HsContentPublishHandler(HsIpcChannelHost *channel,QObject *parent=0);
-    ~HsContentPublishHandler();
-public slots:
-     void onMessageReceived(const QVariantMap &message);
-signals:
-     void finished();
-private:
-    bool addWidget(const QString &uri, const QVariantMap &preferences);
-private:
-    HsIpcChannelHost* mChannel;
-};
-
-#endif // HSCONTENTPUBLISHHANDLER_H
--- a/homescreenapp/hsdomainmodel/inc/hscontentservice.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/inc/hscontentservice.h	Fri Apr 16 14:54:01 2010 +0300
@@ -20,13 +20,12 @@
 
 #include <QObject>
 #include <QMetaType>
+#include <QVariant>
 
 #include "hsdomainmodel_global.h"
-#include <QVariant>
 
 class HsWidgetHost;
 
-
 class HSDOMAINMODEL_EXPORT HsContentService : public QObject
 {
     Q_OBJECT
@@ -35,8 +34,8 @@
     HsContentService(QObject *parent = 0);
     ~HsContentService();
 
-    bool createWidget(const QVariantMap &params);
-    HsWidgetHost *createWidgetForPreview(const QVariantMap &params);
+    bool createWidget(const QVariantHash &params);
+    HsWidgetHost *createWidgetForPreview(const QVariantHash &params);
 
 private:
     Q_DISABLE_COPY(HsContentService)
--- a/homescreenapp/hsdomainmodel/inc/hsdatabase.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/inc/hsdatabase.h	Fri Apr 16 14:54:01 2010 +0300
@@ -11,20 +11,18 @@
 *
 * Contributors:
 *
-* Description:  Implementation for SQLite content store.
+* Description:
 *
 */
 
 #ifndef HSDATABASE_H
 #define HSDATABASE_H
 
+#include <QObject>
 #include <QScopedPointer>
-#include <QtSql>
+#include <QVariantHash>
+
 #include "hsdomainmodel_global.h"
-#include "hstest_global.h"
-
-HOMESCREEN_TEST_CLASS(TestRuntimeServices)
-HOMESCREEN_TEST_CLASS(HomeScreenStatePluginTest)
 
 class HsSceneData;
 class HsPageData;
@@ -34,60 +32,64 @@
 class HSDOMAINMODEL_EXPORT HsDatabase : public QObject
 {
     Q_OBJECT
-
+    Q_PROPERTY(QString connectionName READ connectionName WRITE setConnectionName)
+    Q_PROPERTY(QString databaseName READ databaseName WRITE setDatabaseName)
+    
 public:
-    static void setDatabaseName(const QString& dbName);
-    static HsDatabase *instance();
+    HsDatabase(QObject *parent = 0);
     ~HsDatabase();
 
+    void setConnectionName(const QString &name);
+    QString connectionName() const;    
+    void setDatabaseName(const QString &name);
+    QString databaseName() const;
+
+    bool open();
+    void close();
+
     bool transaction();
     bool rollback();
     bool commit();
 
-    bool scene(HsSceneData &scene);
-    bool updateScene(const HsSceneData &scene);
+    bool scene(HsSceneData &data);
+    bool updateScene(const HsSceneData &data);
+
+    bool pages(QList<HsPageData> &data);
+    bool page(HsPageData &data);
+    bool insertPage(HsPageData &data);
+    bool updatePage(const HsPageData &data);
+    bool deletePage(int id);
     
-    bool pages(QList<HsPageData> &pages);
-    bool page(int id, HsPageData &page, bool getChildren = true);
-    bool insertPage(HsPageData &page);
-    bool updatePage(const HsPageData &page, bool updateChildren = true);
-    bool deletePage(int id);
-
-    bool widget(int id, HsWidgetData &widget, bool getChildren = true);
-    bool insertWidget(HsWidgetData &widget);
-    bool insertWidget(const HsWidgetData &widget,int &databaseId);
-    bool updateWidget(const HsWidgetData &widget, bool updateChildren = true);
+    bool widgets(int pageId, QList<HsWidgetData> &data);
+    bool widgets(const QString &uri, QList<HsWidgetData> &data);
+    bool widget(HsWidgetData &data);
+    bool insertWidget(HsWidgetData &data);
+    bool updateWidget(const HsWidgetData &data);
     bool deleteWidget(int id);
     bool deleteWidgets(const QString &uri);
 
-    bool widgetPresentation(int widgetId, const QString &key, HsWidgetPresentationData &presentation);
-    bool insertWidgetPresentation(HsWidgetPresentationData &presentation);
-    bool updateWidgetPresentation(const HsWidgetPresentationData &presentation);
-    bool deleteWidgetPresentation(int id);
+    bool widgetPresentation(HsWidgetPresentationData &data);
+    bool setWidgetPresentation(const HsWidgetPresentationData &data);
+    bool deleteWidgetPresentation(int widgetId, const QString &key);
 
-    bool setWidgetPreferenceForKey(int widgetId, const QString &key, const QString &value);
-    bool widgetPreferenceForKey(int widgetId, const QString &key, QString &value);
-    bool setWidgetPreferences(int widgetId, const QVariantMap &preferences);
-    bool widgetPreferences(int widgetId, QVariantMap &preferences);
-    bool widgetIds(const QString &uri, QList<int>& ids);
+    bool widgetPreferences(int widgetId, QVariantHash &data);
+    bool widgetPreference(int widgetId, const QString &key, QVariant &value);
+    bool setWidgetPreferences(int widgetId, const QVariantHash &data);
+            
+public:
+    static void setInstance(HsDatabase *instance);
+    static HsDatabase *instance();
+    static HsDatabase *takeInstance();
+
+private:    
+    Q_DISABLE_COPY(HsDatabase)
+    bool checkConnection() const;
 
 private:
-    HsDatabase();
-    bool openDatabase(const QString &databaseName);
-    Q_DISABLE_COPY(HsDatabase)
-
-    bool parsePage(const QSqlQuery &query, bool getChildren, HsPageData &page);
-    bool parseWidget(const QSqlQuery &query, bool getChildren, HsWidgetData &widget);
-    bool parseWidgetPresentation(const QSqlQuery &query, HsWidgetPresentationData &presentation);
+    QString mConnectionName;
+    QString mDatabaseName;
 
-    QVariant columnValue(const QSqlQuery &query, const QString &columnName) const;
-    QSqlDatabase database() const;
-
-private:
     static QScopedPointer<HsDatabase> mInstance;
-    static QString  mDatabaseName;
-    HOMESCREEN_TEST_FRIEND_CLASS(TestRuntimeServices)
-    HOMESCREEN_TEST_FRIEND_CLASS(HomeScreenStatePluginTest)
 };
 
 #endif // HSDATABASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/inc/hsdomainmodeldatastructures.h	Fri Apr 16 14:54:01 2010 +0300
@@ -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 HSDOMAINMODELDATASTRUCTURES_H
+#define HSDOMAINMODELDATASTRUCTURES_H
+
+#include <QRectF>
+#include "hsdomainmodel_global.h"
+
+class HSDOMAINMODEL_EXPORT HsSceneData
+{
+public:
+    HsSceneData() 
+      : id(-1), defaultPageId(-1), maximumPageCount(-1)
+    {}
+    
+    int     id;
+    QString portraitWallpaper;
+    QString landscapeWallpaper;
+    int     defaultPageId;
+    int     maximumPageCount;
+};
+
+class HSDOMAINMODEL_EXPORT HsPageData
+{
+public:
+    HsPageData() 
+      : id(-1), indexPosition(-1)
+    {}
+    
+    int id;    
+    int indexPosition;
+};
+
+class HSDOMAINMODEL_EXPORT HsWidgetData
+{
+public:
+    HsWidgetData()
+      : id(-1), 
+        pageId(-1)
+    {}
+
+    int     id;
+    QString uri;
+    int     pageId;
+};
+
+class HSDOMAINMODEL_EXPORT HsWidgetPresentationData
+{
+public:
+    HsWidgetPresentationData()
+        : x(0), y(0), width(0), height(0), zValue(0), 
+          widgetId(-1)
+    {}
+
+    QRectF geometry() const
+    {
+        return QRectF(x, y, width, height);
+    }
+
+    void setGeometry(const QRectF &geometry)
+    {
+        x      = geometry.x();
+        y      = geometry.y();
+        width  = geometry.width();
+        height = geometry.height();
+    }
+
+    void setPos(const QPointF &pos)
+    {
+        x = pos.x();
+        y = pos.y();
+    }
+
+    void setSize(const QSizeF &size)
+    {
+        width  = size.width();
+        height = size.height();
+    }
+
+    QString key;
+    qreal   x;
+    qreal   y;
+    qreal   width;
+    qreal   height;
+    qreal   zValue;
+    int     widgetId;
+};
+
+#endif // HSDOMAINMODELDATASTRUCTURES_H
--- a/homescreenapp/hsdomainmodel/inc/hsipcchannel.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#ifndef HSIPCHANNEL_H
-#define HSIPCHANNEL_H
-
-#include <QLocalSocket>
-#include <QVariantMap>
-
-#include "hsdomainmodel_global.h"
-
-class QDataStream;
-
-class HSDOMAINMODEL_EXPORT HsIpcChannel : public QObject
-{
-    Q_OBJECT
-public:
-    
-    virtual ~HsIpcChannel();
-
-    bool isConnected() const;
-    bool sendMessage(const QVariantMap &message);
-    bool waitForSendMessage(const QVariantMap &message);
-    bool waitForReadMessage(QVariantMap &message);
-    virtual void closeConnection()=0;
-
-signals:
-    void connectionEstablished();
-    void connectionError();
-    void messageReceived(const QVariantMap &message);
-    void disconnected();
-private slots:
-    void onReadyRead();
-    void onError(QLocalSocket::LocalSocketError socketError);
-
-protected:
-     HsIpcChannel(QObject *parent = 0);
-     
-protected:
-    quint32 mBlockSize;
-    QLocalSocket *mSocket;
-};
-
-#endif // HsIpcChannel_H
--- a/homescreenapp/hsdomainmodel/inc/hsipcchannelclient.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#ifndef HSIPCCHANNELCLIENT_H
-#define HSIPCCHANNELCLIENT_H
-
-#include "hsipcchannel.h"
-
-class HSDOMAINMODEL_EXPORT HsIpcChannelClient : public HsIpcChannel
-{
-    Q_OBJECT
-public:
-    HsIpcChannelClient(QObject *parent = 0);
-    ~HsIpcChannelClient();
-
-    bool openConnection(const QString &serverName);
-    bool waitForOpenConnection(const QString &serverName);
-    void closeConnection();
-    bool waitForCloseConnection();
-
-private slots:
-    void onConnected();
-};
-
-#endif 
--- a/homescreenapp/hsdomainmodel/inc/hsipcchannelhost.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-#ifndef HSIPCCHANNELHOST_H
-#define HSIPCCHANNELHOST_H
-
-#include <QObject>
-#include "hsipcchannelclient.h"
-
-
-class HSDOMAINMODEL_EXPORT HsIpcChannelHost : public HsIpcChannel
-{
-    Q_OBJECT
-
-public:
-    HsIpcChannelHost(QLocalSocket *socket,QObject *parent=0);
-    ~HsIpcChannelHost();
-
-    void closeConnection();
-private:
-    
-};
-
-#endif // HSIPCCHANNELHOST_H
--- a/homescreenapp/hsdomainmodel/inc/hsipcconnectiondispatcher.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#ifndef HSIPCCONNECTIONDISPATCHER_H
-#define HSIPCCONNECTIONDISPATCHER_H
-
-#include <QObject>
-#include <QVariant>
-#include "hsdomainmodel_global.h"
-
-class HsIpcServer;
-class HsContentPublishHandler;
-
-class HSDOMAINMODEL_EXPORT HsIpcConnectionDispatcher : public QObject
-{
-    Q_OBJECT
-
-public:
-    HsIpcConnectionDispatcher(const QString &connectionName,QObject *parent=0);
-    ~HsIpcConnectionDispatcher();
-
-    bool start();
-    void stop();
-private slots:
-    void onConnectionEstablished();
-
-private:
-    QString mConnectionName;
-    HsIpcServer *mIpcServer;
-};
-
-#endif // HSIPCCONNECTIONDISPATCHER_H
--- a/homescreenapp/hsdomainmodel/inc/hsipcserver.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#ifndef HSIPCSERVER_H
-#define HSIPCSERVER_H
-
-#include <QObject>
-#include <QQueue>
-#include "hsdomainmodel_global.h"
-
-class QLocalServer;
-class HsIpcChannelHost;
-
-class HSDOMAINMODEL_EXPORT HsIpcServer: public QObject
-{
-    Q_OBJECT
-public:
-    HsIpcServer(QObject *parent = 0);
-    ~HsIpcServer();
-
-    bool startServer(const QString &serverName);
-    void stopServer();
-    
-    HsIpcChannelHost* takeConnection();
-signals:
-    void newConnection();
-private slots:
-    void onNewConnection();
-
-private:
-    QLocalServer *mServer;
-    QQueue<HsIpcChannelHost*> mConnections;
-};
-
-#endif // HSIPCSERVER_H
--- a/homescreenapp/hsdomainmodel/inc/hspage.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/inc/hspage.h	Fri Apr 16 14:54:01 2010 +0300
@@ -48,7 +48,6 @@
     bool addNewWidget(HsWidgetHost *widgetHost);
     void layoutNewWidgets();
     void resetNewWidgets();    
-
     bool deleteFromDatabase();
 
     QList<HsWidgetHost *> widgets() const;
@@ -57,11 +56,14 @@
     void setRemovable(bool removable);
 
     bool updateZValues();
-    
-    void setOnline(bool online = true);
 
     static HsPage *createInstance(const HsPageData &pageData);
 
+public slots:
+    void showWidgets();
+    void hideWidgets();
+    void setOnline(bool online = true);
+
 private:
     void connectWidget(HsWidgetHost *widget);
     void disconnectWidget(HsWidgetHost *widget);
@@ -73,8 +75,9 @@
     int mDatabaseId;    
     bool mRemovable;
     QList<HsWidgetHost*> mWidgets;
-    QList<HsWidgetHost *> mNewWidgets;
-
+    QList<HsWidgetHost*> mNewWidgets;
+    QMap<QString, QPointF> mStartPoint; 
+    
     HOMESCREEN_TEST_FRIEND_CLASS(TestRuntimeServices)
 };
  
--- a/homescreenapp/hsdomainmodel/inc/hspagedata.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Contains page metadata.
-*
-*/
-
-#ifndef HSPAGEDATA_H
-#define HSPAGEDATA_H
-
-#include <QList>
-#include <QString>
-#include "hsdomainmodel_global.h"
-#include "hswidgetdata.h"
-
-class HSDOMAINMODEL_EXPORT HsPageData
-{
-public:	
-    HsPageData();
-	~HsPageData();
-
-    void setId(int pageId);
-	int id() const;
-	
-	void setIndex(int index);
-    int index() const;
-	    
-    QList<HsWidgetData> widgets() const;
-    QList<HsWidgetData> &widgets();
-        
-private:
-    int mId;	
-    int mIndex;	    
-	QList<HsWidgetData> mWidgets;    
-};
-
-#endif
--- a/homescreenapp/hsdomainmodel/inc/hsscene.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/inc/hsscene.h	Fri Apr 16 14:54:01 2010 +0300
@@ -31,7 +31,7 @@
 class HsPage;
 class HsWidgetHost;
 
-class HsScenePrivate;
+
 class HSDOMAINMODEL_EXPORT HsScene : public QObject
 {
     Q_OBJECT
@@ -54,6 +54,7 @@
     bool setActivePageIndex(int index);
     HsPage *activePage() const;
     int activePageIndex() const;
+    int maximumPageCount() const;
 
     void setActiveWidget(HsWidgetHost *widget);
     HsWidgetHost *activeWidget() const;
@@ -70,7 +71,15 @@
     Q_DISABLE_COPY(HsScene)
 
 private:
-    QScopedPointer<HsScenePrivate> mD;
+    int mDatabaseId;
+    bool mIsOnline;
+    HsWallpaper *mWallpaper;
+    QList<HsPage *> mPages;
+    int mMaximumPageCount;
+    HsPage *mActivePage;
+    HsWidgetHost *mActiveWidget;
+
+    
     static QScopedPointer<HsScene> mInstance;
 
     HOMESCREEN_TEST_FRIEND_CLASS(TestRuntimeServices)
--- a/homescreenapp/hsdomainmodel/inc/hsscene_p.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#ifndef HSSCENE_P_H
-#define HSSCENE_P_H
-
-class HsWallpaper;
-class HsPage;
-class HsWidgetHost;
-#ifndef Q_OS_SYMBIAN
-class HsIpcConnectionDispatcher;
-#endif
-
-class HsScenePrivate
-{
-public:
-    HsScenePrivate();
-    ~HsScenePrivate();
-
-    int mDatabaseId;
-    bool mIsOnline;
-    HsWallpaper *mWallpaper;
-    QList<HsPage *> mPages;
-    HsPage *mActivePage;
-    HsWidgetHost *mActiveWidget;
-#ifndef Q_OS_SYMBIAN
-    HsIpcConnectionDispatcher *mIpcConnectionDispatcher;
-#endif
-    
-};
-
-#endif // HSSCENE_P_H
--- a/homescreenapp/hsdomainmodel/inc/hsscenedata.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Contains scene metadata.
-*
-*/
-
-#ifndef HSSCENEDATA_H
-#define HSSCENEDATA_H
-
-#include <QString>
-#include "hsdomainmodel_global.h"
-#include "hspagedata.h"
-
-class HSDOMAINMODEL_EXPORT HsSceneData
-{
-
-public:
-	HsSceneData();
-	~HsSceneData();
-	
-    void setId(int id);
-	int id() const;
-
-    void setPortraitWallpaper(const QString &path);
-	QString portraitWallpaper() const;
-
-    void setLandscapeWallpaper(const QString &path);
-	QString landscapeWallpaper() const;
-
-    void setDefaultPage(const HsPageData &defaultPage);
-	HsPageData defaultPage() const;
-    
-private:
-    int mId;
-	QString mPortraitWallpaper;
-    QString mLandscapeWallpaper;
-    HsPageData mDefaultPage;
-	
-};
-
-
-
-
-#endif
--- a/homescreenapp/hsdomainmodel/inc/hswallpaper.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/inc/hswallpaper.h	Fri Apr 16 14:54:01 2010 +0300
@@ -54,7 +54,10 @@
     Q_DISABLE_COPY(HsWallpaper)
 
 private:
-    QScopedPointer<HsWallpaperPrivate> mD;
+    QPixmap mImage;
+    QString mLImagePath;
+    QString mPImagePath;
+    Qt::Orientation mOrientation;
     
     HOMESCREEN_TEST_FRIEND_CLASS(TestRuntimeServices)
 };
--- a/homescreenapp/hsdomainmodel/inc/hswallpaper_p.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#ifndef HSWALLPAPER_P_H
-#define HSWALLPAPER_P_H
-
-#include <QPixmap>
-
-class HsWallpaperPrivate
-{
-public:
-    HsWallpaperPrivate();
-    ~HsWallpaperPrivate();
-
-    QPixmap mImage;
-    QString mLImagePath;
-    QString mPImagePath;
-    Qt::Orientation mOrientation;
-};
-
-#endif // HSWALLPAPER_P_H
--- a/homescreenapp/hsdomainmodel/inc/hswidgetdata.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Contains widget metadata.
-*
-*/
-
-#ifndef HSWIDGETDATA_H
-#define HSWIDGETDATA_H
-
-#include <QList>
-#include <QString>
-#include "hsdomainmodel_global.h"
-#include "hswidgetpresentationdata.h"
-
-
-class HSDOMAINMODEL_EXPORT HsWidgetData
-{
-
-public:
-
-	HsWidgetData();
-	~HsWidgetData();
-
-	void setId(int id);
- 	int id() const;
-
-    void setUri(const QString &uri);
-	QString uri() const;
-	
-    QList<HsWidgetPresentationData> presentations() const;
-    QList<HsWidgetPresentationData> &presentations();
-
-	void setPageId(int pageId);
-	int pageId() const;
-
-private:
-
-    int mId;
-	QString mUri;
-    QList<HsWidgetPresentationData> mPresentations;
-    int mPageId;
-
-};
-
-
-
-
-#endif
--- a/homescreenapp/hsdomainmodel/inc/hswidgethost.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/inc/hswidgethost.h	Fri Apr 16 14:54:01 2010 +0300
@@ -24,7 +24,7 @@
 
 #include <HbWidget>
 
-#include "hswidgetdata.h"
+#include "hsdomainmodeldatastructures.h"
 #include "hsdomainmodel_global.h"
 #include "hstest_global.h"
 
@@ -40,8 +40,19 @@
     Q_OBJECT
 
 public:
-    static HsWidgetHost *createInstance(const HsWidgetData &widgetData, 
-                                        const QVariantMap &preferences = QVariantMap());
+    enum State {
+        Constructed,
+        Initialized,
+        Visible,
+        Hidden,
+        Uninitialized,
+        Finished,
+        Faulted
+    };
+
+public:
+    static HsWidgetHost *createInstance(HsWidgetData &widgetData, 
+                                        const QVariantHash &preferences = QVariantHash());
 
     HsWidgetHost(int databaseId, QGraphicsItem *parent = 0);
     
@@ -56,6 +67,8 @@
 
     int databaseId() const;
 
+    State state() const { return mState; }
+
     bool deleteFromDatabase();
     
     bool setWidgetPresentation();
@@ -102,6 +115,7 @@
     QMetaMethod mOnHideMethod;
     QMetaMethod mOnUninitializeMethod;
     QMetaProperty mIsOnlineProperty;
+    State mState;
     
     int mDatabaseId;
     QString mUri;
--- a/homescreenapp/hsdomainmodel/inc/hswidgetpresentationdata.h	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Contains widget presentation metadata.
-*
-*/
-
-
-#ifndef HSWIDGETPRESENTATIONDATA_H
-#define HSWIDGETPRESENTATIONDATA_H
-
-#include <QString>
-#include <QPointF>
-#include <QSizeF>
-#include "hsdomainmodel_global.h"
-
-class HSDOMAINMODEL_EXPORT HsWidgetPresentationData
-{
-
-public:
-	HsWidgetPresentationData();
-	~HsWidgetPresentationData();
-
-	void setId(int id);
-	int id() const;
-
-    void setKey(const QString &key);
-    QString key() const;
-
-    void setPosition(const QPointF &position);
-    QPointF position() const;
-
-	void setZValue(qreal zValue);
-   	qreal zValue() const;
-
-    void setSize(const QSizeF &size);
-    QSizeF size() const;
-
-	void setWidgetId(int widgetId);
-	int widgetId() const;
-   	
-private:
-    int mId;
-	QString mKey;
-    QPointF mPosition;
-    QSizeF mSize;
-    int mWidgetId;
-    qreal mZValue;	
-};
-
-#endif
--- a/homescreenapp/hsdomainmodel/src/hscontentpublishhandler.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-#include <QDebug>
-#include "hscontentpublishhandler.h"
-#include "hsipcchannelhost.h"
-#include "hsscene.h"
-#include "hspage.h"
-#include "hswidgetdata.h"
-#include "hswidgethost.h"
-
-HsContentPublishHandler::HsContentPublishHandler(
-    HsIpcChannelHost *channel, QObject *parent)
-    : QObject(parent),mChannel(channel)
-{
-    connect(mChannel,SIGNAL(disconnected()),SLOT(deleteLater()));
-    connect(mChannel, SIGNAL(messageReceived(const QVariantMap&)), 
-        SLOT(onMessageReceived(const QVariantMap&)),Qt::QueuedConnection);
-    qDebug() << "HsContentPublishHandler::HsContentPublishHandler" << (int)this;
-    
-}
-
-HsContentPublishHandler::~HsContentPublishHandler()
-{
-    qDebug() << "HsContentPublishHandler::~HsContentPublishHandler" << (int)this;
-    delete mChannel;
-}
-
-void HsContentPublishHandler::onMessageReceived(const QVariantMap &message)
-{
-    qDebug() << "HsContentPublishHandler message: " << message;
-
-    QString messageType = message.value("messageType").toString();
-    
-    if(messageType == "addWidget"){
-        QString uri = message.value("uri").toString();
-        QVariantMap preferences = message.value("preferences").toMap();
-
-        QString result("true");
-        if(!addWidget(uri,preferences)){
-            result = "false";
-        }
-        
-        // write response
-        QVariantMap response;
-        response.insert("messageType", "response");
-        response.insert("result", result);
-        response.insert("request", message);
-        if(!mChannel->sendMessage(response)){
-            qDebug() << "HsContentPublishHandler response failed: ";    
-        }
-        
-    }else{
-        qDebug() << "HsContentPublishHandler messageType not supported!";
-    }
-
-    
-}
-
-bool HsContentPublishHandler::addWidget(
-    const QString &uri, const QVariantMap &preferences)
-{
-    HsWidgetData widgetData;
-    widgetData.setUri(uri);
-
-    QScopedPointer<HsWidgetHost> widget(HsWidgetHost::createInstance(widgetData, preferences));
-
-    if (!widget.data()) {
-        qDebug() << "HsWidgetHost::createInstance failed";
-        return false;
-    }
-    HsPage* activePage = HsScene::instance()->activePage();
-    if (!widget->load() || !activePage->addNewWidget(widget.data())) {
-        widget->deleteFromDatabase();
-        qDebug() << "widget->load() || activePage->addNewWidget failed";
-        return false;
-    }
-    HsWidgetHost* taken = widget.take();
-    taken->initializeWidget();
-    taken->showWidget();
-    activePage->layoutNewWidgets();
-    activePage->resetNewWidgets();
-    
-    
-    return true;
-}
\ No newline at end of file
--- a/homescreenapp/hsdomainmodel/src/hscontentservice.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hscontentservice.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -19,7 +19,7 @@
 #include "hsdatabase.h"
 #include "hsscene.h"
 #include "hspage.h"
-#include "hswidgetdata.h"
+#include "hsdomainmodeldatastructures.h"
 #include "hswidgethost.h"
 
 
@@ -34,7 +34,7 @@
 }
 
 
-bool HsContentService::createWidget(const QVariantMap &params)
+bool HsContentService::createWidget(const QVariantHash &params)
 {
     HsWidgetHost *widget = createWidgetForPreview(params);
     if (!widget) {
@@ -44,14 +44,14 @@
     return HsScene::instance()->activePage()->addNewWidget(widget);
 }
 
-HsWidgetHost *HsContentService::createWidgetForPreview(const QVariantMap &params)
+HsWidgetHost *HsContentService::createWidgetForPreview(const QVariantHash &params)
 {
     HsWidgetData widgetData;
-    widgetData.setUri(params.value("uri").toString());
+    widgetData.uri = params.value("uri").toString();
 
 
-    HsWidgetHost *widget = HsWidgetHost::createInstance(widgetData,  
-            params.value("preferences").toMap());
+    HsWidgetHost *widget = HsWidgetHost::createInstance(widgetData,
+                                                        params.value("preferences").toHash());
 
     if (!widget) {
         return NULL;
--- a/homescreenapp/hsdomainmodel/src/hsdatabase.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hsdatabase.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -11,727 +11,714 @@
 *
 * Contributors:
 *
-* Description:  Implementation for SQLlite content store.
+* Description:
 *
 */
 
+#include <QSqlDatabase>
+#include <QSqlQuery>
+#include <QSqlRecord>
+#include <QVariantHash>
+#include <QDir>
+
 #include "hsdatabase.h"
-#include "hsscenedata.h"
-#include "hspagedata.h"
-#include "hswidgetdata.h"
-#include "hswidgetpresentationdata.h"
-#include "hstest_global.h"
-
-namespace 
-{
-    const char DATABASE_CONNECTION_NAME[] = "hsdb.connection";
-}
+#include "hsdomainmodeldatastructures.h"
 
-#ifdef Q_OS_SYMBIAN
-QString HsDatabase::mDatabaseName("c:\\private\\20022f35\\homescreendb");
-#else
-QString HsDatabase::mDatabaseName("homescreendb");
-#endif //Q_OS_SYMBIAN
-
-QScopedPointer<HsDatabase> HsDatabase::mInstance(0);
+namespace
+{
+    template<class T>
+    QVariantList toVariantList(const QList<T> &list)
+    {
+        QVariantList vlist;
+        foreach (T item, list) {
+            vlist << item;
+        }
+        return vlist;
+    }
 
-/*!
-    Utility to create variant list from given \a list
-*/
-template<class T>
-QVariantList toVariantList(const QList<T> &list)
-{
-    QVariantList vlist;
-    foreach (T item, list) {
-        vlist << item;
+    template<class T>
+    QVariantList toVariantList(const T &item, int count)
+    {
+        QVariantList vlist;
+        for (int i = 0; i < count; ++i) {
+            vlist << item;
+        }
+        return vlist;
     }
-    return vlist;
 }
 
 /*!
-    Utility to insert given \a item to variant list \a count times
-*/
-template<class T>
-QVariantList toVariantList(const T &item, int count)
-{
-    QVariantList vlist;
-    for (int i = 0; i < count; ++i) {
-        vlist << item;
-    }
-    return vlist;
-}
-/*!
-    Set name of the database to use
+    Constructs a new database with the given \a parent object.
 */
- void HsDatabase::setDatabaseName(const QString& dbName)
- {
-    mDatabaseName = QDir::toNativeSeparators(dbName);
- }
-
-/*!
-    \class HsDatabase
-    \ingroup group_hsdatamodel
-    \brief Implementation for SQLlite content store.
-
-    Home screen content store that uses an SQLite database
-    as the data store.
-
-*/
-
-/*!
-    Singleton. 
-*/
-HsDatabase *HsDatabase::instance()
+HsDatabase::HsDatabase(QObject *parent)
+  : QObject(parent)
 {
-    if (mInstance.isNull()) {
-        mInstance.reset(new HsDatabase());
-        if(!mInstance->openDatabase(mDatabaseName)){
-            mInstance.reset();  
-        }
-    }
-    return mInstance.data();
-}
-
-/*!
-    Closes database and removes it.
-*/
-HsDatabase::~HsDatabase()
-{
-    // Database calls must be in scope, see info from
-    // QSqlDatabase::removeDatabase() documentation.
-    {
-        QSqlDatabase db = database();
-        db.close();
-    }
-
-    QSqlDatabase::removeDatabase(DATABASE_CONNECTION_NAME);
-}
-
-bool HsDatabase::transaction()
-{
-    return database().transaction();
-}
-
-bool HsDatabase::rollback()
-{
-    return database().rollback();
-}
-
-bool HsDatabase::commit()
-{
-    return database().commit();
 }
 
 /*!
-    Returns scene data in \a scene
+    Destroys this database.
 */
-bool HsDatabase::scene(HsSceneData &scene)
-{   
-    HsSceneData temp;
-
-    QSqlDatabase db = database();        
-    QSqlQuery query(db);
-
-    query.prepare("SELECT * FROM Scene");
-
-    if (!query.exec() || !query.next()) {
-        return false;
-    }
-    
-    temp.setId(columnValue(query, "Id").toInt());
-    temp.setPortraitWallpaper(columnValue(query, "PortraitWallpaper").toString());
-    temp.setLandscapeWallpaper(columnValue(query, "LandscapeWallpaper").toString());
-        
-    int defaultPageId = columnValue(query, "DefaultPageId").toInt();
-
-    query.prepare("SELECT * FROM Pages WHERE Id = ?");
-    query.addBindValue(defaultPageId);
-    
-    if (!query.exec() || !query.next()) {
-        return false;
-    }
-    
-    HsPageData page;    
-    if (!parsePage(query, true, page)) {
-        return false;
-    }
-    temp.setDefaultPage(page);
-
-    scene = temp;
-
-    return true;
+HsDatabase::~HsDatabase()
+{
+    close();
 }
 
 /*!
-    Updates the scene with \a scene.
+    Sets the connection name to \a name.
 */
-bool HsDatabase::updateScene(const HsSceneData &scene)
+void HsDatabase::setConnectionName(const QString &name)
 {
-    QSqlDatabase db = database();
-
-    QString queryString = "UPDATE Scene "
-                          "SET PortraitWallpaper = ?, LandscapeWallpaper = ? "
-                          "WHERE Id = ?";
-
-  
-    QSqlQuery query(db);
-
-    query.prepare(queryString);
-    query.addBindValue(scene.portraitWallpaper());
-    query.addBindValue(scene.landscapeWallpaper());    
-    query.addBindValue(scene.id());
-
-    return query.exec();
+    mConnectionName = name;
+}
+ 
+/*!
+    Returns the connection name.
+*/
+QString HsDatabase::connectionName() const
+{
+    return mConnectionName;
 }
 
 /*!
-    Returns page data in \a pages list
+    Sets the database name to \a name.
 */
-bool HsDatabase::pages(QList<HsPageData> &pages)
+void HsDatabase::setDatabaseName(const QString &name)
 {
-    QList<HsPageData> temp;
-
-    QSqlDatabase db = database();           
-    QSqlQuery query(db);
-
-    query.prepare("SELECT * FROM Pages ORDER BY PageIndex");
-    
-    if (!query.exec()) {
-        return false;
-    }
-    
-    while (query.next()) {
-        HsPageData page;
-        if (!parsePage(query, true, page)) {
-            return false;
-        }
-        temp << page;
-    }
-
-    pages = temp;
-
-    return true;
+    mDatabaseName = QDir::toNativeSeparators(name);
 }
-
+ 
 /*!
-    Returns a\ page data for the page with given \a id. Includes children
-    data if \a getChildren is true
+    Returns the database name.
 */
-bool HsDatabase::page(int id, HsPageData &page, bool getChildren)
+QString HsDatabase::databaseName() const
 {
-    QSqlDatabase db = database();           
-    QSqlQuery query(db);
-
-    QString queryString = "SELECT * FROM Pages "
-                          "WHERE Id = ?";
-
-    query.prepare(queryString);
-    query.addBindValue(id);
-    
-    if (!query.exec() || !query.next()) {
-        return false;
-    }
-    
-    return parsePage(query, getChildren, page);
+    return mDatabaseName;
 }
 
 /*!
-    Insert page based on given \a page data 
-*/
-bool HsDatabase::insertPage(HsPageData &page)
+    Opens the database connection using the current connection
+    values. Returns true on success, otherwise returns false.
+*/  
+bool HsDatabase::open()
 {
-    QSqlDatabase db = database();
-
-    QString queryString = "INSERT INTO Pages "
-                          "(PageIndex) "
-                          "VALUES(?)";
-
-    QSqlQuery query(db);
-
-    query.prepare(queryString);    
-    query.addBindValue(page.index());
-    
-    if (!query.exec()) {
+    QSqlDatabase database;
+    if (QSqlDatabase::contains(mConnectionName)) {
+        database = QSqlDatabase::database(mConnectionName);
+    } else {
+        database = QSqlDatabase::addDatabase("QSQLITE", mConnectionName);
+        database.setDatabaseName(mDatabaseName);
+    }
+    if (!database.isValid()) {
+        close();
         return false;
     }
-
-    page.setId(query.lastInsertId().toInt());
-
-    QList<HsWidgetData> &widgets = page.widgets();
-    for (int i = 0; i < widgets.count(); ++i) {
-        widgets[i].setPageId(page.id());
-        if (!insertWidget(widgets[i])) {
-            return false;
-        }
-    }
-
-    return true;
-}
-
-
-/*!
-    Updates a page based on given \a page data. Includes children
-    data if \a getChildren is true
-*/
-bool HsDatabase::updatePage(const HsPageData &page, bool updateChildren)
-{
-    QSqlDatabase db = database();
-
-    QString queryString = "UPDATE Pages "
-                          "SET PageIndex = ? "
-                          "WHERE Id = ?";
-
-  
-    QSqlQuery query(db);
-
-    query.prepare(queryString);    
-    query.addBindValue(page.index());    
-    query.addBindValue(page.id());
-
-    if (!query.exec()) {
-        return false;
-    }
-
-    if (!updateChildren) {
-        return true;
-    }
-
-    QList<HsWidgetData> widgets = page.widgets();
-    for (int i = 0; i < widgets.count(); ++i) {
-        if (!updateWidget(widgets[i])) {
+    if (!database.isOpen()) {
+        if (!database.open()) {
+            close();
             return false;
         }
     }
     return true;
 }
+ 
+/*!
+    Closes the database connection.
+*/
+void HsDatabase::close()
+{
+    {
+        QSqlDatabase database = QSqlDatabase::database(mConnectionName);
+        if (database.isValid() && database.isOpen()) {
+            database.close();
+        }
+    }
+    QSqlDatabase::removeDatabase(mConnectionName);
+}
 
 /*!
-    Deletes page with given \a id
+    Begins a transaction on the database if the driver 
+    supports transactions. Returns true if the operation 
+    succeeded. Otherwise returns false.
+*/
+bool HsDatabase::transaction()
+{
+    return QSqlDatabase::database(mConnectionName).transaction();
+}
+ 
+/*!
+    Rolls back a transaction on the database, if the driver 
+    supports transactions and a transaction() has been started.
+    Returns true if the operation succeeded. Otherwise returns
+    false.
 */
-bool HsDatabase::deletePage(int id)
+bool HsDatabase::rollback()
 {
-    HsPageData pageToBeDeleted;
+    return QSqlDatabase::database(mConnectionName).rollback();
+}
+ 
+/*!
+    Commits a transaction to the database if the driver supports 
+    transactions and a transaction() has been started. Returns 
+    true if the operation succeeded. Otherwise returns false.
+*/
+bool HsDatabase::commit()
+{
+    return QSqlDatabase::database(mConnectionName).commit();
+}
 
-    if (!page(id, pageToBeDeleted, false)) {
-        return false;
-    }
-   
-    QSqlDatabase db = database();
-              
-    QString queryString = "DELETE FROM Pages "
-                          "WHERE Id = ?";
+/*!
 
-    QSqlQuery query(db);
-
-    query.prepare(queryString);
-    query.addBindValue(id);
-    
-    if (!query.exec()) {
+*/
+bool HsDatabase::scene(HsSceneData &data)
+{
+    if (!checkConnection()) {
         return false;
     }
 
-    //update other indexes
-    QList<HsPageData> allPages;
-    if (!pages(allPages)) {
-        return false;    
-    }
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    HsPageData page;
-    foreach (page, allPages) {
-        if (page.index() > pageToBeDeleted.index()) {
-            page.setIndex(page.index() - 1);
-            if (!updatePage(page, false)) {
-                return false;   
-            }
-        }
+    QString statement =
+        "SELECT id, portraitWallpaper, landscapeWallpaper, defaultPageId, maximumPageCount "
+        "FROM Scene";
+    
+    if (query.prepare(statement) && query.exec() && query.next()) {        
+        data.id                 = query.value(0).toInt();
+        data.portraitWallpaper  = query.value(1).toString();
+        data.landscapeWallpaper = query.value(2).toString();
+        data.defaultPageId      = query.value(3).toInt();
+        data.maximumPageCount   = query.value(4).toInt();
+        return true;
     }
-
-    return true;
-
+    
+    return false;
 }
 
 /*!
-    Returns widget data for the widget with given id. Includes children
-    data if \a getChildren is true
+
 */
-bool HsDatabase::widget(int id, HsWidgetData &widget, bool getChildren)
+bool HsDatabase::updateScene(const HsSceneData &data)
 {
-    QSqlDatabase db = database();
-    QSqlQuery query(db);
-
-    QString queryString = "SELECT * FROM Widgets "
-                          "WHERE Id = ?";
-    
-    query.prepare(queryString);
-    query.addBindValue(id);
-
-    if (!query.exec() || !query.next()) {
+    if (!checkConnection()) {
         return false;
     }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "UPDATE Scene "
+        "SET portraitWallpaper = ?, landscapeWallpaper = ? "
+        "WHERE id = ?";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(data.portraitWallpaper);
+        query.addBindValue(data.landscapeWallpaper);    
+        query.addBindValue(data.id);
+        return  query.exec();
+    }
     
-    return parseWidget(query, getChildren, widget);
+    return false;
 }
 
 /*!
-    Insert widget based on given \a widget data
+
 */
-bool HsDatabase::insertWidget(HsWidgetData &widget)
-{    
-    QSqlDatabase db = database();
+bool HsDatabase::pages(QList<HsPageData> &data)
+{
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "SELECT id, indexPosition "
+        "FROM Pages "
+        "ORDER BY indexPosition";
 
-    QString queryString = "INSERT INTO Widgets "
-                          "(Uri, PageId) "
-                          "VALUES(?, ?)";
-
-    QSqlQuery query(db);
+    if (query.prepare(statement) && query.exec()) {
+        data.clear();
+        while (query.next()) {
+            HsPageData d;
+            d.id            = query.value(0).toInt();
+            d.indexPosition = query.value(1).toInt();
+            data.append(d);
+        }
+        return true;
+    }
 
-    query.prepare(queryString);
-    query.addBindValue(widget.uri());
-    query.addBindValue(widget.pageId());
+    return false;
+}
+
+/*!
 
-    if (!query.exec()) {
+*/
+bool HsDatabase::page(HsPageData &data)
+{
+    if (!checkConnection()) {
         return false;
     }
 
-    widget.setId(query.lastInsertId().toInt());
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    QList<HsWidgetPresentationData> &presentations = widget.presentations();
-    for (int i = 0; i < presentations.count(); ++i) {
-        presentations[i].setWidgetId(widget.id());
-        if (!insertWidgetPresentation(presentations[i])) {
-            return false;
+    QString statement =
+        "SELECT indexPosition "
+        "FROM Pages "
+        "WHERE id = ?";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(data.id);
+        if (query.exec() && query.next()) {
+            data.indexPosition = query.value(0).toInt();
+            return true;
         }
     }
 
-    return true;
+    return false;
+}
+
+/*!
+
+*/
+bool HsDatabase::insertPage(HsPageData &data)
+{
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "INSERT INTO Pages "
+        "(indexPosition) "
+        "VALUES "
+        "(?)";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(data.indexPosition);
+        if (query.exec()) {
+            data.id = query.lastInsertId().toInt();
+            return true;
+        }
+    }
+
+    return false;
 }
 
 /*!
-    Insert widget based on given \a widget data. Widget \a databaseId
-    is written on return.
+
 */
-bool HsDatabase::insertWidget(const HsWidgetData &widget,
-                              int &databaseId)
+bool HsDatabase::updatePage(const HsPageData &data)
 {
-    QSqlDatabase db = database();
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "UPDATE Pages "
+        "SET indexPosition = ? "
+        "WHERE id = ?";
 
-    QString queryString = "INSERT INTO Widgets "
-                          "(Uri, PageId) "
-                          "VALUES(?, ?)";
-
-    QSqlQuery query(db);
+    if (query.prepare(statement)) {
+        query.addBindValue(data.indexPosition);
+        query.addBindValue(data.id);
+        return query.exec();
+    }
 
-    query.prepare(queryString);
-    query.addBindValue(widget.uri());
-    query.addBindValue(widget.pageId());
+    return false;
+}
+
+/*!
 
-    if (!query.exec()) {
-        QSqlError err = query.lastError();
+*/
+bool HsDatabase::deletePage(int id)
+{
+    if (!checkConnection()) {
         return false;
     }
 
-    databaseId = query.lastInsertId().toInt();
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "DELETE FROM Pages "
+        "WHERE id = ?";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(id);
+        return query.exec();
+    }
+
+    return false;
+}
+
+/*!
 
-    QList<HsWidgetPresentationData> presentations = widget.presentations();
-    for (int i = 0; i < presentations.count(); ++i) {
-        presentations[i].setWidgetId(databaseId);
-        if (!insertWidgetPresentation(presentations[i])) {
-            return false;
+*/
+bool HsDatabase::widgets(int pageId, QList<HsWidgetData> &data)
+{
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "SELECT id, uri "
+        "FROM Widgets "
+        "WHERE pageId = ?";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(pageId);
+        if (query.exec()) {
+            data.clear();
+            while (query.next()) {
+                HsWidgetData d;
+                d.id     = query.value(0).toInt();
+                d.uri    = query.value(1).toString();
+                d.pageId = pageId;
+                data.append(d);
+            }
+            return true;
         }
     }
 
-    return true;
+    return false;
 }
 
 /*!
-    Updates a widget based on given \a widget data. Includes children
-    if \a getChildren is true
+
 */
-bool HsDatabase::updateWidget(const HsWidgetData &widget, 
-                              bool updateChildren)
+bool HsDatabase::widgets(const QString &uri, QList<HsWidgetData> &data)
 {
-    QSqlDatabase db = database();
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "SELECT id, pageId "
+        "FROM Widgets "
+        "WHERE uri = ?";
 
-    QString queryString = "UPDATE Widgets "
-                          "SET Uri = ?";
-
-    if (widget.pageId() != -1) {
-        queryString += ", PageId = ?";
+    if (query.prepare(statement)) {
+        query.addBindValue(uri);
+        if (query.exec()) {
+            data.clear();
+            while (query.next()) {
+                HsWidgetData d;
+                d.id     = query.value(0).toInt();
+                d.uri    = uri;
+                d.pageId = query.value(1).toInt();
+                data.append(d);
+            }
+            return true;
+        }
     }
 
-    queryString += " WHERE Id = ?";
+    return false;
+}
+
+/*!
 
-  
-    QSqlQuery query(db);
+*/
+bool HsDatabase::widget(HsWidgetData &data)
+{
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "SELECT uri, pageId "
+        "FROM Widgets "
+        "WHERE id = ?";
 
-    query.prepare(queryString);
-    query.addBindValue(widget.uri());
-    if (widget.pageId() != -1) {
-        query.addBindValue(widget.pageId());
+    if (query.prepare(statement)) {
+        query.addBindValue(data.id);
+        if (query.exec() && query.next()) {
+            data.uri    = query.value(0).toString();
+            data.pageId = query.value(1).toInt();
+            return true;
+        }
     }
-    query.addBindValue(widget.id());
+
+    return false;
+}
 
-    if (!query.exec()) {
+/*!
+
+*/
+bool HsDatabase::insertWidget(HsWidgetData &data)
+{
+    if (!checkConnection()) {
         return false;
     }
 
-    if (!updateChildren) {
-        return true;
-    }
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    QList<HsWidgetPresentationData> presentations = widget.presentations();
-    for (int i = 0; i < presentations.count(); ++i) {
-        if (!updateWidgetPresentation(presentations[i])) {
-            return false;
+    QString statement =
+        "INSERT INTO Widgets "
+        "(uri, pageId) "
+        "VALUES "
+        "(?, ?)";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(data.uri);
+        query.addBindValue(data.pageId);
+        if (query.exec()) {
+            data.id = query.lastInsertId().toInt();
+            return true;
         }
     }
 
-    return true;
+    return false;
 }
 
 /*!
-    Deletes widget with given \a widget id
+
+*/
+bool HsDatabase::updateWidget(const HsWidgetData &data)
+{
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "UPDATE Widgets "
+        "SET uri = ?, pageId = ? "
+        "WHERE id = ?";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(data.uri);
+        query.addBindValue(data.pageId);
+        query.addBindValue(data.id);
+        return query.exec();
+    }
+
+    return false;
+}
+
+/*!
+
 */
 bool HsDatabase::deleteWidget(int id)
 {
-    QSqlDatabase db = database();
-       
-    QString queryString = "DELETE FROM Widgets "
-                          "WHERE Id = ?";
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    QSqlQuery query(db);
+    QString statement =
+        "DELETE FROM Widgets "
+        "WHERE id = ?";
 
-    query.prepare(queryString);
-    query.addBindValue(id);
+    if (query.prepare(statement)) {
+        query.addBindValue(id);
+        return query.exec();
+    }
 
-    return query.exec();
+    return false;
 }
 
 /*!
-    Deletes all widgets with given \a uri
+
 */
 bool HsDatabase::deleteWidgets(const QString &uri)
 {
-    QSqlDatabase db = database();
-       
-    QString queryString = "DELETE FROM Widgets "
-                          "WHERE Uri = ?";
-
-    QSqlQuery query(db);
-
-    query.prepare(queryString);
-    query.addBindValue(uri);
-
-    return query.exec();
-}
-
-/*!
-    Returns widget \a presentation data for the widget with given \a widgetId. 
-    Presentations can be distinguished by given \a key.
-*/
-bool HsDatabase::widgetPresentation(int widgetId, 
-                                    const QString &key, 
-                                    HsWidgetPresentationData &presentation)
-{
-    Q_UNUSED(key);
-
-    QSqlDatabase db = database();
-    QSqlQuery query(db);
-    
-    QString queryString = "SELECT * FROM WidgetPresentations "
-                          "WHERE WidgetId = ? "
-                          "AND Key = ?";
-    
-    query.prepare(queryString);
-    query.addBindValue(widgetId);
-    query.addBindValue(key);
-    
-    if (!query.exec() || !query.next()) {
+    if (!checkConnection()) {
         return false;
     }
 
-    return parseWidgetPresentation(query, presentation);
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "DELETE FROM Widgets "
+        "WHERE uri = ?";
+
+    if (query.prepare(statement)) {
+        query.addBindValue(uri);
+        return query.exec();
+    }
+
+    return false;
 }
 
 /*!
-    Inserts a widget \a presentation. 
+
 */
-bool HsDatabase::insertWidgetPresentation(HsWidgetPresentationData &presentation)
+bool HsDatabase::widgetPresentation(HsWidgetPresentationData &data)
 {
-    QSqlDatabase db = database();
- 
-    QString queryString = "INSERT INTO WidgetPresentations "
-                          "(Key, Height, Width, YPosition, XPosition, ZValue, WidgetId) "
-                          "VALUES(?, ?, ?, ?, ?, ?, ?)";
-
-    QSqlQuery query(db);
-
-    query.prepare(queryString);
-    query.addBindValue(presentation.key());
-    query.addBindValue(presentation.size().height());
-    query.addBindValue(presentation.size().width());
-    query.addBindValue(presentation.position().y());
-    query.addBindValue(presentation.position().x());
-    query.addBindValue(presentation.zValue()); 
-    query.addBindValue(presentation.widgetId());
-
-    if (!query.exec()) {
+    if (!checkConnection()) {
         return false;
     }
 
-    presentation.setId(query.lastInsertId().toInt());
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "SELECT x, y, width, height, zValue "
+        "FROM WidgetPresentations "
+        "WHERE key = ? AND widgetId = ?";
 
-    return true;
+    if (query.prepare(statement)) {
+        query.addBindValue(data.key);
+        query.addBindValue(data.widgetId);
+        if (query.exec() && query.next()) {
+            data.x      = query.value(0).toReal();
+            data.y      = query.value(1).toReal();
+            data.width  = query.value(2).toReal();
+            data.height = query.value(3).toReal();
+            data.zValue = query.value(4).toReal();
+            return true;
+        }
+    }
+
+    return false;
 }
 
 /*!
-    Update a widget \a presentation. 
-*/
-bool HsDatabase::updateWidgetPresentation(const HsWidgetPresentationData &presentation)
-{
-    QSqlDatabase db = database();
 
-    QString queryString = "UPDATE WidgetPresentations "
-                          "SET Key = ?, Height = ?, Width = ?, YPosition = ?, XPosition = ?, ZValue = ?";
-    
-    if (presentation.widgetId() != -1) {
-        queryString += ", WidgetId = ?";
+*/
+bool HsDatabase::setWidgetPresentation(const HsWidgetPresentationData &data)
+{
+    if (!checkConnection()) {
+        return false;
     }
-     
-    queryString += " WHERE Id = ?";
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    QSqlQuery query(db);
+    QString statement =
+        "REPLACE INTO WidgetPresentations "
+        "(key, x, y, width, height, zValue, widgetId) "
+        "VALUES (?, ?, ?, ?, ?, ?, ?)";
 
-    query.prepare(queryString);
-    query.addBindValue(presentation.key());
-    query.addBindValue(presentation.size().height());
-    query.addBindValue(presentation.size().width());
-    query.addBindValue(presentation.position().y());
-    query.addBindValue(presentation.position().x());
-    query.addBindValue(presentation.zValue()); 
-    if (presentation.widgetId() != -1) {
-        query.addBindValue(presentation.widgetId());
-    }    
-    query.addBindValue(presentation.id());
+    if (query.prepare(statement)) {
+        query.addBindValue(data.key);
+        query.addBindValue(data.x);
+        query.addBindValue(data.y);
+        query.addBindValue(data.width);
+        query.addBindValue(data.height);
+        query.addBindValue(data.zValue);
+        query.addBindValue(data.widgetId);
+        return query.exec();
+    }
 
-    return query.exec();
+    return false;
 }
 
 /*!
-    Delete widget \a presentation width given \a id. 
+
 */
-bool HsDatabase::deleteWidgetPresentation(int id)
+bool HsDatabase::deleteWidgetPresentation(int widgetId, const QString &key)
 {
-    QSqlDatabase db = database();
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    QString queryString = "DELETE FROM WidgetPresentations "
-                          "WHERE Id = ?";
-
-    QSqlQuery query(db);
+    QString statement =
+        "DELETE FROM WidgetPresentations "
+        "WHERE key = ? AND widgetId = ?";
 
-    query.prepare(queryString);
-    query.addBindValue(id);
+    if (query.prepare(statement)) {
+        query.addBindValue(key);
+        query.addBindValue(widgetId);
+        return query.exec();
+    }
 
-    return query.exec();
+    return false;
 }
 
 /*!
-    Set widget preference \a value for given \a key for widget with given \a widgetId 
+
 */
-bool HsDatabase::setWidgetPreferenceForKey(int widgetId, 
-                                           const QString &key, 
-                                           const QString &value)
+bool HsDatabase::widgetPreferences(int widgetId, QVariantHash &data)
 {
-    QSqlDatabase db = database();
-
-    QString queryString = "SELECT COUNT() "
-                          "FROM WidgetPreferences "
-                          "WHERE WidgetId = ? "
-                          "AND Key = ?";
-
-    QSqlQuery query(db);
-
-    query.prepare(queryString);
-    query.addBindValue(widgetId);
-    query.addBindValue(key);
-
-    if (!query.exec() || !query.next()) {
+    if (!checkConnection()) {
         return false;
     }
 
-    int count = query.value(0).toInt();
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QString statement =
+        "SELECT key, value "
+        "FROM WidgetPreferences "
+        "WHERE widgetId = ?";
 
-    if (count) {
-        queryString = "UPDATE WidgetPreferences "
-                      "SET Value = :value "
-                      "WHERE WidgetId = :widgetId "
-                      "AND Key = :key";
-    } else {
-        queryString = "INSERT INTO WidgetPreferences "
-                      "(WidgetId, Key, Value) "
-                      "VALUES(:widgetId, :key, :value)";
+    if (query.prepare(statement)) {
+        query.addBindValue(widgetId);
+        if (query.exec()) {
+            data.clear();
+            while (query.next()) {
+                data.insert(query.value(0).toString(), 
+                            query.value(1));
+            }
+            return true;
+        }
     }
 
-    query.prepare(queryString);
-    query.bindValue(":widgetId", widgetId);
-    query.bindValue(":value", value);
-    query.bindValue(":key", key);
-
-    return query.exec();
+    return false;
 }
 
 /*!
-    Returns widget preference \a value for given \a key for widget with given \a widgetId 
+
 */
-bool HsDatabase::widgetPreferenceForKey(int widgetId, 
-                                        const QString &key, 
-                                        QString &value)
+bool HsDatabase::widgetPreference(int widgetId, const QString &key, QVariant &value)
 {
-    QSqlDatabase db = database();
-
-    QString queryString = "SELECT Value "
-                          "FROM WidgetPreferences "
-                          "WHERE WidgetId = ? "
-                          "AND Key = ?";
-
-    QSqlQuery query(db);
-
-    query.prepare(queryString);
-    query.addBindValue(widgetId);
-    query.addBindValue(key);
-
-    if (!query.exec() || !query.next()) {
+    if (!checkConnection()) {
         return false;
     }
 
-    value = query.value(0).toString();
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
 
-    return true;
-}
+    QString statement =
+        "SELECT value "
+        "FROM WidgetPreferences "
+        "WHERE key = ? AND widgetId = ?";
 
-/*!
-    Store widget \a preferences for given \a widgetId. Returns true
-    if successfull.
-*/
-bool HsDatabase::setWidgetPreferences(int widgetId, const QVariantMap &preferences)
-{
-    QSqlDatabase db = database();
-    QSqlQuery query(db);
-
-    QList<QString> deleteNames = preferences.keys(QVariant());
-    QVariantMap insertOrReplaceMap(preferences);
-    foreach (QString deleteName, deleteNames) {
-        insertOrReplaceMap.remove(deleteName);
+    if (query.prepare(statement)) {
+        query.addBindValue(key);
+        query.addBindValue(widgetId);
+        if (query.exec() && query.next()) {
+            value = query.value(0);
+            return true;
+        }
     }
 
-    if (!deleteNames.isEmpty()) {
-        QString queryString = "DELETE FROM WidgetPreferences "
-                              "WHERE WidgetId = ? "
-                              "AND Key = ?";
+    return false;
+}
+ 
+/*!
+
+*/
+bool HsDatabase::setWidgetPreferences(int widgetId, const QVariantHash &data)
+{
+    if (!checkConnection()) {
+        return false;
+    }
+
+    QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+    QList<QString> deleteKeys = data.keys(QVariant());
+    QVariantHash insertOrReplaceData(data);
+    foreach (QString key, deleteKeys) {
+        insertOrReplaceData.remove(key);
+    }
+
+    if (!deleteKeys.isEmpty()) {
+        QString statement = 
+            "DELETE FROM WidgetPreferences "
+            "WHERE key = ? AND widgetId = ?";
         
-        if (query.prepare(queryString)) {
-            query.addBindValue(toVariantList(widgetId, deleteNames.count()));
-            query.addBindValue(toVariantList(deleteNames));
+        if (query.prepare(statement)) {
+            query.addBindValue(toVariantList(deleteKeys));
+            query.addBindValue(toVariantList(widgetId, deleteKeys.count()));
             if (!query.execBatch()) {
                 return false;
             }
@@ -740,15 +727,16 @@
         }
     }
 
-    if (!insertOrReplaceMap.isEmpty()) {
-        QString queryString = "REPLACE INTO WidgetPreferences "
-                              "(WidgetId, Key, Value) "
-                              "VALUES (?, ?, ?)";
+    if (!insertOrReplaceData.isEmpty()) {
+        QString statement = 
+            "REPLACE INTO WidgetPreferences "
+            "(key, value, widgetId) "
+            "VALUES (?, ?, ?)";
             
-        if (query.prepare(queryString)) {
-            query.addBindValue(toVariantList(widgetId, insertOrReplaceMap.count()));
-            query.addBindValue(toVariantList(insertOrReplaceMap.keys()));
-            query.addBindValue(toVariantList(insertOrReplaceMap.values()));
+        if (query.prepare(statement)) {
+            query.addBindValue(toVariantList(insertOrReplaceData.keys()));
+            query.addBindValue(toVariantList(insertOrReplaceData.values()));
+            query.addBindValue(toVariantList(widgetId, insertOrReplaceData.count()));
             if (!query.execBatch()) {
                 return false;
             }
@@ -759,198 +747,44 @@
 
     return true;
 }
-
+ 
 /*!
-    Fetch widget \a preferences based on given \a widgetId. Returns
-    true if successfull.
+    Sets the database instance. The existing instance
+    will be deleted.
 */
-bool HsDatabase::widgetPreferences(int widgetId, QVariantMap &preferences)
+void HsDatabase::setInstance(HsDatabase *instance)
 {
-    QSqlDatabase db = database();
-    QSqlQuery query(db);
-    
-    QString queryString = "SELECT Key, Value "
-                          "FROM WidgetPreferences "
-                          "WHERE WidgetId = ?";
-
-    query.prepare(queryString);
-    query.addBindValue(widgetId);
-  
-    if (query.exec()) {
-        while (query.next()) {
-            preferences.insert(query.value(0).toString(), 
-                               query.value(1));
-        }
-    } else {
-        return false;
-    }
-    return true;
+    mInstance.reset(instance);
 }
 
 /*!
-    Returns instance \a ids of the widget identified by the given \a uri
+    Returns the database instance.
 */
-bool HsDatabase::widgetIds(const QString &uri, QList<int> &ids)
+HsDatabase *HsDatabase::instance()
 {
-    QSqlDatabase db = database();
-    QSqlQuery query(db);
-
-    QString queryString = "SELECT Id "
-                          "FROM Widgets "
-                          "WHERE Uri = ?";
-    
-    query.prepare(queryString);
-    query.addBindValue(uri);
-
-    if (!query.exec() || !query.next()) {
-        return false;
-    }
-
-    ids << query.value(0).toInt();
-    while (query.next()) {
-        ids << query.value(0).toInt();        
-    }
-
-    return true;
-}
-
-/*!
-    Constructor
-*/
-HsDatabase::HsDatabase()
-    : QObject()
-{
-}
-/*!
-    Open database from given \a databaseName
-*/
-bool HsDatabase::openDatabase(const QString &databaseName)
-{
-    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", DATABASE_CONNECTION_NAME);
-    db.setDatabaseName(databaseName);
-    if (!db.open()) {
-        HSDEBUG( db.lastError().text().toLatin1() );
-        return false;
-    }
-    return true;
+    return mInstance.data();
 }
 
 /*!
-    Parses \a page data from given \a query. Include child 
-    data when \a getChildren is set to true.
+    Returns the current database instance. Callers of this 
+    function take ownership of the instance. The current 
+    database instance will be reset to null.    
 */
-bool HsDatabase::parsePage(const QSqlQuery &query, 
-                           bool getChildren, 
-                           HsPageData &page)
+HsDatabase *HsDatabase::takeInstance()
 {
-    HsPageData temp;
-
-    temp.setId(columnValue(query, "Id").toInt());    
-    temp.setIndex(columnValue(query, "PageIndex").toInt());    
-        
-    if (getChildren) {
-        QSqlDatabase db = database();
-        QSqlQuery q(db);        
-        
-        QString queryString = "SELECT * "
-                              "FROM Widgets "
-                              "WHERE PageId = ?";
-        
-        q.prepare(queryString);
-        q.addBindValue(temp.id());
-
-        if (!q.exec()) {
-            return false;
-        }
-
-        while (q.next()) {
-            HsWidgetData widget;
-            if (!parseWidget(q, true, widget)) {
-                return false;
-            }
-            temp.widgets() << widget;
-        }
-    }
-
-    page = temp;
-
-    return true;
+    return mInstance.take();
+}
+  
+/*!
+    Checks the connection validity. Returns true if the 
+    connection is valid.
+*/
+bool HsDatabase::checkConnection() const
+{
+    return QSqlDatabase::database(mConnectionName).isValid();
 }
 
 /*!
-    Parses \a widget data from given \a query. Include child data 
-    when \a getChildren is set to true.
+    Points to the database instance.
 */
-bool HsDatabase::parseWidget(const QSqlQuery &query, 
-                             bool getChildren, 
-                             HsWidgetData &widget)
-{
-    HsWidgetData temp;
-
-    temp.setId(columnValue(query, "Id").toInt());
-    temp.setUri(columnValue(query, "Uri").toString());
-    temp.setPageId(columnValue(query, "PageId").toInt());
-
-    if (getChildren) {
-        QSqlDatabase db = database();
-        QSqlQuery q(db);
-        
-        QString queryString = "SELECT * "
-                              "FROM WidgetPresentations "
-                              "WHERE WidgetId = ?";
-
-        q.prepare(queryString);
-        q.addBindValue(temp.id());
-
-        if (!q.exec()) {
-            return false;
-        }
-
-        while (q.next()) {
-            HsWidgetPresentationData presentation;
-            if (!parseWidgetPresentation(q, presentation)) {
-                return false;
-            }
-            temp.presentations() << presentation;
-        }
-    }
-
-    widget = temp;
-
-    return true;
-}
-
-/*!
-    Parses widget \a presentation data from given SQL \a query.
-*/
-bool HsDatabase::parseWidgetPresentation(const QSqlQuery &query, 
-                                         HsWidgetPresentationData &presentation)
-{
-    presentation.setId(columnValue(query, "Id").toInt());
-    presentation.setKey(columnValue(query, "Key").toString());
-    presentation.setPosition(QPointF(columnValue(query, "XPosition").toDouble(),
-                                     columnValue(query, "YPosition").toDouble()));
-    presentation.setSize(QSizeF(columnValue(query, "Width").toDouble(),
-                                columnValue(query, "Height").toDouble()));    
-    presentation.setZValue(columnValue(query, "ZValue").toDouble());
-    presentation.setWidgetId(columnValue(query, "WidgetId").toInt());
-
-    return true;
-}
-
-/*!
-    Parses column value with given \a columnName from given SQL \a query.
-*/
-QVariant HsDatabase::columnValue(const QSqlQuery &query, 
-                                 const QString &columnName) const
-{
-    return query.value(query.record().indexOf(columnName));
-}
-
-/*!
-    Returns database connection
-*/
-QSqlDatabase HsDatabase::database() const
-{
-    return QSqlDatabase::database(DATABASE_CONNECTION_NAME);
-}
+QScopedPointer<HsDatabase> HsDatabase::mInstance(0);
--- a/homescreenapp/hsdomainmodel/src/hsipcchannel.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#include <QDataStream>
-#include <QDebug> 
-#include "hsipcchannelclient.h"
-
-/*!
-    \class HsIpcChannel
-    \ingroup group_hsutils
-    \brief Homescreen ipc transport channel.
-    
-    Responsible for reading and writing ipc messages. Uses QLocalSocket for transport 
-    mechanism. 
-
-*/
-HsIpcChannel::~HsIpcChannel()
-{
-}
-
-bool HsIpcChannel::isConnected() const
-{
-    if(!mSocket)return false;
-    return mSocket->state() == QLocalSocket::ConnectedState;
-}
-
-bool HsIpcChannel::sendMessage(const QVariantMap &message)
-{
-    if (!isConnected()) {
-        return false;
-    }
-
-    QByteArray byteArray;
-    QDataStream out(&byteArray, QIODevice::WriteOnly);
-    out.setVersion(QDataStream::Qt_4_6);
-    out << (quint32)0; //fill size placeholder
-    out << message;
-    out.device()->seek(0); // now write right value to it
-    out << (quint32)(byteArray.size() - sizeof(quint32));
-
-    mSocket->write(byteArray);
-
-    return true;
-}
-
-bool HsIpcChannel::waitForSendMessage(const QVariantMap &message)
-{
-    if (!isConnected()) {
-        return false;
-    }
-    QByteArray byteArray;
-    QDataStream out(&byteArray, QIODevice::WriteOnly);
-    out.setVersion(QDataStream::Qt_4_6);
-    out << (quint32)0; //fill size placeholder
-    out << message;
-    out.device()->seek(0); // now write right value to it
-    out << (quint32)(byteArray.size() - sizeof(quint32));
-
-    mSocket->write(byteArray);
-    bool ok = true;
-    while(mSocket->bytesToWrite() && ok){
-        ok = mSocket->waitForBytesWritten(1000);// timeout in 1sec
-    }
-    
-    return ok;  
-}
-
-bool HsIpcChannel::waitForReadMessage(QVariantMap &message)
-{
-    if (!isConnected()) {
-        return false;
-    }
-   
-    QDataStream in(mSocket);
-    in.setVersion(QDataStream::Qt_4_6);
-    quint32 blockSize = 0;
-    bool ok = mSocket->waitForReadyRead();
-    while( ok && mSocket->bytesAvailable() < (int)sizeof(quint32) ){
-        ok = mSocket->waitForReadyRead(1000);
-    }
-    if(!ok){
-        return false;
-    }
-    in >> blockSize;
-
-    while(ok && mSocket->bytesAvailable() < blockSize){
-        ok = mSocket->waitForReadyRead(1000);
-    }
-    
-    if(!ok){
-        return false;
-    }
-    
-    // now we have all data
-    message.clear();
-    in >> message;
-    return true;
-}
-
-void HsIpcChannel::onReadyRead()
-{
-    QDataStream in(mSocket);
-    in.setVersion(QDataStream::Qt_4_6);
-
-    if (mBlockSize == 0) {
-        if (mSocket->bytesAvailable() < (int)sizeof(quint32)){
-            return;
-        }
-        in >> mBlockSize;
-    } 
-
-    if (mSocket->bytesAvailable() < mBlockSize){
-        return;
-    }
-    mBlockSize = 0;
-    // now we have all data
-    QVariantMap message;
-    in >> message;
-    
-    emit messageReceived(message);
-}
-
-void HsIpcChannel::onError(QLocalSocket::LocalSocketError socketError)
-{
-    Q_UNUSED(socketError);
-    emit connectionError();
-}
-
-
-
-HsIpcChannel::HsIpcChannel(QObject *parent) 
-    : QObject(parent),mBlockSize(0),mSocket(0)
-{
-    
-}
--- a/homescreenapp/hsdomainmodel/src/hsipcchannelclient.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-#include "hsipcchannelclient.h"
-
-/*!
-    \class HsIpcChannelClient
-    \ingroup group_hsutils
-    \brief Homescreen ipc transport channel client api.
-    
-    Client side communication channel management. 
-
-*/
-HsIpcChannelClient::HsIpcChannelClient(QObject *parent)
-: HsIpcChannel(parent)
-{
-}
-
-HsIpcChannelClient::~HsIpcChannelClient()
-{
-    delete mSocket;
-}
-
-bool HsIpcChannelClient::openConnection(const QString &serverName)
-{
-    closeConnection();
-    delete mSocket;
-    mSocket = NULL;
-    mSocket = new QLocalSocket;
-    connect(mSocket, SIGNAL(connected()), SLOT(onConnected()));
-    connect(mSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), 
-            SLOT(onError(QLocalSocket::LocalSocketError)));
-
-    mSocket->connectToServer(serverName);
-    
-    return true;
-}
-bool HsIpcChannelClient::waitForOpenConnection(const QString &serverName)
-{
-    delete mSocket;
-    mSocket = NULL;
-    mSocket = new QLocalSocket;
-    connect(mSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), 
-            SLOT(onError(QLocalSocket::LocalSocketError)));
-
-    mSocket->connectToServer(serverName);
-    return mSocket->waitForConnected(1000);
-}
-
-void HsIpcChannelClient::closeConnection()
-{
-    Q_ASSERT(mSocket);
-    mSocket->disconnectFromServer();
-}
-
-bool HsIpcChannelClient::waitForCloseConnection()
-{
-    Q_ASSERT(mSocket);
-    mSocket->disconnectFromServer();
-    return mSocket->waitForDisconnected(1000);
-}
-
-
-
-void HsIpcChannelClient::onConnected()
-{
-    disconnect(mSocket,SIGNAL(connected()),this, SLOT(onConnected()) );
-  
-    connect(mSocket, SIGNAL(readyRead()), SLOT(onReadyRead()));
-    connect(mSocket, SIGNAL(disconnected()), SIGNAL(disconnected()));
-    emit connectionEstablished();
-}
--- a/homescreenapp/hsdomainmodel/src/hsipcchannelhost.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-#include <QDebug>
-#include "hsipcchannelhost.h"
-
-/*!
-    \class HsIpcChannelHost
-    \ingroup group_hsutils
-    \brief Homescreen ipc transport channel server api.
-    
-    Server side communication channel management. 
-
-*/
-
-HsIpcChannelHost::HsIpcChannelHost(QLocalSocket *socket,QObject *parent)
-    : HsIpcChannel(parent)
-{
-    Q_ASSERT(socket);
-
-    mSocket = socket;
-    connect(mSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), 
-            SLOT(onError(QLocalSocket::LocalSocketError)));
-    connect(mSocket, SIGNAL(readyRead()), SLOT(onReadyRead()));
-    connect(mSocket, SIGNAL(disconnected()), SIGNAL(disconnected()));
-    qDebug()<< "HsIpcChannelHost::HsIpcChannelHost(): " << (int)this;
-}
-
-HsIpcChannelHost::~HsIpcChannelHost()
-{
-    qDebug()<< "HsIpcChannelHost::~HsIpcChannelHost(): " << (int)this;
-    delete mSocket;
-}
-
-void HsIpcChannelHost::closeConnection()
-{
-    mSocket->close();
-}
\ No newline at end of file
--- a/homescreenapp/hsdomainmodel/src/hsipcconnectiondispatcher.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-#include "hsipcconnectiondispatcher.h"
-#include "hscontentpublishhandler.h"
-#include "hsipcserver.h"
-#include "hsipcchannelhost.h"
-
-/*!
-    \class HsIpcConnectionDispatcher
-    \ingroup group_hsutils
-    \brief Dispatch ipc connections.
-    
-    Creates homescreen ipc communication server and dispatch ipc connections 
-    asynchronously for connection handlers. 
-
-*/
-
-HsIpcConnectionDispatcher::HsIpcConnectionDispatcher(
-    const QString &connectionName,QObject *parent)
-    : QObject(parent),
-    mConnectionName(connectionName),
-    mIpcServer(new HsIpcServer())
-{
-    mIpcServer->setParent(this);
-
-}
-
-HsIpcConnectionDispatcher::~HsIpcConnectionDispatcher()
-{
-   
-}
-
-bool HsIpcConnectionDispatcher::start()
-{
-    if(!mIpcServer->startServer(mConnectionName)){
-        return false;
-    }
-    connect(mIpcServer, SIGNAL(newConnection()),
-        SLOT(onConnectionEstablished()));
-    return true;
-}
-void HsIpcConnectionDispatcher::stop()
-{
-    mIpcServer->stopServer();
-}
-
-void HsIpcConnectionDispatcher::onConnectionEstablished()
-{
-    QScopedPointer<HsIpcChannelHost> newChannel(mIpcServer->takeConnection());
-    new HsContentPublishHandler(newChannel.data());
-    newChannel.take();
-}
-
--- a/homescreenapp/hsdomainmodel/src/hsipcserver.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#include <QLocalServer>
-#include <QDataStream>
-#include <QDebug>
-#include "hsipcserver.h"
-#include "hsipcchannelhost.h"
-
-/*!
-    \class HsIpcServer
-    \ingroup group_hsutils
-    \brief Homescreen ipc server api.
-    
-    Server to host ipc communication. Signals when new
-    connection arrives.
-
-*/
-
-HsIpcServer::HsIpcServer(QObject *parent)
-    : QObject(parent),
-      mServer(0)
-{
-}
-
-HsIpcServer::~HsIpcServer()
-{
-    stopServer();
-}
-
-bool HsIpcServer::startServer(const QString &serverName)
-{
-    stopServer();
-    QLocalServer::removeServer(serverName);
-    mServer = new QLocalServer;
-    connect(mServer, SIGNAL(newConnection()), SLOT(onNewConnection()));
-    if(!mServer->listen(serverName)){
-        qDebug()<< "HsIpcServer::startServer listen failed";
-        delete mServer;
-        mServer = NULL;
-        return false;
-    }
-    return true;
-}
-
-
-void HsIpcServer::stopServer()
-{
-    if (mServer) {
-        mServer->close();
-        delete mServer;
-        mServer = NULL;
-       
-    }
-    while(!mConnections.isEmpty()){
-        delete mConnections.dequeue();    
-        }
-   
-}
-HsIpcChannelHost* HsIpcServer::takeConnection()
-{
-    if(!mConnections.isEmpty()){
-        return mConnections.dequeue();
-    }
-    return 0;
-}
-
-void HsIpcServer::onNewConnection()
-{
-    QLocalSocket* socket = mServer->nextPendingConnection();
-    if (socket) {
-        qDebug() << "HsIpcServer::onNewConnection";
-        QScopedPointer<HsIpcChannelHost> channel( new HsIpcChannelHost(socket) );
-        mConnections.enqueue(channel.data());
-        channel.take();
-        emit newConnection();
-    }
-}
--- a/homescreenapp/hsdomainmodel/src/hspage.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hspage.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -16,16 +16,15 @@
 */
 
 #include <QPainter>
+#include <QRectF>
 #include <QGraphicsLinearLayout>
 #include <HbInstance>
 
+#include "hsdomainmodeldatastructures.h"
 #include "hspage.h"
 #include "hsscene.h"
 #include "hsdatabase.h"
 #include "hswidgethost.h"
-#include "hswidgetdata.h"
-#include "hswidgetpresentationdata.h"
-#include "hspagedata.h"
 #include "hswallpaper.h"
 #include "hswidgetpositioningonwidgetadd.h"
 
@@ -51,6 +50,9 @@
     setFlag(QGraphicsItem::ItemHasNoContents);
     setSizePolicy(QSizePolicy(QSizePolicy::Ignored, 
                               QSizePolicy::Ignored));
+                              
+    mStartPoint["portrait"] = QPointF();                              
+    mStartPoint["landscape"] = QPointF();                              
 }
 
 /*!
@@ -81,35 +83,31 @@
 */
 bool HsPage::load()
 {
-    HsDatabase *db = HsDatabase::instance();
-    Q_ASSERT(db);
+    if (mDatabaseId < 0) {
+        return false;
+    }
 
-    HsPageData pageData;
-    if (!db->page(mDatabaseId, pageData, true)) {
+    HsDatabase *db = HsDatabase::instance();
+    
+    QList<HsWidgetData> datas;
+    if (!db->widgets(mDatabaseId, datas)) {
         return false;
     }
 
-    QList<HsWidgetData> widgetDatas = pageData.widgets();
-    foreach (HsWidgetData widgetData, widgetDatas) {
-        HsWidgetHost *widget = new HsWidgetHost(widgetData.id());
-        connectWidget(widget);
-        widget->load();
-
-		if (!widget->isValid()) {
-			qDebug() << "HsPage: Widget loading failed.";
-			continue;
+    foreach (HsWidgetData data, datas) {
+        QScopedPointer<HsWidgetHost> widget(new HsWidgetHost(data.id));
+        if(!widget->load() || !widget->isValid()) {
+            continue;
 		}
-
+        connectWidget(widget.data());
         widget->setPage(this);
-        mWidgets << widget;
+        widget->initializeWidget();
+        widget->showWidget();
+        mWidgets.append(widget.data());
+        widget->setParentItem(this);
+        widget.take(); // now this page owns widget
     }
 
-    foreach (HsWidgetHost *widget, mWidgets) {
-        widget->initializeWidget();
-        widget->showWidget();
-        widget->setParentItem(this);
-    }
-    
     return true;    
 }
 
@@ -171,17 +169,16 @@
 
     HsWidgetPresentationData presentation;
     if (!widgetHost->widgetPresentationData(key, presentation)) {
-        presentation.setKey(key);
-        presentation.setPosition(QPointF());
+        presentation.key = key;
+        presentation.setPos(QPointF());
         presentation.setSize(widgetHost->preferredSize());
-        presentation.setZValue(0);       
+        presentation.zValue = 0;
         widgetHost->setWidgetPresentationData(presentation);
     }
 
     widgetHost->hide();
-    widgetHost->setGeometry(QRectF(presentation.position(), 
-                                   presentation.size()));
-    widgetHost->setZValue(presentation.zValue());   
+    widgetHost->setGeometry(presentation.geometry());
+    widgetHost->setZValue(presentation.zValue);
     
     connectWidget(widgetHost);
     mNewWidgets << widgetHost;
@@ -194,29 +191,39 @@
 */
 void HsPage::layoutNewWidgets()
 {
-    QList<QRectF> oldWidgetGeometries;
+    if (mNewWidgets.isEmpty()) {
+        return;
+    }
+    
+    QString key = HsScene::orientation() == Qt::Horizontal ? 
+        "landscape" : "portrait";
 
-    foreach(HsWidgetHost *widget, mNewWidgets) {
-        oldWidgetGeometries << widget->rect();
-    }
+    QList<QRectF> rects;
 
-    QList<QRectF> newWidgetGeometries = 
-        HsWidgetPositioningOnWidgetAdd::instance()->convert(
-        rect().adjusted(10, 10, -10, -10),
-        oldWidgetGeometries);
-
+    foreach (HsWidgetHost *newWidget, mNewWidgets) {
+        rects << newWidget->rect();
+    }
+    
+    HsWidgetPositioningOnWidgetAdd *algorithm = 
+        HsWidgetPositioningOnWidgetAdd::instance();
+   
+    QList<QRectF> calculatedRects = 
+        algorithm->convert(HsScene::mainWindow()->layoutRect(), rects, mStartPoint[key]);
+    
     updateZValues();
 
-    HsWidgetHost *widget = NULL;
-    for(int i = 0; i < mNewWidgets.count(); ++i) {  
-        widget = mNewWidgets[i];
-        widget->setGeometry(newWidgetGeometries[i]);
+    HsWidgetHost *widget = 0;
+    for (int i = 0; i < mNewWidgets.count(); ++i) {
+        widget = mNewWidgets.at(i);
+        widget->setGeometry(calculatedRects.at(i));
         widget->setWidgetPresentation();
         widget->setPage(this);
         widget->setParentItem(this);
         widget->show();
-        mWidgets << widget;
     }
+    mStartPoint[key] = widget->geometry().bottomRight();
+    mWidgets << mNewWidgets;
+    mNewWidgets.clear();
 }
 
 /*!
@@ -229,24 +236,18 @@
 
 bool HsPage::deleteFromDatabase()
 {
-    HsDatabase *db = HsDatabase::instance();
-    Q_ASSERT(db);
-
-    db->transaction();
-
+    HsDatabase *db = HsDatabase::instance();    
+    
     foreach (HsWidgetHost *widget, mWidgets) {
-        if (!widget->deleteFromDatabase()) {
-            db->rollback();
+        if (!widget->deleteFromDatabase()) {            
             return false;
         }
     }
 
     if (!db->deletePage(mDatabaseId))  {
-        db->rollback();
         return false;
     }
 
-    db->commit();
     return true;
 }
 
@@ -274,39 +275,79 @@
 
 bool HsPage::updateZValues()
 {
-    if (mWidgets.isEmpty()) {
-        return true;
-    }
-    
-    QMultiMap<qreal, HsWidgetHost *> map;
-    foreach (HsWidgetHost *widget, mWidgets) {
-        map.insert(widget->zValue(), widget);
-    }
-    
-    QList<HsWidgetHost *> sortedWidgets = map.values();
-            
-    HsWidgetHost *activeWidget = HsScene::instance()->activeWidget();    
-    if (sortedWidgets.contains(activeWidget)) {
-        sortedWidgets.removeOne(activeWidget);
-        sortedWidgets.append(activeWidget);        
+    int z = 0;
+
+    if (!mWidgets.isEmpty()) {
+        QMultiMap<qreal, HsWidgetHost *> map;
+        foreach (HsWidgetHost *widget, mWidgets) {
+            map.insert(widget->zValue(), widget);
+        }
+        
+        QList<HsWidgetHost *> sortedWidgets = map.values();
+                
+        HsWidgetHost *activeWidget = HsScene::instance()->activeWidget();    
+        if (sortedWidgets.contains(activeWidget)) {
+            sortedWidgets.removeOne(activeWidget);
+            sortedWidgets.append(activeWidget);        
+        }
+        
+        foreach (HsWidgetHost *widget, sortedWidgets) {
+            widget->setZValue(z++);
+            widget->setWidgetPresentation();
+        }
     }
 
-    int z = 0;
-    foreach (HsWidgetHost *widget, sortedWidgets) {
-        widget->setZValue(z++);
-        widget->setWidgetPresentation();
-    }
-
-    foreach (HsWidgetHost *widget, mNewWidgets) {
-        widget->setZValue(z++);
-        widget->setWidgetPresentation();
+    if (!mNewWidgets.isEmpty()) {
+        foreach (HsWidgetHost *widget, mNewWidgets) {
+            widget->setZValue(z++);
+            widget->setWidgetPresentation();
+        }
     }
 
     return true;
 }
+
+HsPage *HsPage::createInstance(const HsPageData &pageData)
+{
+    HsDatabase *db = HsDatabase::instance();
+    Q_ASSERT(db);
+    
+    HsPageData data(pageData);    
+    if (db->insertPage(data)) {
+        HsPage *page = new HsPage;
+        page->setDatabaseId(data.id);
+        return page;
+    }
+
+    return 0;
+}
+
+/*!
+    Calls onShow() for contained widgets.
+*/
+void HsPage::showWidgets()
+{
+    foreach (HsWidgetHost *widget, mWidgets) {
+        if (widget->parentItem() == this) {
+            widget->showWidget();
+        }
+    }
+}
+ 
+/*!
+    Calls onHide() for contained widgets.
+*/
+void HsPage::hideWidgets()
+{
+    foreach (HsWidgetHost *widget, mWidgets) {
+        if (widget->parentItem() == this) {
+            widget->hideWidget();
+        }
+    }
+}
+
 /*!
     Propogate online state to widgets.
-
 */
 void HsPage::setOnline(bool online)
 {
@@ -318,21 +359,6 @@
     }
 }
 
-HsPage *HsPage::createInstance(const HsPageData &pageData)
-{
-    HsDatabase *db = HsDatabase::instance();
-    Q_ASSERT(db);
-    
-    HsPageData data(pageData);    
-    if (!db->insertPage(data)) {
-        return 0;
-    }
-
-    HsPage *page = new HsPage;
-    page->setDatabaseId(data.id());
-    return page;
-}
-
 void HsPage::connectWidget(HsWidgetHost *widget)
 {
     connect(widget, SIGNAL(widgetFinished(HsWidgetHost*)),
@@ -346,14 +372,13 @@
 
 void HsPage::onWidgetFinished(HsWidgetHost *widget)
 {
-    if (mNewWidgets.contains(widget)) {
-        mNewWidgets.removeOne(widget);
-    } else if (mWidgets.contains(widget)) {
-        mWidgets.removeOne(widget);        
-    } else {
-        return;
+    Q_ASSERT(widget);
+    // It can be in new widget list if we haven't layouted it yet
+    // or layouted new widget and widget list
+    if (!mNewWidgets.removeOne(widget)) {
+        mWidgets.removeOne(widget);
     }
-
+   
     disconnectWidget(widget);
     widget->uninitializeWidget();
     widget->deleteFromDatabase();
--- a/homescreenapp/hsdomainmodel/src/hspagedata.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  HsPage meta data.
-*
-*/
-
-#include "hspagedata.h"
-
-/*!
-    \class HsPageData
-    \ingroup group_hsdatamodel
-    \brief Contains page metadata.
-
-    Used by content store and content service for
-    holding page metadata.
-*/
-
-
-/*!
-    \fn HsPageData::HsPageData()
-
-    Constructor
-*/
-HsPageData::HsPageData()
-    : mId(-1),
-      mIndex(-1)
-{
-
-}
-
-/*!
-    \fn HsPageData::~HsPageData()
-
-    Destructor
-*/
-HsPageData::~HsPageData()
-{
-
-}
-
-/*!
-    \fn void HsPageData::setId(int aId)
-
-    Set page \a pageId
-*/
-void HsPageData::setId(int pageId)
-{
-	mId = pageId;
-}
-
-/*!
-    \fn int HsPageData::id() const
-
-    Return page id
-*/
-int HsPageData::id() const
-{
-    return mId;
-}
-
-/*!
-    \fn void HsPageData::setIndex(int index)
-
-    Set page \a index i.e it's appearance order
-*/
-void HsPageData::setIndex(int index)
-{
-	mIndex = index;
-}
-
-/*!
-    \fn int HsPageData::index() const
-
-    Return page index
-*/
-int HsPageData::index() const
-{
-	return mIndex;
-}
-
-/*!
-    \fn QList<HsWidgetData> HsPageData::widgets() const
-
-    Get widgets belonging to this page
-*/
-QList<HsWidgetData> HsPageData::widgets() const
-{
-	return mWidgets; 
-}
-
-/*!
-    \fn QList<HsWidgetData> &HsPageData::widgets()
-
-    Get modifiable list of widgets belonging to this page
-*/
-QList<HsWidgetData> &HsPageData::widgets()
-{
-    return mWidgets; 
-}
--- a/homescreenapp/hsdomainmodel/src/hsscene.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hsscene.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -16,62 +16,50 @@
 */
 
 #include <HbInstance>
+#include "hsdomainmodeldatastructures.h"
 #include "hsscene.h"
-#include "hsscene_p.h"
-#include "hsscenedata.h"
 #include "hspage.h"
-#include "hspagedata.h"
 #include "hswidgethost.h"
 #include "hsdatabase.h"
 #include "hswallpaper.h"
-#ifndef Q_OS_SYMBIAN
-#include "hsipcconnectiondispatcher.h"
-#endif
+#include "hsdatabase.h"
+
 
-HsScenePrivate::HsScenePrivate()
-    : mDatabaseId(-1),
-      mIsOnline(true),
-      mWallpaper(0),
-      mActivePage(0),
-      mActiveWidget(0)
-#ifndef Q_OS_SYMBIAN
-      ,mIpcConnectionDispatcher(0)
-#endif
-{
-    mWallpaper = new HsWallpaper;
-}
- 
-HsScenePrivate::~HsScenePrivate()
+/*!
+    Destructor.
+*/
+HsScene::~HsScene()
 {
     delete mWallpaper;
     qDeleteAll(mPages);
 }
-    
-HsScene::~HsScene()
+
+/*!
+    Return database id.
+*/
+int HsScene::databaseId() const
 {
+    return mDatabaseId;
 }
 
-int HsScene::databaseId() const
-{
-    return mD->mDatabaseId;
-}
-
+/*!
+    Load scene from database.
+*/
 bool HsScene::load()
 {
     HsDatabase *db = HsDatabase::instance();
-    Q_ASSERT(db);
 
     HsSceneData sceneData;
     if (!db->scene(sceneData)) {
         return false;
     }
 
-    if (sceneData.portraitWallpaper().isEmpty()) {
-        mD->mWallpaper->setImagesById();
+    if (sceneData.portraitWallpaper.isEmpty()) {
+        mWallpaper->setImagesById();
     } else {
-        mD->mWallpaper->setImagesByPaths(
-            sceneData.landscapeWallpaper(), 
-            sceneData.portraitWallpaper());
+        mWallpaper->setImagesByPaths(
+            sceneData.landscapeWallpaper, 
+            sceneData.portraitWallpaper);
     }
 
     QList<HsPageData> pageDatas;
@@ -79,116 +67,197 @@
         return false;
     }
     
-    HsPage *page = 0;
     foreach (HsPageData pageData, pageDatas) {
-        page = new HsPage;
-        page->setDatabaseId(pageData.id());
+        HsPage *page = new HsPage;
+        page->setDatabaseId(pageData.id);
         if (page->load()) {
-            mD->mPages << page;
+            mPages.append(page);
         } else {
-            qDebug() << "HsScene: Page loading failed.";
-            // TODO
+            delete page;
+            continue;
+        }
+        if (pageData.id == sceneData.defaultPageId) {
+            mActivePage = page;
+            mActivePage->setRemovable(false);
         }
     }
-
-    int defaultPageIndex = sceneData.defaultPage().index();        
-    if(defaultPageIndex > -1){
-        mD->mActivePage = mD->mPages[defaultPageIndex];
-        mD->mActivePage->setRemovable(false);
-    }
-#ifndef Q_OS_SYMBIAN
-    mD->mIpcConnectionDispatcher = new HsIpcConnectionDispatcher("hs_content_publish");
-    mD->mIpcConnectionDispatcher->setParent(this);
-    return mD->mIpcConnectionDispatcher->start();
-#endif    
+   
+    mMaximumPageCount = sceneData.maximumPageCount;
+	return true;
 }
 
+/*!
+    Return wallpaper. 
+*/
 HsWallpaper *HsScene::wallpaper() const
 {
-    return mD->mWallpaper;
+    return mWallpaper;
 }
 
+/*!
+   Return pages array.
+*/
 QList<HsPage *> HsScene::pages() const
 {
-    return mD->mPages;
+    return mPages;
 }
     
+/*!
+    Add page \a page.
+*/
 bool HsScene::addPage(HsPage *page)
 {
     if (!page) {
         return false;
     }
    
-    if (mD->mPages.contains(page)) {
+    if (mPages.contains(page)) {
         return true;
     }
 
     HsDatabase *db = HsDatabase::instance();
-
-    HsPageData pageData;
-    if (!db->page(page->databaseId(), pageData, false)) {
+    
+    HsPageData data;
+    data.id = page->databaseId();
+    if (!db->page(data)) {
         return false;
     }
-    int index = mD->mPages.count();
-    if (pageData.index() != index) {
-        pageData.setIndex(index);
-        if (!db->updatePage(pageData, false)) {
+
+    db->transaction();
+
+    for (int i = data.indexPosition; i < mPages.count(); ++i) {
+        data.id = mPages.at(i)->databaseId();
+        data.indexPosition = i + 1;
+        if (!db->updatePage(data)) {
+            db->rollback();
             return false;
         }
     }
     
-    mD->mPages << page;
+    db->commit();
+    
+    mPages.insert(data.indexPosition, page);
     return true;
 }
     
+/*!
+    Removes page \a page.
+*/
 bool HsScene::removePage(HsPage *page)
 {
     if (!page) {
         return false;
     }
-    return mD->mPages.removeOne(page);
+
+    if (!mPages.contains(page)) {
+        return true;
+    }
+
+    int index = mPages.indexOf(page) + 1;
+
+    HsDatabase *db = HsDatabase::instance();
+    db->transaction();
+
+    HsPageData data;
+    for (int i = index; i < mPages.count(); ++i) {
+        data.id = mPages.at(i)->databaseId();
+        data.indexPosition = i - 1;
+        if (!db->updatePage(data)) {
+            db->rollback();
+            return false;
+        }
+    }
+
+    if (!page->deleteFromDatabase()) {
+        db->rollback();
+        return false;
+    }
+
+    db->commit();
+
+    mPages.removeOne(page);
+    return true;
 }
  
+/*!
+    Set active page \a page.
+*/
 bool HsScene::setActivePage(HsPage *page)
 {
     if (!page) {
         return false;
     }
    
-    if (!mD->mPages.contains(page)) {
+    if (!mPages.contains(page)) {
         return false;
     }
 
-    mD->mActivePage = page;
+    if (page == mActivePage) {
+        return true;
+    }
+
+    mActivePage = page;
+
+    foreach (HsPage *p, mPages) {
+        if (p == mActivePage) {
+            p->showWidgets();
+        } else {
+            p->hideWidgets();
+        }
+    }
+
     return true;
 }
 
+/*!
+    Set active page \a index.
+*/
 bool HsScene::setActivePageIndex(int index)
 {
-    if (index < 0 || mD->mPages.count() <= index) {
+    if (index < 0 || mPages.count() <= index) {
         return false;
     }
-    return setActivePage(mD->mPages[index]);
+    return setActivePage(mPages[index]);
 }
 
+/*!
+    Return active page.
+*/
 HsPage *HsScene::activePage() const
 {
-    return mD->mActivePage;
+    return mActivePage;
 }
 
+/*!
+    Return active page index.
+*/
 int HsScene::activePageIndex() const
 {
-    return mD->mPages.indexOf(mD->mActivePage);
+    return mPages.indexOf(mActivePage);
 }
 
+/*!
+    Return maximum number of pages.
+*/
+int HsScene::maximumPageCount() const
+{
+    return mMaximumPageCount;
+}
+
+/*!
+    Set active widget \a widget.
+*/
 void HsScene::setActiveWidget(HsWidgetHost *widget)
 {
-    mD->mActiveWidget = widget;
+    mActiveWidget = widget;
 }
  
+/*!
+   Return active widget.
+*/
 HsWidgetHost *HsScene::activeWidget() const
 {
-    return mD->mActiveWidget;
+    return mActiveWidget;
 }
 /*!
     Toggle application online state. Defaults 
@@ -196,17 +265,23 @@
 */
 void HsScene::setOnline(bool online)
 {
-    mD->mIsOnline = online;
-    foreach (HsPage *page, mD->mPages) {
+    mIsOnline = online;
+    foreach (HsPage *page, mPages) {
         page->setOnline(online);
     }
 }
 
+/*!
+    Return current online setting.
+*/
 bool HsScene::isOnline()const
 {
-    return mD->mIsOnline;
+    return mIsOnline;
 }
 
+/*!
+    Singleton. 
+*/
 HsScene *HsScene::instance()
 {
     if (mInstance.isNull()) {
@@ -215,20 +290,39 @@
     return mInstance.data();
 }
 
+/*!
+    Return current orientation.
+*/
 Qt::Orientation HsScene::orientation()
 {
-    return hbInstance->orientation();
+    return mainWindow()->orientation();
 }
 
+/*!
+    Return main window.
+*/
 HbMainWindow *HsScene::mainWindow()
 {
     return hbInstance->allMainWindows().first();
 }
 
+/*!
+    Constructor
+*/
 HsScene::HsScene(QObject *parent)
-    : QObject(parent)
+  : QObject(parent),
+    mDatabaseId(-1),
+    mIsOnline(true),
+    mWallpaper(0),
+    mMaximumPageCount(1),
+    mActivePage(0),
+    mActiveWidget(0)
+
 {
-    mD.reset(new HsScenePrivate);
+    mWallpaper = new HsWallpaper;
 }
 
+/*!
+    Points to the scene instance.
+*/
 QScopedPointer<HsScene> HsScene::mInstance(0);
--- a/homescreenapp/hsdomainmodel/src/hsscenedata.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Scene meta data.
-*
-*/
-
-
-#include "hsscenedata.h"
-
-
-/*!
-    \class HsSceneData
-    \ingroup group_hsdatamodel
-    \brief Contains scene metadata.
-
-    Used by content store and content service for
-    holding scene metadata.
-*/
-
-
-/*!
-    \fn HsSceneData::HsSceneData()
-
-    Initialize scene id to -1
-*/
-HsSceneData::HsSceneData() 
-    : mId(-1)
-{
-
-}
-
-/*!
-    \fn HsSceneData::~HsSceneData()
-
-    Destructor
-*/
-HsSceneData::~HsSceneData()
-{
-
-}
-
-/*!
-    \fn void HsSceneData::setId(int id)
-
-    Set scene \a id
-*/
-void HsSceneData::setId(int id)
-{
-	mId = id;
-}
-
-/*!
-    \fn int HsSceneData::id() const
-
-    Return scene id
-*/
-int HsSceneData::id() const
-{
-    return mId;
-}
-
-/*!
-    Sets portrait wallpaper \a path.
-*/
-void HsSceneData::setPortraitWallpaper(const QString &path)
-{
-	mPortraitWallpaper = path;
-}
-
-/*!
-    Returns portrait wallpaper.
-*/
-QString HsSceneData::portraitWallpaper() const
-{
-	return mPortraitWallpaper;
-}
-
-/*!
-    Sets landscape wallpaper \a path.
-*/
-void HsSceneData::setLandscapeWallpaper(const QString &path)
-{
-	mLandscapeWallpaper = path;
-}
-
-/*!
-    Returns landscape wallpaper.
-*/
-QString HsSceneData::landscapeWallpaper() const
-{
-	return mLandscapeWallpaper;
-}
-
-/*!
-    \fn void HsSceneData::setDefaultPage(const HsPageData &defaultPage)
-
-    Set scene \a defaultPage 
-*/
-void HsSceneData::setDefaultPage(const HsPageData &defaultPage)
-{	
-    mDefaultPage = defaultPage;
-}
-
-/*!
-    \fn HsPageData HsSceneData::defaultPage() const
-
-    Return scene default page
-*/
-HsPageData HsSceneData::defaultPage() const
-{
-    return mDefaultPage;
-}
-
-
--- a/homescreenapp/hsdomainmodel/src/hsshortcutservice.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hsshortcutservice.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -19,13 +19,13 @@
 #include "hsshortcutservice.h"
 #include "hsshortcutservice_p.h"
 #include "hsdatabase.h"
-#include "hswidgetdata.h"
+#include "hsdomainmodeldatastructures.h"
 #include "hsmenueventfactory.h"
 
 namespace
 {
-    const char SHORTCUT_ID[] = "mcsId";
-    const char SHORTCUT_WIDGET_URI[] = "hsshortcutwidgetplugin";
+    const char gShortcutId[]        = "mcsId";
+    const char gShortcutWidgetUri[] = "hsshortcutwidgetplugin";
 }
 
 HsShortcutServicePrivate::HsShortcutServicePrivate(QStateMachine *stateMachine, QObject *parent)
@@ -52,12 +52,12 @@
     HsDatabase *db = HsDatabase::instance();
     Q_ASSERT(db);
 
-	QList<int> ids;
-	if (db->widgetIds(SHORTCUT_WIDGET_URI, ids)) {
-		for (int i = 0; i < ids.count(); ++i) {
-            QString id;
-            if (db->widgetPreferenceForKey(ids.at(i), SHORTCUT_ID, id) 
-				&& id.toInt() == itemId) {
+	QList<HsWidgetData> widgetDatas;
+	if (db->widgets(gShortcutWidgetUri, widgetDatas)) {
+        for (int i = 0; i < widgetDatas.count(); ++i) {
+            QVariant id;
+            if (db->widgetPreference(widgetDatas.at(i).id, gShortcutId, id) && 
+                id.toInt() == itemId) {
                 return true;
             }
         }
--- a/homescreenapp/hsdomainmodel/src/hswallpaper.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hswallpaper.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -18,24 +18,14 @@
 #include <QDir>
 #include <QPainter>
 #include "hswallpaper.h"
-#include "hswallpaper_p.h"
 #include "hsscene.h"
 
-HsWallpaperPrivate::HsWallpaperPrivate()
-  : mOrientation(Qt::Vertical)
-{
-}
- 
-HsWallpaperPrivate::~HsWallpaperPrivate()
+HsWallpaper::HsWallpaper(QGraphicsItem *parent)
+  : HbWidget(parent),
+    mOrientation(Qt::Vertical)
 {
 }
 
-HsWallpaper::HsWallpaper(QGraphicsItem *parent)
-    : HbWidget(parent)
-{
-    mD.reset(new HsWallpaperPrivate);
-}
-
 HsWallpaper::~HsWallpaper()
 {
 }
@@ -48,18 +38,18 @@
     Q_UNUSED(widget);
 
     Qt::Orientation orientation = HsScene::orientation();
-    if (orientation != mD->mOrientation) {
-        mD->mOrientation = orientation;
-        mD->mImage = QPixmap();
+    if (orientation != mOrientation) {
+        mOrientation = orientation;
+        mImage = QPixmap();
         if (orientation == Qt::Horizontal) {
-            mD->mImage.load(mD->mLImagePath);
+            mImage.load(mLImagePath);
         } else {
-            mD->mImage.load(mD->mPImagePath);
+            mImage.load(mPImagePath);
         }
     }
 
-    if (!mD->mImage.isNull()) {
-        painter->drawPixmap(rect().toRect(), mD->mImage);
+    if (!mImage.isNull()) {
+        painter->drawPixmap(rect().toRect(), mImage);
     }
 }
 
@@ -74,26 +64,26 @@
 bool HsWallpaper::setImagesByPaths(const QString &landscapeImagePath,
                                    const QString &portraitImagePath)
 {
-    mD->mLImagePath = landscapeImagePath;
-    mD->mPImagePath = portraitImagePath;
-    mD->mOrientation = HsScene::orientation();
+    mLImagePath = landscapeImagePath;
+    mPImagePath = portraitImagePath;
+    mOrientation = HsScene::orientation();
     
-    if (mD->mOrientation == Qt::Horizontal) {
-        return mD->mImage.load(mD->mLImagePath);
+    if (mOrientation == Qt::Horizontal) {
+        return mImage.load(mLImagePath);
     } else {
-        return mD->mImage.load(mD->mPImagePath);
+        return mImage.load(mPImagePath);
     }
 }
 
 bool HsWallpaper::removeImages()
 {
-    if (mD->mLImagePath != wallpaperPath(Qt::Horizontal)) {
-        QFile::remove(mD->mLImagePath);
-        mD->mLImagePath.clear();
+    if (mLImagePath != wallpaperPath(Qt::Horizontal)) {
+        QFile::remove(mLImagePath);
+        mLImagePath.clear();
     }
-    if (mD->mPImagePath != wallpaperPath(Qt::Vertical)) {
-        QFile::remove(mD->mPImagePath);
-        mD->mPImagePath.clear();
+    if (mPImagePath != wallpaperPath(Qt::Vertical)) {
+        QFile::remove(mPImagePath);
+        mPImagePath.clear();
     }    
     return true;
 }
--- a/homescreenapp/hsdomainmodel/src/hswidgetdata.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Home screen widget meta data.
-*
-*/
-
-
-#include "hswidgetdata.h"
-
-
-/*!
-    \class HsWidgetData 
-    \ingroup group_hsdatamodel
-    \brief Contains widget metadata.
-
-    Used by content store and content service for
-    holding widget metadata.
-*/
-
-
-
-/*!
-    \fn HsWidgetData::HsWidgetData()
-
-    Initialize widget and page id to -1
-*/
-HsWidgetData::HsWidgetData()
-    : mId(-1),
-      mPageId(-1)
-{
-
-}
-
-/*!
-    \fn HsWidgetData::~HsWidgetData()
-
-    Destructor
-*/
-HsWidgetData::~HsWidgetData()
-{
-
-}
-
-/*!
-    Set widget \a id
-*/
-void HsWidgetData::setId(int id)
-{
-	mId = id;
-}
-
-/*!
-    Return widget id
-*/
-int HsWidgetData::id() const
-{
-    return mId;
-}
-
-/*!
-    Set widget \a uri
-*/
-void HsWidgetData::setUri(const QString &uri)
-{
-	mUri = uri;
-}
-
-/*!
-     Return widget uri.
-*/
-QString HsWidgetData::uri() const
-{
-	return mUri;
-}
-
-
-/*!
-    Return widget presentations
-*/
-QList<HsWidgetPresentationData> HsWidgetData::presentations() const
-{
-    return mPresentations;
-}
-	
-/*!
-    Return modifiable widget presentations
-*/
-QList<HsWidgetPresentationData> &HsWidgetData::presentations()
-{
-	return mPresentations;
-}
-
-/*!
-    Set \a pageId where widget is
-*/
-void HsWidgetData::setPageId(int pageId)
-{
-	mPageId = pageId;
-}
-
-/*!
-    Return widget page id
-*/
-int HsWidgetData::pageId() const
-{
-    return mPageId;
-}
-
-
--- a/homescreenapp/hsdomainmodel/src/hswidgethost.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsdomainmodel/src/hswidgethost.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -28,7 +28,7 @@
 
 #include "hswidgethost.h"
 #include "hsdatabase.h"
-#include "hswidgetdata.h"
+#include "hsdomainmodeldatastructures.h"
 #include "hspage.h"
 #include "hsapp_defs.h"
 #include "hsscene.h"
@@ -49,21 +49,18 @@
     homescreen widget has its own host.
 */
 
-HsWidgetHost* HsWidgetHost::createInstance(const HsWidgetData &widgetData, 
-                                           const QVariantMap &preferences)
+HsWidgetHost* HsWidgetHost::createInstance(HsWidgetData &widgetData, 
+                                           const QVariantHash &preferences)
 {
-    HsWidgetHost *host = NULL;
-    
     HsDatabase* db = HsDatabase::instance();
     Q_ASSERT(db);
 
-    int databaseId = -1;
-    if (db->insertWidget(widgetData, databaseId)) {
-        db->setWidgetPreferences(databaseId, preferences);
-        host = new HsWidgetHost(databaseId);
+    if (db->insertWidget(widgetData)) {
+        db->setWidgetPreferences(widgetData.id, preferences);
+        return new HsWidgetHost(widgetData.id);
     }
 
-    return host;                
+    return 0;
 }
 /*!
     Construct a widget host for the given \a databaseId. 
@@ -73,6 +70,7 @@
     : HbWidget(parent),
       mWidget(0),
       mPage(0),
+      mState(Constructed),
       mDatabaseId(databaseId)
 {
     CaQuery query;
@@ -81,8 +79,8 @@
     CaNotifier *notifier = CaService::instance()->createNotifier(filter);
     notifier->setParent(this);
     connect(notifier,
-            SIGNAL(entryChanged(const CaEntry&, ChangeType)),
-            SLOT(onEntryChanged(const CaEntry&, ChangeType)), Qt::QueuedConnection);
+            SIGNAL(entryChanged(CaEntry,ChangeType)),
+            SLOT(onEntryChanged(CaEntry,ChangeType)), Qt::QueuedConnection);
 
     /* TODO: Uncomment after the Qt bug has been fixed.
     QGraphicsDropShadowEffect *effect = 
@@ -111,22 +109,22 @@
     }
 
     HsDatabase *db = HsDatabase::instance();
-    Q_ASSERT(db);
-
+    
     // Find the widget data.
-    HsWidgetData widgetData;
-    if (!db->widget(mDatabaseId, widgetData, false)) {
+    HsWidgetData data;
+    data.id = mDatabaseId;
+    if (!db->widget(data)) {
         return false;
     }
 
-    mUri = widgetData.uri();
+    mUri = data.uri;
 
     // Create the hosted widget.
     QServiceManager manager;
-    QServiceFilter filter("com.nokia.IHomeScreenWidget");
-    filter.setServiceName(widgetData.uri());
+    QServiceFilter filter("com.nokia.symbian.IHomeScreenWidget");
+    filter.setServiceName(mUri);
     QList<QServiceInterfaceDescriptor> interfaces = manager.findInterfaces(filter);
-    if(interfaces.isEmpty()) {
+    if (interfaces.isEmpty()) {
         return false;
     }
 
@@ -174,13 +172,14 @@
     Q_ASSERT(db);
 
     HsWidgetData data;
-    if (db->widget(mDatabaseId, data, false)) {
+    data.id = mDatabaseId;
+    if (db->widget(data)) {
         if (!page) {
-            data.setPageId(-1);
+            data.pageId = -1;
         } else {
-            data.setPageId(page->databaseId());
+            data.pageId = page->databaseId();
         }
-        if (!db->updateWidget(data, false)) {
+        if (!db->updateWidget(data)) {
             return false;
         }
     } else {
@@ -219,11 +218,14 @@
 */
 bool HsWidgetHost::deleteFromDatabase()
 {
-    if (HsDatabase::instance()->deleteWidget(mDatabaseId)) {
-        mDatabaseId = -1;
-        return true;
+    HsDatabase *db = HsDatabase::instance();
+
+    if (!db->deleteWidget(mDatabaseId)) {
+        return false;
     }
-    return false;
+
+    mDatabaseId = -1;
+    return true;
 }
 
 /*!
@@ -235,29 +237,17 @@
     HsDatabase *db = HsDatabase::instance();
     Q_ASSERT(db);
 
-    QString key = hbInstance->orientation() == Qt::Vertical ? 
+    QString key = HsScene::orientation() == Qt::Vertical ? 
         "portrait" : "landscape";
    
-    HsWidgetPresentationData data;
-    data.setWidgetId(databaseId());
-    data.setKey(key);
-    data.setPosition(pos());
+    HsWidgetPresentationData data;    
+    data.key      = key;
+    data.setPos(pos());
     data.setSize(size());
-    data.setZValue(zValue());
+    data.zValue   = zValue();
+    data.widgetId = databaseId();
     
-    HsWidgetPresentationData temp;
-    if (!db->widgetPresentation(databaseId(), key, temp)) {        
-        if (!db->insertWidgetPresentation(data)) {
-            return false;
-        }
-    } else {
-        data.setId(temp.id());
-        if (!db->updateWidgetPresentation(data)) {
-            return false;
-        }
-    }
-
-    return true;
+    return db->setWidgetPresentation(data);
 }
 
 /*!
@@ -266,18 +256,26 @@
 */
 bool HsWidgetHost::setWidgetPresentationData(HsWidgetPresentationData &presentationData)
 {
-    presentationData.setWidgetId(mDatabaseId);
-    return HsDatabase::instance()->insertWidgetPresentation(presentationData);
+    HsDatabase *db = HsDatabase::instance();
+    Q_ASSERT(db);
+
+    presentationData.widgetId = mDatabaseId;
+    return db->setWidgetPresentation(presentationData);
 }
+
 /*!
     Get widget presentation data matching given \a key. 
     Data is returned on given empty \a presentationData. Return true if successfull 
 */
-bool HsWidgetHost::widgetPresentationData(
-    const QString &key,
-    HsWidgetPresentationData &presentationData)
+bool HsWidgetHost::widgetPresentationData(const QString &key,
+                                          HsWidgetPresentationData &presentationData)
 {
-    return HsDatabase::instance()->widgetPresentation(mDatabaseId,key,presentationData);
+    HsDatabase *db = HsDatabase::instance();
+    Q_ASSERT(db);
+
+    presentationData.key = key;
+    presentationData.widgetId = mDatabaseId;
+    return db->widgetPresentation(presentationData);
 }
 
 /*!
@@ -292,12 +290,13 @@
         "portrait" : "landscape";
 
     HsWidgetPresentationData data;
-    if (db->widgetPresentation(databaseId(), key, data)) {
+    data.key = key;
+    data.widgetId = mDatabaseId;
+    if (db->widgetPresentation(data)) {
         return data;
     } else {
         return HsWidgetPresentationData();
     }
-
 }
 
 /*!
@@ -306,18 +305,19 @@
 bool HsWidgetHost::loadWidgetPresentation()
 {
     HsDatabase *db = HsDatabase::instance();
-    Q_ASSERT(db);
-
-    QString key = hbInstance->orientation() == Qt::Vertical ? 
+    
+    QString key = HsScene::orientation() == Qt::Vertical ?
         "portrait" : "landscape";
 
     HsWidgetPresentationData data;
-    if (!db->widgetPresentation(databaseId(), key, data)) {
+    data.key = key;
+    data.widgetId = mDatabaseId;
+    if (!db->widgetPresentation(data)) {
         return false;
     }
 
-    setGeometry(QRectF(data.position(), data.size()));
-    setZValue(data.zValue());
+    setGeometry(data.geometry());
+    setZValue(data.zValue);
 
     return true;
 }
@@ -333,17 +333,8 @@
 
     QString key = orientation == Qt::Vertical ? 
         "portrait" : "landscape";
-
-    HsWidgetPresentationData data;
-    if (!db->widgetPresentation(databaseId(), key, data)) {
-        return true;
-    } else {
-        if (!db->deleteWidgetPresentation(data.id())) {
-            return false;
-        }
-    }
-
-    return true;
+    
+    return db->deleteWidgetPresentation(mDatabaseId, key);
 }
 
 /*!
@@ -363,10 +354,16 @@
     widget defines it.
 */
 void HsWidgetHost::initializeWidget()
-{    
+{   
+    if (mState != Constructed) {
+        return;
+    }
+
     setPreferencesToWidget();
     setOnline(HsScene::instance()->isOnline());
     mOnInitializeMethod.invoke(mWidget);
+   
+    mState = Initialized;
 }
 
 /*!
@@ -375,7 +372,14 @@
 */
 void HsWidgetHost::showWidget()
 {
+    if (mState != Initialized &&
+        mState != Hidden) {
+        return;
+    }
+
     mOnShowMethod.invoke(mWidget);
+    
+    mState = Visible;
 }
 
 /*!
@@ -384,7 +388,14 @@
 */
 void HsWidgetHost::hideWidget()
 {
+    if (mState != Initialized &&
+        mState != Visible) {
+        return;
+    }
+
     mOnHideMethod.invoke(mWidget);
+
+    mState = Hidden;
 }
 
 /*!
@@ -393,7 +404,14 @@
 */
 void HsWidgetHost::uninitializeWidget()
 {
+    if (mState != Visible &&
+        mState != Hidden) {
+        return;
+    }
+
     mOnUninitializeMethod.invoke(mWidget);
+
+    mState = Uninitialized;
 }
 
 /*!
@@ -511,7 +529,7 @@
     HsDatabase *db = HsDatabase::instance();
     Q_ASSERT(db);
 
-    QVariantMap preferences;
+    QVariantHash preferences;
     if (!db->widgetPreferences(mDatabaseId, preferences)) {
         return false;
     }
@@ -539,7 +557,7 @@
         return;
     }
 
-    QVariantMap preferences;
+    QVariantHash preferences;
 
     foreach (QString name, names) {
         QVariant value = mWidget->property(name.toLatin1());
@@ -562,6 +580,7 @@
 */
 void HsWidgetHost::onFinished()
 {
+    mState = Finished;
     emit widgetFinished(this);
 }
 
@@ -572,6 +591,7 @@
 */
 void HsWidgetHost::onError()
 {
+    mState = Faulted;
     emit widgetError(this);
 }
 
--- a/homescreenapp/hsdomainmodel/src/hswidgetpresentationdata.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Home screen widget presentation data.
-*
-*/
-
-
-#include "hswidgetpresentationdata.h"
-
-/*!
-    \class HsWidgetPresentationData
-    \ingroup group_hsdatamodel
-    \brief Contains widget presentation metadata.
-
-    Used by content store and content service for
-    holding widget presentation metadata.
- 
-*/
-
-
-
-
-/*!
-    Initialize id and widget id to -1 and z value to 0.0 
-*/
-HsWidgetPresentationData::HsWidgetPresentationData()
-    : mId(-1),
-      mWidgetId(-1),
-      mZValue(0.0)
-{
-
-}
-
-/*!
-    Destructor
-*/
-HsWidgetPresentationData::~HsWidgetPresentationData()
-{
-
-}
-
-/*!
-    Set widget \a id 
-*/
-void HsWidgetPresentationData::setId(int id)
-{
-    mId = id;
-}	
-
-/*!
-    Return widget id 
-*/ 
-int HsWidgetPresentationData::id() const
-{
-    return mId;
-}
-  
-/*!
-    Set \a key to distinguish presentations
-*/
-void HsWidgetPresentationData::setKey(const QString &key)
-{
-    mKey = key;
-}
-	    
-/*!
-    Return presentation key 
-*/ 
-QString HsWidgetPresentationData::key() const
-{
-    return mKey;
-}
-
-/*!
-    Set \a position 
-*/ 
-void HsWidgetPresentationData::setPosition(const QPointF &position)
-{
-    mPosition = position;
-}
-   
-/*!
-    Return position 
-*/ 
-QPointF HsWidgetPresentationData::position() const
-{
-    return mPosition;
-}
-
-/*!
-    Set \a zValue 
-*/  
-void HsWidgetPresentationData::setZValue(qreal zValue)
-{
-    mZValue = zValue;
-}
-
-/*!
-    Return z value 
-*/
-qreal HsWidgetPresentationData::zValue() const
-{
-    return mZValue;
-}
-
-/*!
-    Set \a size 
-*/ 
-void HsWidgetPresentationData::setSize(const QSizeF &size)
-{
-    mSize = size;
-}
-
-/*!
-    Return size 
-*/
-QSizeF HsWidgetPresentationData::size() const
-{
-    return mSize;
-}
-
-/*!
-    Set \a widgetId 
-*/
-void HsWidgetPresentationData::setWidgetId(int widgetId)
-{
-    mWidgetId = widgetId;
-}	
-
-/*!
-    Return widget id
-*/
-int HsWidgetPresentationData::widgetId() const
-{
-    return mWidgetId;
-}
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/hshomescreenclientplugin.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,23 @@
+#
+# 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:
+#
+
+HEADERS += ./inc/hshomescreenclientplugin.h
+SOURCES += ./src/hshomescreenclientplugin.cpp
+symbian:{
+    HEADERS += ./inc/hshomescreenclient.h
+    SOURCES += ./src/hshomescreenclient.cpp
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/hshomescreenclientplugin.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+
+TEMPLATE = lib
+CONFIG += plugin hb mobility console
+MOBILITY = serviceframework
+
+PLUGIN_SUBDIR = /hsresources/plugins/homescreenclientplugin
+
+include (../common.pri)
+
+DEPENDPATH += 	./inc \
+              	./src
+              
+INCLUDEPATH += 	./inc 
+
+symbian: {
+    TARGET.UID3 = 0x20022F72
+    LIBS += -lxqservice
+}
+
+win32: {
+    error("Only Symbian supported!")
+}
+
+include(hshomescreenclientplugin.pri)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/inc/hshomescreenclient.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Homescreen client api.
+*
+*/
+
+#ifndef HSHOMESCREENCLIENT_H
+#define HSHOMESCREENCLIENT_H
+
+#include <QObject>
+#include <QVariant>
+
+#include "hstest_global.h"
+
+HOMESCREEN_TEST_CLASS(HsHomescreenClientPluginTest)
+
+class XQServiceRequest;
+
+class HsHomescreenClient : public QObject
+{
+    Q_OBJECT
+
+public:
+    HsHomescreenClient(QObject *parent = 0);
+    virtual ~HsHomescreenClient();
+ 
+public slots:
+    bool addWidget(const QString &uri, const QVariantHash &preferences);
+private slots:
+    void onRequestCompleted(const QVariant &result);
+    void onRequestError(int error);
+    void doAddWidget(const QString &uri, const QVariantHash &preferences);
+signals:
+    void requestFinished();
+private:
+    XQServiceRequest* mAsyncRequest;
+    bool    mRequestResult;
+    
+    HOMESCREEN_TEST_FRIEND_CLASS(HsHomescreenClientPluginTest)
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/inc/hshomescreenclientplugin.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Plugin factory.
+*
+*/
+
+#ifndef HSHOMESCREENCLIENTPLUGIN_H
+#define HSHOMESCREENCLIENTPLUGIN_H
+
+#include <QObject>
+#include <qserviceplugininterface.h>
+
+QTM_USE_NAMESPACE
+
+class HsHomescreenClientPlugin : public QObject, public QServicePluginInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(QtMobility::QServicePluginInterface)
+
+public:
+    QObject *createInstance(const QServiceInterfaceDescriptor &descriptor,
+                            QServiceContext *context,
+                            QAbstractSecuritySession *session);
+};
+
+#endif //HSHOMESCREENCLIENTPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/resource/hshomescreenclientplugin.s60xml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service>
+    <name>hshomescreenclientplugin</name>
+    <filepath>z:/hsresources/plugins/homescreenclientplugin/hshomescreenclientplugin.qtplugin</filepath>
+    <description>Homescreen client plugin</description>
+    <interface>
+        <name>com.nokia.symbian.IHomeScreenClient</name>
+        <version>1.0</version>
+        <description>Homescreen exposed service interface </description>
+        <capabilities></capabilities>
+    </interface>
+</service>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/resource/hshomescreenclientplugin.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service>
+    <name>hshomescreenclientplugin</name>
+    <filepath>hshomescreenclientplugin</filepath>
+    <description>Homescreen client plugin</description>
+    <interface>
+        <name>com.nokia.symbian.IHomeScreenClient</name>
+        <version>1.0</version>
+        <description>Homescreen exposed service interface </description>
+        <capabilities></capabilities>
+    </interface>
+</service>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/src/hshomescreenclient.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Homescreen client api
+*
+*/
+#include "hshomescreenclient.h"
+#include <xqservicerequest.h>
+#include <QEventLoop>
+
+const char INTERFACE_NAME[] = "com.nokia.services.hsapplication.IHomeScreenClient";
+HsHomescreenClient::HsHomescreenClient(QObject *parent)
+    :QObject(parent),
+    mAsyncRequest(0),
+    mRequestResult(false)
+{   
+}
+
+HsHomescreenClient::~HsHomescreenClient()
+{
+    delete mAsyncRequest;
+}
+
+bool HsHomescreenClient::addWidget(
+    const QString &uri, 
+    const QVariantHash &preferences)
+{
+    QEventLoop eventLoop;
+    connect(this, SIGNAL(requestFinished()), &eventLoop, SLOT(quit()));
+    QMetaObject::invokeMethod(this, "doAddWidget", Qt::QueuedConnection,
+            Q_ARG(QString,uri),Q_ARG(QVariantHash,preferences));
+    eventLoop.exec();
+   
+    return mRequestResult;
+}
+    
+void HsHomescreenClient::onRequestCompleted(const QVariant &result)
+{
+    mRequestResult = result.toBool();
+    emit requestFinished();
+}
+    
+void HsHomescreenClient::onRequestError(int error)
+{
+    Q_UNUSED(error)
+    emit requestFinished();
+}
+    
+void HsHomescreenClient::doAddWidget(
+    const QString &uri, 
+    const QVariantHash &preferences)
+{
+    delete mAsyncRequest;
+    mAsyncRequest = 0;
+    mAsyncRequest = new XQServiceRequest(INTERFACE_NAME,
+                       "addWidget(QString,QVariantHash)",false);
+    *mAsyncRequest << uri;
+    *mAsyncRequest << preferences;
+    
+    connect(mAsyncRequest, SIGNAL(requestCompleted(QVariant)), 
+           SLOT(onRequestCompleted(QVariant)));
+    connect(mAsyncRequest, SIGNAL(requestError(int)), 
+              SLOT(onRequestError(int)));
+       
+    mRequestResult = false;
+    bool res=mAsyncRequest->send();
+    if(!res){
+       emit requestFinished();
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/src/hshomescreenclientplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Plugin factory.
+*
+*/
+
+#include <qserviceinterfacedescriptor.h>
+#include <qabstractsecuritysession.h>
+#include <qservicecontext.h>
+
+#include "hshomescreenclientplugin.h"
+#ifdef Q_OS_SYMBIAN
+#include "hshomescreenclient.h"
+#endif
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+
+QObject *HsHomescreenClientPlugin::createInstance(const QServiceInterfaceDescriptor &descriptor,
+                                                QServiceContext *context,
+                                                QAbstractSecuritySession *session)
+{
+    Q_UNUSED(context);
+    Q_UNUSED(session);
+
+    if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IHomeScreenClient")) {
+#ifdef Q_OS_SYMBIAN        
+        return new HsHomescreenClient(this);
+#else
+        return NULL;
+#endif         
+    } else {
+        return 0;
+    }
+}
+
+Q_EXPORT_PLUGIN2(hshomescreenclientplugin, HsHomescreenClientPlugin)
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/inc/t_hshomescreenclientplugin.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Test class for hshomescreenclientplugin
+*
+*/
+
+
+#include <QtTest/QtTest>
+
+#include "hshomescreenclientplugin.h"
+
+
+/**
+* @test Test class for hshomescreenclientplugin.
+*/
+class HsHomescreenClientPluginTest : public QObject
+{
+	Q_OBJECT
+
+private slots:
+
+    void cleanupTestCase();
+    void initTestCase();
+    
+	/**
+	 * HsHomescreenClient
+	 */
+     void testConstruction();
+     void testAddWidget();
+     void testAddInvalidWidget();
+
+signals:
+     void onRequestCompletedTest(const QVariant &result);
+         
+private:
+     
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/sis/gen_sisx.bat	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,30 @@
+@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
+
+if exist t_hshomescreenclientplugin.sisx del t_hshomescreenclientplugin.sisx
+
+makesis t_hshomescreenclientplugin.pkg
+signsis t_hshomescreenclientplugin.sis t_hshomescreenclientplugin.sisx ../../../../sis/rd.cer ../../../../sis/rd-key.pem
+
+if exist t_hshomescreenclientplugin.sisx (
+echo t_hshomescreenclientplugin.sisx creation SUCCEEDED
+del t_hshomescreenclientplugin.sis
+)
+
+if not exist t_hshomescreenclientplugin.sisx (
+echo t_hshomescreenclientplugin.sisx creation FAILED
+)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/sis/t_hshomescreenclientplugin.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,35 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"t_hshomescreenclientplugin"},(0x20022F73),1,0,0
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Supports S60 5th Edition
+[0x1028315F], 0, 0, 0, {"S60ProductID"}
+
+; HS Content Publish Plugin tests
+"/epoc32/release/armv5/urel/t_hshomescreenclientplugin.exe"                       - "c:/sys/bin/t_hshomescreenclientplugin.exe"
+"/epoc32/data/z/private/10003a3f/import/apps/t_hshomescreenclientplugin_reg.rsc"  - "c:/private/10003a3f/import/apps/t_hshomescreenclientplugin_reg.rsc"
+"/epoc32/data/z/resource/apps/t_hshomescreenclientplugin.rsc"                     - "c:/resource/apps/t_hshomescreenclientplugin.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/src/t_hshomescreenclientplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Test class for hshomescreenclientplugin
+*
+*/
+
+#include "t_hshomescreenclientplugin.h"
+#include "hshomescreenclient.h"
+
+#include <xqservicerequest.h>
+
+#include <QSignalSpy>
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::initTestCase()
+{ 
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::cleanupTestCase()
+{
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::testConstruction()
+{
+    HsHomescreenClient *client = new HsHomescreenClient;
+    QVERIFY(client);
+    delete client;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::testAddWidget()
+{  
+    HsHomescreenClient *client = new HsHomescreenClient;
+    
+    QSignalSpy requestFinishedSpy(client, SIGNAL(requestFinished()));
+    
+    // add invalid widget
+    QVariantHash preferences;
+    bool result = client->addWidget("invalidwidget", preferences);
+    
+    // but emit correct signals
+    connect(this, SIGNAL(onRequestCompletedTest(QVariant)), client, SLOT(onRequestCompleted(QVariant)));
+    emit onRequestCompletedTest(true);
+    
+    QVERIFY(requestFinishedSpy.count());
+    QVERIFY(client->mRequestResult);
+    
+    delete client;    
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::testAddInvalidWidget()
+{  
+    HsHomescreenClient *client = new HsHomescreenClient;
+    
+    QVariantHash preferences;
+    bool result = client->addWidget("invalidwidget", preferences);
+    
+    QVERIFY(!result);
+    QVERIFY(!client->mRequestResult);
+
+    delete client;
+}
+
+QTEST_MAIN(HsHomescreenClientPluginTest)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/t_hshomescreenclientplugin.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+#Header files
+HEADERS += ./inc/*.h \
+           ../../inc/hshomescreenclient.h \
+
+#Source files
+SOURCES += ./src/*.cpp \
+           ../../src/hshomescreenclient.cpp           
+           
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/t_hshomescreenclientplugin.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,58 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = app
+
+CONFIG(debug, debug|release) {
+    DESTDIR = ./debug
+}
+else {
+    DESTDIR = ./release
+}
+
+CONFIG += debug_and_release \
+          console
+
+QT += testlib
+
+DEFINES += HOMESCREEN_TEST
+
+DEPENDPATH += .\
+              ./src \
+              ./inc \
+              ../../src \
+              ../../inc
+
+INCLUDEPATH += .\
+               ./inc \
+               ../../inc \
+               ../../../inc
+
+symbian: {
+    CONFIG += symbian_test
+    load(hb.prf)
+    CONFIG -= symbian_i18n      
+    SYMBIAN_PLATFORMS = WINSCW ARMV5
+    TARGET.UID3 = 0x20022F73
+    TARGET.CAPABILITY = CAP_APPLICATION AllFiles
+    TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+    LIBS += -lxqservice
+} else {
+    error("Only Symbian supported!")
+}
+
+include(t_hshomescreenclientplugin.pri)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/tsrc.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = subdirs
+SUBDIRS  += t_hshomescreenclientplugin
+
+CONFIG  += ordered
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/hsmenucontentpublish.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = lib
+
+CONFIG += plugin mobility
+MOBILITY = serviceframework
+
+PLUGIN_SUBDIR = /hsresources/plugins/hsmenucontentpublishplugin
+
+LIBS += -lcaclient
+
+INCLUDEPATH += inc
+
+HEADERS +=  inc/hsmenucontentpublish.h \
+            inc/hsmenucontentpublishplugin.h \
+
+SOURCES +=  src/hsmenucontentpublish.cpp \
+            src/hsmenucontentpublishplugin.cpp \
+
+symbian: {
+	TARGET.UID3 = 0x20028715
+#export interface header to platform
+BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>"
+BLD_INF_RULES.prj_exports += "inc/hsmenucontentpublish.h \
+	APP_LAYER_PLATFORM_EXPORT_PATH(hsmenucontentpublish.h)"
+}
+
+include(../common.pri)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/inc/hsmenucontentpublish.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: hsmenucontentpublish.h
+ *
+ */
+
+#ifndef HSMENUCONTENTPUBLISH_H
+#define HSMENUCONTENTPUBLISH_H
+
+#include <QObject>
+#include <QVariant>
+#include <qservicemanager.h>
+
+QTM_USE_NAMESPACE
+
+//mandatory keys
+const QString hsItemName("item:name");
+const QString hsitemLaunchUri("item:launchuri");
+const QString hsitemPublisherId("item:publisherId");
+
+//not mandatory
+const QString hsItemWidgetUri("widget:uri");
+const QString hsItemDescription("item:description");
+
+//for icon - not mandatory
+const QString hsIconFileName("icon:filename");//to display specific icon from file
+const QString hsIconName("icon:name");// it is used in similar way in HbIcon
+const QString hsIconApplicationId("icon:applicationid"); //publisherid makes rest
+
+
+class HsMenuContentPublishPrivate;
+
+class HsMenuContentPublish : public QObject
+{
+    Q_OBJECT
+
+public:
+    HsMenuContentPublish(QObject *parent = 0);
+    ~HsMenuContentPublish();
+public slots:
+   bool add(const QVariantMap &entryPreference = QVariantMap());
+   bool remove(const QVariantMap &queryPreference = QVariantMap()) const;
+   
+   QList<QVariantMap > getList(const QVariantMap &queryPreference = QVariantMap());
+  
+private:
+   Q_DISABLE_COPY(HsMenuContentPublish)
+    /**
+     * Pointer to a private implementation.
+     */
+   HsMenuContentPublishPrivate * const m_d;
+};
+
+
+
+#endif // HSMENUCONTENTPUBLISH_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/inc/hsmenucontentpublish_p.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: hsmenucontentpublish_p.h
+ *
+ */
+
+#ifndef HSMENUCONTENTPUBLISH_PRIVATE_H
+#define HSMENUCONTENTPUBLISH_PRIVATE_H
+
+// hidden
+const QString hsItemId("id");
+
+class HsMenuContentPublish;
+
+class HsMenuContentPublishPrivate
+{
+
+public:
+
+    explicit HsMenuContentPublishPrivate(HsMenuContentPublish *publishPublic);
+    ~HsMenuContentPublishPrivate();
+    bool add(const QVariantMap &entryPreference = QVariantMap());
+    bool remove(const QVariantMap &queryPreference = QVariantMap()) const;    
+    QList<QVariantMap > getList(const QVariantMap &queryPreference = QVariantMap());
+    
+private:
+    /**
+     * Points to the HsMenuContentPublish instance that uses this private implementation.
+     */
+    HsMenuContentPublish *const m_q;    
+};
+
+#endif //HSMENUCONTENTPUBLISH_PRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/inc/hsmenucontentpublishplugin.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Plugin factory.
+*
+*/
+
+#ifndef HSMENUCONTENTPUBLISHPLUGIN_H
+#define HSMENUCONTENTPUBLISHPLUGIN_H
+
+#include <QObject>
+#include <qserviceplugininterface.h>
+
+QTM_USE_NAMESPACE
+
+class HsMenuContentPublishPlugin : public QObject, public QServicePluginInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(QtMobility::QServicePluginInterface)
+
+public:
+    QObject *createInstance(const QServiceInterfaceDescriptor &descriptor,
+                            QServiceContext *context,
+                            QAbstractSecuritySession *session);
+};
+
+#endif //HSMENUCONTENTPUBLISHPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/resource/hsmenucontentpublish.s60xml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service>
+    <name>hsmenucontentpublishplugin</name>
+    <filepath>z:/hsresources/plugins/hsmenucontentpublishplugin/hsmenucontentpublish.qtplugin</filepath>
+    <description>HsMenu Client plugin</description>
+    <interface>
+        <name>com.nokia.symbian.IMenuClient</name>
+        <version>1.0</version>
+        <description>HsMenu Client exposed service interface </description>
+        <capabilities></capabilities>
+    </interface>
+</service>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/resource/hsmenucontentpublish.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service>
+    <name>hsmenucontentpublishplugin</name>
+    <filepath>hsmenucontentpublish</filepath>
+    <description>HsMenu Client plugin</description>
+    <interface>
+        <name>com.nokia.symbian.IMenuClient</name>
+        <version>1.0</version>
+        <description>HsMenu Client exposed service interface </description>
+        <capabilities></capabilities>
+    </interface>
+</service>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/src/hsmenucontentpublish.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,196 @@
+/*
+ * 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: hsmenucontentpublish.cpp
+ *
+ */
+
+#include <QString>
+#include <QDebug>
+
+#include "hsapp_defs.h"
+#include "caquery.h"
+#include "caentry.h"
+#include "caicondescription.h"
+#include "caservice.h"
+
+#include "hsmenucontentpublish.h"
+#include "hsmenucontentpublish_p.h"
+
+HsMenuContentPublish::HsMenuContentPublish(QObject *parent)
+    :QObject(parent), m_d(new HsMenuContentPublishPrivate(this))
+{
+ 
+}
+
+HsMenuContentPublish::~HsMenuContentPublish()
+{
+    delete m_d;
+}
+
+bool HsMenuContentPublish::add(const QVariantMap &entryPreference)
+{    
+    return m_d->add(entryPreference);
+}
+bool HsMenuContentPublish::remove(const QVariantMap &entry) const
+{
+    return m_d->remove(entry);
+}
+
+QList<QVariantMap > HsMenuContentPublish::getList(const QVariantMap &queryPreference)
+{
+    return m_d->getList(queryPreference);
+}
+
+/*!
+ Constructor
+ \param publishPublic pointer to public contentPublish
+ */
+HsMenuContentPublishPrivate::HsMenuContentPublishPrivate(HsMenuContentPublish *publishPublic) :
+    m_q(publishPublic)
+{
+
+}
+
+/*!
+ destructor
+ */
+HsMenuContentPublishPrivate::~HsMenuContentPublishPrivate()
+{
+    
+}
+
+bool HsMenuContentPublishPrivate::add(const QVariantMap &entryPreference)
+{
+    bool result = false;
+    QMap<QString, QVariant> pref = entryPreference;
+    
+    CaIconDescription iconDesc;
+    if(pref.contains(hsItemId))
+        {
+            CaEntry *update_entry = CaService::instance()->getEntry(pref.take(hsItemId).toInt());
+            
+            update_entry->setText(pref.take(hsItemName).toString());
+            
+            update_entry->setDescription(pref.take(hsItemDescription).toString());
+            
+            iconDesc.setFilename(pref.take(hsIconFileName).toString());
+            iconDesc.setSkinId(pref.take(hsIconName).toString());
+            iconDesc.setApplicationId(pref.take(hsIconApplicationId).toString());
+            update_entry->setIconDescription(iconDesc);
+            QMapIterator<QString, QVariant> k(pref);
+            while (k.hasNext()) {
+                k.next();
+                update_entry->setAttribute(k.key(),k.value().toString());
+            }
+            
+            result = CaService::instance()->updateEntry(*update_entry);
+        }
+    else if (pref.contains(hsItemName) && pref.contains(hsitemLaunchUri) && pref.contains(hsitemPublisherId))
+        {
+            CaEntry add_entry(ItemEntryRole);
+            add_entry.setEntryTypeName(templatedApplicationTypeName());
+            // mandatory values
+            add_entry.setText(pref.take(hsItemName).toString());
+            
+            iconDesc.setFilename(pref.take(hsIconFileName).toString());
+            iconDesc.setSkinId(pref.take(hsIconName).toString());
+            iconDesc.setApplicationId(pref.take(hsIconApplicationId).toString());            
+            add_entry.setIconDescription(iconDesc);  
+            
+            add_entry.setDescription(pref.take(hsItemDescription).toString());
+            QMapIterator<QString, QVariant> k(pref);
+            while (k.hasNext()) {
+                k.next();
+                add_entry.setAttribute(k.key(),k.value().toString());
+            }
+
+            add_entry.setFlags(add_entry.flags() & ~RemovableEntryFlag);
+            
+            CaEntry *entry = CaService::instance()->createEntry(add_entry);
+            if (entry) {
+                result = true;
+                delete entry;
+            }      
+        }
+    else
+        {
+            return false;
+        }
+    return result;
+    
+  
+}
+bool HsMenuContentPublishPrivate::remove(const QVariantMap &entry) const
+{
+    bool result = false;
+    if (entry.contains(hsItemId))
+        {    
+            result = CaService::instance()->removeEntry(entry.value(hsItemId).toInt());
+        }
+    return result;
+}
+
+QList<QVariantMap > HsMenuContentPublishPrivate::getList(const QVariantMap &queryPreference)
+{
+    QList<QVariantMap> list;
+    QMap<QString, QVariant> map = queryPreference;
+    
+    map.remove(hsItemName);
+    map.remove(hsItemDescription);
+    
+    CaQuery query;
+    // define query
+    query.setFlagsOn(VisibleEntryFlag);
+    query.setEntryRoles(ItemEntryRole);
+    query.setEntryTypeNames(QStringList(templatedApplicationTypeName()));
+    
+    
+    // add atributes to caquery
+    QMapIterator<QString, QVariant> k(map);
+    while (k.hasNext()) {
+        k.next();
+        query.setAttribute(k.key(),k.value().toString());
+    }  
+    QList<CaEntry *> entries = CaService::instance()->getEntries(query);
+    map.clear();
+    if (entries.count()) {
+        QMap<QString, QString> attrMap;
+        QMapIterator<QString, QString> k(attrMap);
+        //walk trought entrys and extract keys into map
+        for (int i = 0; i < entries.count(); ++i) {
+            map[hsItemId] = entries.at(i)->id();
+            map[hsItemName] = entries.at(i)->text();
+            map[hsItemDescription] = entries.at(i)->description();
+            CaIconDescription iconDesc = entries.at(i)->iconDescription();
+            map[hsIconFileName] = iconDesc.filename();
+            map[hsIconName] = iconDesc.skinId();
+            map[hsIconApplicationId] = iconDesc.applicationId();
+            
+            // extract entry atributes
+            attrMap = entries.at(i)->attributes();
+            QMapIterator<QString, QString> k(attrMap);
+            // insert entrys attr into map
+            while (k.hasNext()) {
+                k.next();
+                map.insert(k.key(),k.value());
+            }
+            list.append(map); //append entry map to list
+            // clean used maps
+            map.clear();
+            attrMap.clear();
+        }
+    }
+    qDeleteAll(entries);
+    return list;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsmenucontentpublish/src/hsmenucontentpublishplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Plugin factory.
+*
+*/
+
+#include <qserviceinterfacedescriptor.h>
+#include <qabstractsecuritysession.h>
+#include <qservicecontext.h>
+
+#include "hsmenucontentpublishplugin.h"
+#include "hsmenucontentpublish.h"
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+
+QObject *HsMenuContentPublishPlugin::createInstance(const QServiceInterfaceDescriptor &descriptor,
+                                                QServiceContext *context,
+                                                QAbstractSecuritySession *session)
+{
+    Q_UNUSED(context);
+    Q_UNUSED(session);
+
+    if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IMenuClient")) {
+        return new HsMenuContentPublish(this);
+    } else {
+        return 0;
+    }
+}
+
+Q_EXPORT_PLUGIN2(hsmenucontentpublishplugin, HsMenuContentPublishPlugin)
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
--- a/homescreenapp/hsutils/inc/hsmenueventfactory.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/inc/hsmenueventfactory.h	Fri Apr 16 14:54:01 2010 +0300
@@ -42,7 +42,8 @@
         int entryId,
         const QString &entryTypeName = QString(),
         const QString &uri = QString(),
-        const QString &library = QString()
+        const QString &library = QString(),
+        QMap<QString, QString>* attributes = NULL
     );
 
     static QEvent *createOpenCollectionEvent(int itemId,
--- a/homescreenapp/hsutils/inc/hspageindicator.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/inc/hspageindicator.h	Fri Apr 16 14:54:01 2010 +0300
@@ -11,64 +11,51 @@
 *
 * Contributors:
 *
-* Description:  Page indicator
+* Description:
 *
 */
 
 #ifndef HSPAGEINDICATOR_H
 #define HSPAGEINDICATOR_H
 
-#include <hbwidget.h>
+#include <HbWidget>
 
 #include "hsutils_global.h"
+
 #include "hstest_global.h"
-
-class QGraphicsLinearLayout;
-class QParallelAnimationGroup;
-class HbIconItem;
-
 HOMESCREEN_TEST_CLASS(t_hsUtils)
 
-class HSUTILS_EXPORT HsPageIndicator: public HbWidget
+class HsPageIndicatorItem;
+
+class HSUTILS_EXPORT HsPageIndicator : public HbWidget
 {
     Q_OBJECT
 
 public:
-    HsPageIndicator(QGraphicsItem* parent = 0);
+    HsPageIndicator(QGraphicsItem *parent = 0);
     ~HsPageIndicator();
-       
-signals:
-    void currentItemChangeAnimationFinished();
 
-public slots:
-    void addItem(bool setAsCurrent=false,bool animated=true);
-    void removeItem(bool animated=true);
-    void setCurrentIndex(int currentIndex,bool animated=true);
+    void initialize(int itemCount, int activeItemIndex);
+    
+    int itemCount() const;
 
-public:
-    void setItemCount(int itemCount);    
-    int itemCount();
-    int currentIndex();
-    bool isAnimatingCurrentItemChange();
-    
-private slots:
-    void resetEffect();
-    
-private: 
-    void addItemInternal(bool setAsCurrent,int itemIndex,bool animated=true);
+    void setActiveItemIndex(int index);
+    int activeItemIndex() const;
 
-    void startItemAnimation();
+    void addItem(int activeItemIndex);
+    void removeItem(int activeItemIndex);
+
+    bool isAnimationRunning() const;
 
 private:
-    int mItemCount;
-    int mCurrentIndex;
-    HbIcon *mNonActiveIcon;
-    HbIcon *mActiveIcon;
-    QSizeF mItemSize;
-    QGraphicsLinearLayout *mPageIndicatorLayout;
-    QParallelAnimationGroup *mIconAnimationGroup;
+    Q_DISABLE_COPY(HsPageIndicator)
+    void layoutItems();    
+
+private:
+    QList<HsPageIndicatorItem *> mItems;    
+    int mActiveItemIndex;
 
     HOMESCREEN_TEST_FRIEND_CLASS(t_hsUtils)
 };
 
-#endif
+#endif // HSPAGEINDICATOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsutils/inc/hspageindicatoritem.h	Fri Apr 16 14:54:01 2010 +0300
@@ -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 HSPAGEINDICATORITEM_H
+#define HSPAGEINDICATORITEM_H
+
+#include <HbWidget>
+
+class HbIconItem;
+
+class HsPageIndicatorItem : public HbWidget
+{
+    Q_OBJECT
+
+public:
+    HsPageIndicatorItem(bool active = false, QGraphicsItem *parent = 0);
+    ~HsPageIndicatorItem();
+
+public:
+    void setActive(bool active = true);
+    bool isActive() const;
+
+    bool isAnimationRunning() const;
+
+private:
+    Q_DISABLE_COPY(HsPageIndicatorItem)
+    void startAnimation();
+
+private slots:
+    void animationFinished();
+
+private:
+    HbIconItem *mIconItem;    
+    bool mIsActive;    
+};
+
+#endif // HSPAGEINDICATORITEM_H
--- a/homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h	Fri Apr 16 14:54:01 2010 +0300
@@ -28,8 +28,9 @@
     virtual ~HsWidgetPositioningOnWidgetAdd() {}
     
     virtual QList<QRectF> convert(const QRectF &contentArea,
-                                  const QList<QRectF> &widgets) = 0;
-
+                                  const QList<QRectF> &rects, 
+                                  const QPointF &startPoint) = 0;
+   
     static void setInstance(HsWidgetPositioningOnWidgetAdd *instance);
     static HsWidgetPositioningOnWidgetAdd *instance();
 
@@ -41,15 +42,18 @@
 {
 public:
     QList<QRectF> convert(const QRectF &contentArea,
-                          const QList<QRectF> &widgets);
+                          const QList<QRectF> &rects,
+                          const QPointF &startPoint);
+ 
 };
 
 class HSUTILS_EXPORT HsAnchorPointInCenter : public HsWidgetPositioningOnWidgetAdd
 {
 public:
     QList<QRectF> convert(const QRectF &contentArea,
-                          const QList<QRectF> &widgets);
-};
+                          const QList<QRectF> &rects,
+                          const QPointF &startPoint);
+ };
 
 
 #endif // HSWIDGETPOSITIONINGONWIDGETADD_H
--- a/homescreenapp/hsutils/src/hsmenueventfactory.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/src/hsmenueventfactory.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -41,20 +41,23 @@
     \param entryTypeName Name of the entry type (e.g. application, widget).
     \param uri Widget uri.
     \param library Widget library path and name.
+    \param attributes Widget params.
     \return Event for adding the widget to homescreen.
 */
 QEvent *HsMenuEventFactory::createAddToHomeScreenEvent(
     int entryId,
     const QString &entryTypeName,
     const QString &uri,
-    const QString &library)
+    const QString &library,
+    QMap<QString, QString>* attributes)
 {
     // get CaEntry type, and if widget get uri and library stored as properties...
     QVariantMap params;
+    QVariantMap widgetParams;
 
     params.insert(itemIdKey(), entryId);
 
-    if (entryTypeName == widgetTypeName()) {
+    if (entryTypeName == widgetTypeName() || entryTypeName == templatedApplicationTypeName()) {
         params.insert(
             widgetUriAttributeName(),
             uri);
@@ -64,6 +67,19 @@
             library);
 
         params.insert(entryTypeNameKey(), entryTypeName);
+        
+        if (entryTypeName == templatedApplicationTypeName()) {
+            QMapIterator<QString, QString> i(*attributes);
+            while (i.hasNext()) {
+                i.next();
+                QString key(i.key());
+                QString value(i.value());
+                if (key.contains(widgetParam())) {
+                    widgetParams.insert(key,value);
+                }
+            }
+            params.insert(widgetParam(),widgetParams);
+        }
     }
 
     return new HsMenuEvent(HsMenuEvent::AddToHomeScreen, params);
--- a/homescreenapp/hsutils/src/hspageindicator.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/src/hspageindicator.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -11,240 +11,133 @@
 *
 * Contributors:
 *
-* Description:  Menu Event.
+* Description:
 *
 */
 
 #include <QGraphicsLinearLayout>
-#include <QGraphicsBlurEffect>
-#include <QPropertyAnimation>
-#include <QParallelAnimationGroup>
-#include <QPointer>
-
-#include <HbIconItem>
 
 #include "hspageindicator.h"
-
-const char *KPageIndicatorActiveItemImageName = "qtg_graf_hspage_highlight";
-const char *KPageIndicatorNonActiveItemImageName = "qtg_graf_hspage_normal";
-
-/*! 
-    \class HsPageIndicator
-    \ingroup group_hsutils
-    \brief Page indicator widget.
-*/
+#include "hspageindicatoritem.h"
 
 /*!
-    Constructor.
-
-    \a parent Owner. 
-*/
-HsPageIndicator::HsPageIndicator(QGraphicsItem* parent):
-    HbWidget(parent),
-    mItemCount(0),
-    mCurrentIndex(0),
-    mNonActiveIcon(0),
-    mActiveIcon(0),
-    mIconAnimationGroup(0)
-{
-    mItemSize = QSizeF(30, 15);
 
-    // perf improvement to load icons only once
-    mNonActiveIcon = new HbIcon(KPageIndicatorNonActiveItemImageName);
-    mActiveIcon = new HbIcon(KPageIndicatorActiveItemImageName);
-
-    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
-    layout->addStretch();
+*/
+HsPageIndicator::HsPageIndicator(QGraphicsItem *parent)
+  : HbWidget(parent),
+    mActiveItemIndex(-1)
+{
+}
 
-    mPageIndicatorLayout = new QGraphicsLinearLayout(Qt::Horizontal);
-    layout->addItem(mPageIndicatorLayout);
+/*!
 
-    layout->addStretch();
-    
-    setLayout(layout);
+*/
+HsPageIndicator::~HsPageIndicator()
+{
+    qDeleteAll(mItems);
 }
 
 /*!
-    Destructor.
-*/
-HsPageIndicator::~HsPageIndicator()
-{
-}
-
-/*! 
-    \fn HsPageIndicator::currentItemChangeAnimationFinished()
-    Signaled when current item is changed and animation is finished.
-*/
 
-/*!
-   Add an item and animates if \a animated is true and sets the
-   new page as current if \a setAsCurrent is true
 */
-void HsPageIndicator::addItem(bool setAsCurrent,bool animated)
+void HsPageIndicator::initialize(int itemCount, int activeItemIndex)
 {
-    mItemCount++;
-    addItemInternal(setAsCurrent,mItemCount - 1,animated);
-}
+    qDeleteAll(mItems);
+    mItems.clear();
+    mActiveItemIndex = -1;
 
-/*!
-   Removes on item and animates if \a animated is true.
-*/
-void HsPageIndicator::removeItem(bool animated)
-{
-    if (mItemCount < 1) {
+    if (itemCount < 1 || activeItemIndex < 0 || 
+        itemCount <= activeItemIndex) {
         return;
     }
 
-    mItemCount--;
+    for (int i = 0; i < itemCount; ++i) {
+        mItems << new HsPageIndicatorItem(i == activeItemIndex);
+    }    
+    mActiveItemIndex = activeItemIndex;
+    layoutItems();
+}
+ 
+/*!
 
-    if(mCurrentIndex == mItemCount) {
-        setCurrentIndex(mItemCount-1,animated);
-    }
-    
-    QGraphicsLayoutItem *item = mPageIndicatorLayout->itemAt(mPageIndicatorLayout->count() - 1);
-    mPageIndicatorLayout->removeAt(mPageIndicatorLayout->count() - 1);
-
-    if (mItemCount < 2) {
-        hide();
-    }
-    
-    delete item;
-    layout()->invalidate();
+*/
+int HsPageIndicator::itemCount() const
+{
+    return mItems.count();
 }
 
 /*!
-    Set \a currentIndex as current item and animates the change if \a animated
-    is true.
+
 */
-void HsPageIndicator::setCurrentIndex(int currentIndex,bool animated)
+void HsPageIndicator::setActiveItemIndex(int activeItemIndex)
 {
-    if( currentIndex < mPageIndicatorLayout->count() && currentIndex>=0) {
-        if ( mIconAnimationGroup ) {
-            mIconAnimationGroup->disconnect(this);
-            resetEffect();        
-        }
-        
-        QGraphicsLayoutItem *previousItem = mPageIndicatorLayout->itemAt(mCurrentIndex);
-        HbIconItem *previousIconItem = static_cast<HbIconItem*>(previousItem);
-        previousIconItem->setIcon(*mNonActiveIcon);
-        mCurrentIndex = currentIndex;
+    if (activeItemIndex < 0 || itemCount() <= activeItemIndex) {
+        return;
+    }
 
-        if (animated) {
-            startItemAnimation();
-        }
+    mActiveItemIndex = activeItemIndex;
+    for (int i = 0; i < mItems.count(); ++i) {
+        mItems[i]->setActive(i == activeItemIndex);
     }
 }
+ 
+/*!
+
+*/
+int HsPageIndicator::activeItemIndex() const
+{
+    return mActiveItemIndex;
+}
 
 /*!
-    Sets the item count to \a itemCount. Ie. removes or adds items if 
-    necessary.
-*/
-void HsPageIndicator::setItemCount(int itemCount)
-{
-    if (mItemCount < itemCount) {
-        int count = itemCount - mItemCount;
-        for (int i = 0; i < count; ++i) {
-            addItem(false,false);
-        }
-    } else if (mItemCount > itemCount) {
-        int count = mItemCount - itemCount;
-        for (int i = 0; i < count; ++i) {
-            removeItem(false);
-        }
-    }
-}
 
-/*!
-    Returns the item count
 */
-int HsPageIndicator::itemCount()
+void HsPageIndicator::addItem(int activeItemIndex)
 {
-    return mItemCount;
-}
-
+    if (activeItemIndex < 0 || itemCount() < activeItemIndex) {
+        return;
+    }
 
-/*!
-    Returns current index.
-*/
-int HsPageIndicator::currentIndex()
-{
-    return mCurrentIndex;
-}
-
-/*!
-    Returns true if current item animation is ongoing.
-*/
-bool HsPageIndicator::isAnimatingCurrentItemChange()
-{
-    return mIconAnimationGroup;
+    mItems.append(new HsPageIndicatorItem);
+    layoutItems();
+    setActiveItemIndex(activeItemIndex);
 }
 
 /*!
-    \internal
+
 */
-void HsPageIndicator::resetEffect()
-{
-    QGraphicsLayoutItem *item = mPageIndicatorLayout->itemAt(mCurrentIndex);
-    HbIconItem *iconItem = static_cast<HbIconItem*>(item);
-    if ( iconItem ) {
-        QPointer<QGraphicsEffect> iconEffect = iconItem->graphicsEffect();
-        iconItem->setGraphicsEffect(0);
-        if (iconEffect) {
-            delete iconEffect;
-        }
+void HsPageIndicator::removeItem(int activeItemIndex)
+{   
+    if (activeItemIndex < 0 || itemCount() - 1 <= activeItemIndex) {
+        return;
     }
-    mIconAnimationGroup = 0;
-    emit currentItemChangeAnimationFinished();
+
+    delete mItems.last();
+    mItems.removeLast();
+    layoutItems();
+    setActiveItemIndex(activeItemIndex);
 }
 
 /*!
-    \internal    
+
 */
-void HsPageIndicator::addItemInternal(bool setAsCurrent,int itemIndex,bool animated)
-{    
-    HbIconItem *iconItem = new HbIconItem();
-    iconItem->setIcon(*mNonActiveIcon);
-    iconItem->setPreferredSize(mItemSize);
-    iconItem->setMinimumSize(mItemSize);
-    iconItem->setMaximumSize(mItemSize);
-    
-    mPageIndicatorLayout->addItem(iconItem);
-    if (setAsCurrent) {
-        setCurrentIndex(itemIndex,animated);
-    }
-    layout()->invalidate();
-
-    if (mItemCount < 2) {
-        hide();
-    } else {
-        show();
-    }    
+bool HsPageIndicator::isAnimationRunning() const
+{
+    return mItems.at(mActiveItemIndex)->isAnimationRunning();
 }
 
 /*!
-    \internal    
+
 */
-void HsPageIndicator::startItemAnimation()
+void HsPageIndicator::layoutItems()
 {
-    QGraphicsLayoutItem *item = mPageIndicatorLayout->itemAt(mCurrentIndex);
-    HbIconItem *iconItem = static_cast<HbIconItem*>(item);
-    iconItem->setIcon(*mActiveIcon);
-    
-    QGraphicsBlurEffect* iconBlurEffect = new QGraphicsBlurEffect();
-    iconBlurEffect->setBlurRadius(9);
-    iconItem->setGraphicsEffect(iconBlurEffect);
-    iconItem->setTransformOriginPoint(iconItem->rect().center());
-    
-    mIconAnimationGroup = new QParallelAnimationGroup();
-
-    QPropertyAnimation *animation = new QPropertyAnimation(iconItem, "scale");
-    animation->setDuration(1000);
-    animation->setKeyValueAt(0.5, 2);
-    animation->setEndValue(1.0);
-    mIconAnimationGroup->addAnimation(animation);
-
-    connect(mIconAnimationGroup, SIGNAL(finished()), SLOT(resetEffect()));
-
-    mIconAnimationGroup->start(QAbstractAnimation::DeleteWhenStopped);
-
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
+    layout->setContentsMargins(0, 0, 0, 0);
+    layout->setSpacing(8);
+    layout->addStretch();
+    foreach (HsPageIndicatorItem *item, mItems) {
+        layout->addItem(item);
+    }
+    layout->addStretch();
+    setLayout(layout);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsutils/src/hspageindicatoritem.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,121 @@
+/*
+* 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 <QGraphicsLinearLayout>
+#include <QGraphicsColorizeEffect>
+#include <QPropertyAnimation>
+
+#include <HbIconItem>
+
+#include "hspageindicatoritem.h"
+
+namespace
+{
+    const char gNormalIconName[]    = "qtg_graf_hspage_normal";
+    const char gHighlightIconName[] = "qtg_graf_hspage_highlight";
+}
+
+/*!
+
+*/
+HsPageIndicatorItem::HsPageIndicatorItem(bool active, QGraphicsItem *parent)
+  : HbWidget(parent),
+    mIconItem(0),
+    mIsActive(active)
+{
+    mIconItem = new HbIconItem;
+    if (active) {
+        mIconItem->setIcon(HbIcon(gHighlightIconName));
+    } else {
+        mIconItem->setIcon(HbIcon(gNormalIconName));
+    }
+    
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
+    layout->setContentsMargins(0, 0, 0, 0);
+    layout->addItem(mIconItem);
+    setLayout(layout);
+
+    QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect;
+    effect->setColor(Qt::white);
+    effect->setStrength(0);
+    effect->setEnabled(false);
+    setGraphicsEffect(effect);
+}
+
+/*!
+
+*/
+HsPageIndicatorItem::~HsPageIndicatorItem()
+{
+}
+
+/*!
+
+*/
+void HsPageIndicatorItem::setActive(bool active)
+{
+    if (mIsActive != active) {
+        mIsActive = active;
+        if (mIsActive) {
+            mIconItem->setIcon(HbIcon(gHighlightIconName));
+            startAnimation();
+        } else {
+            mIconItem->setIcon(HbIcon(gNormalIconName));
+        }
+    }
+}
+
+/*!
+
+*/
+bool HsPageIndicatorItem::isActive() const
+{
+    return mIsActive;
+}
+
+
+/*!
+
+*/
+bool HsPageIndicatorItem::isAnimationRunning() const
+{
+    return graphicsEffect()->isEnabled();
+}
+
+/*!
+
+*/
+void HsPageIndicatorItem::startAnimation()
+{
+    graphicsEffect()->setEnabled(true);
+    setTransformOriginPoint(rect().center());
+    QPropertyAnimation *animation = 
+        new QPropertyAnimation(graphicsEffect(), "strength");
+    animation->setDuration(800);
+    animation->setKeyValueAt(0.2, 1);
+    animation->setEndValue(0);
+    connect(animation, SIGNAL(finished()), SLOT(animationFinished()));
+    animation->start(QAbstractAnimation::DeleteWhenStopped);
+}
+
+/*!
+
+*/
+void HsPageIndicatorItem::animationFinished()
+{
+    graphicsEffect()->setEnabled(false);
+}
--- a/homescreenapp/hsutils/src/hstrashbinwidget.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/src/hstrashbinwidget.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -16,12 +16,16 @@
 */
 
 #include <QGraphicsLinearLayout>
+
 #include <HbIconItem>
 
 #include "hstrashbinwidget.h"
 
-const char* KTrashBinNormalItemImageName = "qtg_graf_hs_delete_normal";
-const char* KTrashBinHighlightItemImageName = "qtg_graf_hs_delete_highlight";
+namespace
+{
+    const char gNormalIconName[]    = "qtg_graf_hs_delete_normal";
+    const char gHighlightIconName[] = "qtg_graf_hs_delete_highlight";
+}
 
 /*!
     \internal
@@ -43,14 +47,14 @@
       mHighlightIcon(0),
       mNormalIconVisible(false)
 {
-    mIconItem = new HbIconItem(this);
-
-    mNormalIcon = new HbIcon(KTrashBinNormalItemImageName);
-    mHighlightIcon = new HbIcon(KTrashBinHighlightItemImageName);
-
+    mNormalIcon = new HbIcon(gNormalIconName);
+    mHighlightIcon = new HbIcon(gHighlightIconName);
+    
+    mIconItem = new HbIconItem;
     mIconItem->setIcon(*mNormalIcon);
-    setPreferredSize(80,80); // workaround for icon updating problem when changing theme
-    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
+    
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
+    layout->setContentsMargins(0, 0, 0, 0);
     layout->addItem(mIconItem);
     setLayout(layout);
 }
@@ -61,7 +65,6 @@
 */
 HsTrashBinWidget::~HsTrashBinWidget()
 {
-
 }
 
 /*!
--- a/homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -64,7 +64,8 @@
 */
 QList<QRectF> HsAnchorPointInBottomRight::convert(
     const QRectF &contentArea,
-    const QList<QRectF> &widgets)
+    const QList<QRectF> &rects,
+    const QPointF &startPoint)
 {
     QList<QRectF> toGeometries;
 
@@ -74,30 +75,49 @@
     qreal offset_y = k*offset_x;
     QPointF offsetPoint(offset_x, offset_y);
     
-    QLineF diagonal(contentArea.topLeft(), contentArea.bottomRight());
-    QLineF widgetRight(contentArea.center().x()+ widgets.at(0).width()/2,
-                       contentArea.top(),
-                       contentArea.center().x()+ widgets.at(0).width()/2,
-                       contentArea.bottom());
+    QPointF anchorPoint;
+   
+    if(startPoint.isNull()){
+
+        QLineF diagonal(contentArea.topLeft(), contentArea.bottomRight());
+        QLineF widgetRightSide(contentArea.center().x()+ rects.at(0).width()/2,
+                           contentArea.top(),
+                           contentArea.center().x()+ rects.at(0).width()/2,
+                           contentArea.bottom());
 
-    QPointF anchorPoint;
-    if(QLineF::BoundedIntersection != diagonal.intersect(widgetRight, &anchorPoint)) {
-        return widgets; //Return original since undefined error.
-                        //In this case widget's must be wider than the content area.
+        // right side line intersection with diagonal will be bottom right position
+        // for the first rect
+        if(QLineF::BoundedIntersection != 
+            diagonal.intersect(widgetRightSide, &anchorPoint)) {
+            return rects; //Return original since undefined error.
+                            //In this case widget's must be wider than the content area.
+        }
+    }else{
+        anchorPoint = startPoint - offsetPoint;
     }
 
-    //First widget to the center of the content area
-    foreach (QRectF g, widgets) {
-        g.moveBottomRight(anchorPoint);
-        toGeometries << g;
+    QRectF widgetRect;
+    for(int i=0;i<rects.count();++i) {
+        widgetRect = rects.at(i);
+        widgetRect.moveBottomRight(anchorPoint);
+        //if widget rect doesn't fit, try to move it
+        if(!contentArea.contains(widgetRect)) {
+            /*! precondition is that
+             widget's max height < content area height
+             widget's max widht < content area width
+            */
+            widgetRect.moveBottomRight(contentArea.bottomRight());
+            // anchorPoin is always previous bottom right
+            anchorPoint = widgetRect.bottomRight();
+        }
+        toGeometries << widgetRect;
         anchorPoint -= offsetPoint;
-        if(!contentArea.contains(anchorPoint)) {
-            anchorPoint = contentArea.bottomRight();
-        }
+        
     }
     return toGeometries;
 }
 
+
 /*!
     \class HsAnchorPointInCenter
     \brief Diagonal widget positioning algorithm.
@@ -110,8 +130,11 @@
 #endif //COVERAGE_MEASUREMENT
 QList<QRectF> HsAnchorPointInCenter::convert(
     const QRectF &contentArea,
-    const QList<QRectF> &widgets)
+    const QList<QRectF> &rects,
+    const QPointF &startPoint )
 {
+    Q_UNUSED(startPoint)
+
     QList<QRectF> toGeometries;
 
     //Offset for widgets' centers position to each other
@@ -122,7 +145,7 @@
 
     //First widget to the center of the content area
     QPointF anchorPoint = contentArea.center();
-    foreach (QRectF g, widgets) {
+    foreach (QRectF g, rects) {
         g.moveCenter(anchorPoint);
         toGeometries << g;
         anchorPoint -= offsetPoint;
@@ -133,6 +156,7 @@
     return toGeometries;
 }
 
+
 #ifdef COVERAGE_MEASUREMENT
 #pragma CTC ENDSKIP
 #endif //COVERAGE_MEASUREMENT
--- a/homescreenapp/hsutils/src/xqaiwgetimageclient.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/hsutils/src/xqaiwgetimageclient.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -39,9 +39,9 @@
 XQAIWGetImageClient::XQAIWGetImageClient():
     mImageGrid(0)
 {
-    mImageGrid = new HsImageGridWidget(QStringList(),0);
-    mBackAction = new HbAction(Hb::BackAction, this);
-
+    mImageGrid = new HsImageGridWidget(QStringList(), 0);
+    mBackAction = new HbAction(Hb::BackNaviAction, this);
+    mImageGrid->setNavigationAction(mBackAction);
 }
 
 // ---------------------------------------------------------------------------
@@ -99,22 +99,20 @@
 
     QStringList images;
 
-    foreach(QString imageDir, imageDirs)
-    {
+    foreach (QString imageDir, imageDirs) {
         findImages(QDir(imageDir).absolutePath(), filters, images);
     }
 
-    HbMainWindow *window = HbInstance::instance()->allMainWindows().at(0);
-    window->addSoftKeyAction(Hb::SecondarySoftKey, mBackAction);
-
+    HbMainWindow *window = HbInstance::instance()->allMainWindows().first();
+        
     mImageGrid->setContent(images);
 
-    connect(mImageGrid,SIGNAL(imageSelected(const QString&)),this,SLOT(imageSelected(const QString&)));
+    connect(mImageGrid, SIGNAL(imageSelected(QString)), SLOT(imageSelected(QString)));
 
-    HbInstance::instance()->allMainWindows().at(0)->addView(mImageGrid);
-    HbInstance::instance()->allMainWindows().at(0)->setCurrentView(mImageGrid,false);
+    window->addView(mImageGrid);
+    window->setCurrentView(mImageGrid, false);
 
-    connect(mBackAction,SIGNAL(triggered()),this,SLOT(imageSelectionCancelled()));
+    connect(mBackAction, SIGNAL(triggered()), SLOT(imageSelectionCancelled()));
 }
 
 // ---------------------------------------------------------------------------
@@ -128,10 +126,9 @@
 
     list << val;
 
-    HbMainWindow *window = HbInstance::instance()->allMainWindows().at(0);
+    HbMainWindow *window = HbInstance::instance()->allMainWindows().first();
     window->removeView(mImageGrid);
-    window->removeSoftKeyAction(Hb::SecondarySoftKey, mBackAction);
-
+    
     emit fetchComplete(list);
     QStringList images;
     mImageGrid->setContent(images);
@@ -149,14 +146,12 @@
 {
     mImageGrid->disconnect(this);
 
-    HbMainWindow *window = HbInstance::instance()->allMainWindows().at(0);
+    HbMainWindow *window = HbInstance::instance()->allMainWindows().first();
     window->removeView(mImageGrid);
-    window->removeSoftKeyAction(Hb::SecondarySoftKey, mBackAction);
-
+    
     emit fetchFailed(-1);//KErrNotFound
     QStringList images;
     mImageGrid->setContent(images);
-
 }
 
 // ---------------------------------------------------------------------------
--- a/homescreenapp/inc/hsapp_defs.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/inc/hsapp_defs.h	Fri Apr 16 14:54:01 2010 +0300
@@ -27,6 +27,8 @@
 inline const QString collectionDownloadedTypeName();
 inline const QString menuCollectionsTypeName();
 inline const QString widgetTypeName();
+inline const QString templatedApplicationTypeName();
+inline const QString widgetParam();
 inline const QString openActionIdentifier();
 inline const QString removeActionIdentifier();
 inline const QString itemIdKey();
@@ -54,6 +56,13 @@
     AddHsMenuMode
 };
 
+const int taskSwitcherUid  = 0x2002677D;
+const int taskSwitcherPropertyValue = 1;
+
+const char LIBRARY[] = "library";
+const char URI[] = "uri";
+const char PREFERENCES[] = "preferences";
+
 #include "hsapp_defs.inl"
 
 #endif
--- a/homescreenapp/inc/hsapp_defs.inl	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/inc/hsapp_defs.inl	Fri Apr 16 14:54:01 2010 +0300
@@ -18,6 +18,16 @@
 #ifndef HSAPPDEFS_INL_
 #define HSAPPDEFS_INL_
 
+
+/*!
+\return widget path attribute name
+*/
+inline const QString widgetPathAttributeName()
+{
+    static const QString name("widget:path");
+    return name;
+}
+
 /*!
 \return widget library attribute name
 */
@@ -90,6 +100,24 @@
 }
 
 /*!
+\return temploated application entry type name
+*/
+inline const QString templatedApplicationTypeName()
+{
+    static const QString name("templatedApplication");
+    return name;
+}
+
+/*!
+\return widget param name
+*/
+inline const QString widgetParam()
+{
+    static const QString name("widgetparam:");
+    return name;
+}
+
+/*!
 \return identifier for open an item action
 */
 inline const QString openActionIdentifier()
--- a/homescreenapp/rom/homescreenapp_core.iby	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/rom/homescreenapp_core.iby	Fri Apr 16 14:54:01 2010 +0300
@@ -24,7 +24,7 @@
 data=ZPRIVATE\10003a3f\import\apps\hsapplication_reg.rsc            private\10003a3f\import\apps\hsapplication_reg.rsc
 data=\epoc32\data\z\resource\apps\hsapplication.rsc                 resource\apps\hsapplication.rsc
 data=\epoc32\data\z\resource\apps\hsapplication.mif                 resource\apps\hsapplication.mif
-data=ZPRIVATE\20022f35\homescreendb                                 private\20022f35\homescreendb
+data=ZPRIVATE\20022f35\homescreen.db                                private\20022f35\homescreen.db
 data=ZPRIVATE\20022f35\wallpapers\d_portrait.png                    private\20022f35\wallpapers\d_portrait.png
 data=ZPRIVATE\20022f35\wallpapers\d_landscape.png                   private\20022f35\wallpapers\d_landscape.png
 data=\epoc32\data\z\data\images\kqtihswallpapers\bg_1.png           data\images\kqtihswallpapers\bg_1.png
@@ -39,6 +39,11 @@
 
 file=ABI_DIR\BUILD_DIR\hsdomainmodel.dll                              SHARED_LIB_DIR\hsdomainmodel.dll
 
+// -------- hshomescreenclientplugin
+file=ABI_DIR\BUILD_DIR\hshomescreenclientplugin.dll                 SHARED_LIB_DIR\hshomescreenclientplugin.dll
+data=\epoc32\data\z\hsresources\plugins\homescreenclientplugin\hshomescreenclientplugin.qtplugin    hsresources\plugins\homescreenclientplugin\hshomescreenclientplugin.qtplugin
+data=\epoc32\data\z\hsresources\plugins\homescreenclientplugin\hshomescreenclientplugin.xml    hsresources\plugins\homescreenclientplugin\hshomescreenclientplugin.xml
+
 // ---- runtimeplugins --------------------------------------------
 
 // -------- hsdefaultruntimeplugin
@@ -96,4 +101,12 @@
 file=ABI_DIR\BUILD_DIR\hsanalogclockstyleplugin.dll                                           SHARED_LIB_DIR\hsanalogclockstyleplugin.dll
 data=\epoc32\data\z\hsresources\plugins\styleplugins\hsanalogclockstyleplugin.qtplugin        hsresources\plugins\styleplugins\hsanalogclockstyleplugin.qtplugin
 
+// ---- IMenuClient --------------------------------------------
+
+// -------- hsmenucontentpublish
+file=ABI_DIR\BUILD_DIR\hsmenucontentpublish.dll                                            	  SHARED_LIB_DIR\hsmenucontentpublish.dll 
+data=\epoc32\data\z\hsresources\plugins\hsmenucontentpublishplugin\hsmenucontentpublish.qtplugin       hsresources\plugins\hsmenucontentpublishplugin\hsmenucontentpublish.qtplugin
+data=\epoc32\data\z\hsresources\plugins\hsmenucontentpublishplugin\hsmenucontentpublish.xml      hsresources\plugins\hsmenucontentpublishplugin\hsmenucontentpublish.xml
+
+
 #endif //__HOMESCREENAPP_CORE_IBY__
--- a/homescreenapp/rom/homescreenapp_resources.iby	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/rom/homescreenapp_resources.iby	Fri Apr 16 14:54:01 2010 +0300
@@ -14,8 +14,8 @@
 * Description:
 *
 */
-#ifndef __HOMESCREENAPP_LANGUAGE_IBY__
-#define __HOMESCREENAPP_LANGUAGE_IBY__
+#ifndef __HOMESCREENAPP_RESOURCE_IBY__
+#define __HOMESCREENAPP_RESOURCE_IBY__
 
 #include <data_caging_paths_for_iby.hrh> 
 
--- a/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/inc/hsdefaultruntime.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/inc/hsdefaultruntime.h	Fri Apr 16 14:54:01 2010 +0300
@@ -19,6 +19,7 @@
 #define HSDEFAULTRUNTIME_H
 
 #include <QStateMachine>
+#include <qmobilityglobal.h>
 
 #ifndef HSDEFAULTRUNTIMEPLUGIN_UNITTEST
 	#define TEST_CLASS_FWD
@@ -29,6 +30,11 @@
 #endif
 
 class HsContentService;
+QTM_BEGIN_NAMESPACE
+class QValueSpacePublisher;
+QTM_END_NAMESPACE
+
+QTM_USE_NAMESPACE
 
 TEST_CLASS_FWD
 
@@ -49,6 +55,7 @@
 private:
     Q_DISABLE_COPY(HsDefaultRuntime)
 
+    void createStatePublisher();
     void createContentServiceParts();
     void createStates();
     void assignServices();
@@ -63,6 +70,8 @@
 	
 	bool mHomeScreenActive;
 	bool mIdleStateActive;
+
+	QValueSpacePublisher *mPublisher;
     
     TEST_FRIEND
 };
--- a/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/resource/hsdefaultruntimeplugin.s60xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/resource/hsdefaultruntimeplugin.s60xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>z:/hsresources/plugins/runtimeplugins/hsdefaultruntimeplugin.qtplugin</filepath>
     <description>Homescreen Runtime Plugin</description>
     <interface>
-        <name>com.nokia.homescreen.runtime.HsRuntime</name>
+        <name>com.nokia.symbian.IHomeScreenRuntime</name>
         <version>1.0</version>
         <description>Default implementation for homescreen runtime</description>
         <capabilities></capabilities>
--- a/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/resource/hsdefaultruntimeplugin.xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/resource/hsdefaultruntimeplugin.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>hsdefaultruntimeplugin</filepath>
     <description>Homescreen Runtime Plugin</description>
     <interface>
-        <name>com.nokia.homescreen.runtime.HsRuntime</name>
+        <name>com.nokia.symbian.IHomeScreenRuntime</name>
         <version>1.0</version>
         <description>Default implementation for homescreen runtime</description>
         <capabilities></capabilities>
--- a/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsdefaultruntime.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsdefaultruntime.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -29,6 +29,7 @@
 
 #include "homescreendomainpskeys.h"
 #include "hsdefaultruntime.h"
+#include "hsdatabase.h"
 #include "hscontentservice.h"
 #include "hsshortcutservice.h"
 #include "hsmenueventtransition.h"
@@ -62,16 +63,28 @@
     : QStateMachine(parent),
       mContentService(0),	  
 	  mHomeScreenActive(false),
-	  mIdleStateActive(false)
+	  mIdleStateActive(false),
+	  mPublisher(NULL)
 {
     HSTEST_FUNC_ENTRY("HS::HsDefaultRuntime::HsDefaultRuntime");
 
+    HsDatabase *db = new HsDatabase;
+    db->setConnectionName("homescreen.dbc");
+#ifdef Q_OS_SYMBIAN
+    db->setDatabaseName("c:/private/20022f35/homescreen.db");
+#else
+    db->setDatabaseName("homescreen.db");
+#endif    
+    db->open();
+    HsDatabase::setInstance(db);
+
     HsWidgetPositioningOnOrientationChange::setInstance(
         new HsAdvancedWidgetPositioningOnOrientationChange);
 
     HsWidgetPositioningOnWidgetAdd::setInstance(
         new HsAnchorPointInBottomRight);
 
+    createStatePublisher();
     createContentServiceParts();
     createStates();
     assignServices();
@@ -86,6 +99,7 @@
 HsDefaultRuntime::~HsDefaultRuntime()
 {
     HsWidgetPositioningOnOrientationChange::setInstance(0);
+	delete mPublisher;
 }
 
 /*!
@@ -121,6 +135,21 @@
 }
 
 /*!
+    Creates Home screen state publisher.
+*/
+void HsDefaultRuntime::createStatePublisher()
+{
+    mPublisher = new QValueSpacePublisher(QValueSpace::PermanentLayer, HsStatePSKeyPath);
+
+    if (!mPublisher->isConnected()){
+    	// No permanent layer available
+    	mPublisher = new QValueSpacePublisher(HsStatePSKeyPath);
+    }
+
+    mPublisher->setValue(HsStatePSKeySubPath, EHomeScreenInactive);
+}
+
+/*!
     Creates content service parts.
 */
 void HsDefaultRuntime::createContentServiceParts()
@@ -147,20 +176,24 @@
 
     guiRootState->addTransition(this, SIGNAL(event_exit()), finalState);
 
-    // Workaround to QtSF bug. Create in stack after the bug is fixed.
-    QServiceManager *manager = new QServiceManager(this);
+    QServiceManager manager;
+
     QServiceFilter filter;
 
     filter.setInterface("com.nokia.homescreen.state.HsLoadSceneState");
-    QList<QServiceInterfaceDescriptor> interfaces = manager->findInterfaces(filter);
-    QObject *loadSceneStateObj = manager->loadInterface(interfaces.first().interfaceName());
+#ifdef HSDEFAULTRUNTIMEPLUGIN_UNITTEST
+    filter.setServiceName("mockstateplugins");
+#endif    
+    QList<QServiceInterfaceDescriptor> interfaces = manager.findInterfaces(filter);
+
+    QObject *loadSceneStateObj = manager.loadInterface(interfaces.first());
     QState *loadSceneState = qobject_cast<QState *>(loadSceneStateObj);
     loadSceneState->setParent(guiRootState);
     loadSceneState->setObjectName(interfaces.first().interfaceName());
 
     filter.setInterface("com.nokia.homescreen.state.HsIdleState");
-    interfaces = manager->findInterfaces(filter);
-    QObject *idleStateObj = manager->loadInterface(interfaces.first().interfaceName());
+    interfaces = manager.findInterfaces(filter);
+    QObject *idleStateObj = manager.loadInterface(interfaces.first());
     QState *idleState = qobject_cast<QState *>(idleStateObj);
     idleState->setParent(guiRootState);
     idleState->setObjectName(interfaces.first().interfaceName());
@@ -176,16 +209,16 @@
     QState *menuRootState = new QState(menuParallelState);
 
     filter.setInterface("com.nokia.homescreen.state.HsAppLibraryState");
-    interfaces = manager->findInterfaces(filter);
-    QObject *appLibraryStateObj = manager->loadInterface(interfaces.first().interfaceName());
+    interfaces = manager.findInterfaces(filter);
+    QObject *appLibraryStateObj = manager.loadInterface(interfaces.first());
     QState *appLibraryState = qobject_cast<QState *>(appLibraryStateObj);
     appLibraryState->setParent(menuRootState);
     appLibraryState->setObjectName(interfaces.first().interfaceName());
     menuRootState->setInitialState(appLibraryState);
 
     filter.setInterface("com.nokia.homescreen.state.HsMenuWorkerState");
-    interfaces = manager->findInterfaces(filter);
-    QObject *menuWorkerStateObj = manager->loadInterface(interfaces.first().interfaceName());
+    interfaces = manager.findInterfaces(filter);
+    QObject *menuWorkerStateObj = manager.loadInterface(interfaces.first());
     QState *menuWorkerState = qobject_cast<QState *>(menuWorkerStateObj);
     menuWorkerState->setParent(menuParallelState);
     menuWorkerState->setObjectName(interfaces.first().interfaceName());
@@ -205,7 +238,7 @@
             HsMenuEvent::OpenHomeScreen, appLibraryState, idleState);
     appLibraryState->addTransition(appLibToIdleTransition);
 
-    HbMainWindow *window = hbInstance->allMainWindows().at(0);
+    HbMainWindow *window = hbInstance->allMainWindows().first();
 
     // key driven transition from idle to menu
     QKeyEventTransition *idleToMenuRootTransition =
@@ -270,24 +303,26 @@
 }
 
 /*!
-    
+    Publishes Home screen states via Publish & Subscribe.
 */
 void HsDefaultRuntime::updatePSKeys()
-{
-	QValueSpacePublisher publisher(HsStatePSKeyPath);   
-    		
-    if (mHomeScreenActive && mIdleStateActive){
+{	
+	if (!mPublisher){
+		createStatePublisher();
+	}
+
+	if (mHomeScreenActive && mIdleStateActive){
     	qDebug() << "HsDefaultRuntime::updatePSKeys: EHomeScreenIdleState";
-    	publisher.setValue(HsStatePSKeySubPath, EHomeScreenIdleState);
+    	mPublisher->setValue(HsStatePSKeySubPath, EHomeScreenIdleState);
     }
     else{
     	qDebug() << "HsDefaultRuntime::updatePSKeys: EHomeScreenInactive";
-    	publisher.setValue(HsStatePSKeySubPath, EHomeScreenInactive);
-    }    
+    	mPublisher->setValue(HsStatePSKeySubPath, EHomeScreenInactive);
+    }	
 }
 
 /*!
-    
+    Called when state machine is in Idle state.
 */
 void HsDefaultRuntime::onIdleStateEntered()
 {
@@ -296,7 +331,7 @@
 }
 
 /*!
-    
+    Called when state machine leaves the Idle state.
 */
 void HsDefaultRuntime::onIdleStateExited()
 {
--- a/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsdefaultruntimeplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsdefaultruntimeplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -33,7 +33,7 @@
     Q_UNUSED(context);
     Q_UNUSED(session);
 
-    if (descriptor.interfaceName() == QLatin1String("com.nokia.homescreen.runtime.HsRuntime")) {
+    if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IHomeScreenRuntime")) {
         return new HsDefaultRuntime(this);
     } else {
         return 0;
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -10,7 +10,8 @@
 # Description:
 
 TEMPLATE = lib
-CONFIG += hb
+CONFIG += hb mobility
+MOBILITY += publishsubscribe
 include (../../common.pri)
 DEPENDPATH += . \
     inc \
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice.h	Fri Apr 16 14:54:01 2010 +0300
@@ -49,6 +49,7 @@
     static QString getName(int entryId);
     static bool executeAction(int entryId, const QString &actionName =
                                   openActionIdentifier());
+    static bool launchTaskSwitcher();
 
     static int createCollection(const QString &name);
     static bool renameCollection(int collectionId,
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -17,6 +17,7 @@
 
 #include <QDebug>
 #include <QStandardItem>
+#include <qvaluespacepublisher.h>
 
 #include "hsapp_defs.h"
 #include "hsmenuservice.h"
@@ -26,6 +27,8 @@
 #include "hsmenuitemmodel.h"
 #include "hsmenucollectionsitemmodel.h"
 
+QTM_USE_NAMESPACE
+
 // ======== MEMBER FUNCTIONS ========
 
 // Initialization of a static member variable.
@@ -47,6 +50,7 @@
     query.addEntryTypeName(applicationTypeName());
     query.addEntryTypeName(urlTypeName());
     query.addEntryTypeName(widgetTypeName());
+    query.addEntryTypeName(templatedApplicationTypeName());
     query.setFlagsOn(VisibleEntryFlag);
     query.setFlagsOff(MissingEntryFlag);
     query.setSort(HsMenuServiceUtils::sortBy(sortAttribute),
@@ -168,6 +172,26 @@
 }
 
 /*!
+ Launch task switcher
+ \retval boolean launching status
+ */
+bool HsMenuService::launchTaskSwitcher()
+{
+    qDebug() << "HsMenuService::launchTS";
+    QScopedPointer<CaEntry> tsEntry(new CaEntry);
+    tsEntry->setEntryTypeName(applicationTypeName());
+    tsEntry->setAttribute(
+    		applicationUidEntryKey(), QString::number(taskSwitcherUid)); 
+    int retval = CaService::instance()->executeCommand(*tsEntry, 
+            openActionIdentifier());
+    if(retval) {
+        QValueSpacePublisher publisher("/TaskSwitcher");
+        publisher.setValue("Activation", taskSwitcherPropertyValue);
+    }
+    return retval;
+}
+
+/*!
  Adds new collection
  \param name of the collection
  \retval entryId of new collection
--- a/homescreenapp/sis/homescreenapp.pkg	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/sis/homescreenapp.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -36,7 +36,7 @@
 "/epoc32/data/z/private/10003a3f/import/apps/hsapplication_reg.rsc" - "c:/private/10003a3f/import/apps/hsapplication_reg.rsc"
 "/epoc32/data/z/resource/apps/hsapplication.rsc" - "c:/resource/apps/hsapplication.rsc"
 "/epoc32/data/z/resource/apps/hsapplication.mif" - "c:/resource/apps/hsapplication.mif"
-"/epoc32/data/z/private/20022F35/homescreendb" - "c:/private/20022f35/homescreendb"
+"/epoc32/data/z/private/20022F35/homescreen.db"  - "c:/private/20022f35/homescreen.db"
 "/epoc32/data/z/private/20022f35/wallpapers/1_portrait.png" - "c:/private/20022f35/wallpapers/1_portrait.png"
 "/epoc32/data/z/private/20022f35/wallpapers/1_landscape.png" - "c:/private/20022f35/wallpapers/1_landscape.png"
 "/epoc32/data/z/private/20022f35/wallpapers/2_portrait.png" - "c:/private/20022f35/wallpapers/2_portrait.png"
--- a/homescreenapp/sis/homescreenapp_ut_hs.pkg	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/sis/homescreenapp_ut_hs.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -50,7 +50,7 @@
 "/epoc32/data/z/resource/apps/t_hsdomainmodel.rsc"                       - "c:/resource/apps/t_hsdomainmodel.rsc"
 
 
-"../hsdomainmodel/tsrc/t_hsdomainmodel/testdomainmodeldb" - "c:/private/20022F59/testdomainmodeldb"
+"../hsdomainmodel/tsrc/t_hsdomainmodel/hsdomainmodeltest.db" - "c:/private/20022F59/hsdomainmodeltest.db"
 "../hsdomainmodel/tsrc/t_hsdomainmodel/d_landscape.png" - "c:/private/20022F59/d_landscape.png"
 "../hsdomainmodel/tsrc/t_hsdomainmodel/d_portrait.png" - "c:/private/20022F59/d_portrait.png"
 
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallappsstate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallappsstate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -86,6 +86,8 @@
 
 private slots:
 
+    bool openTaskSwitcher();
+
     /**
      * Slot connected to List widget in normal mode.
      *
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -91,6 +91,8 @@
 
 private slots:
 
+    bool openTaskSwitcher();
+
     /**
      * Slot connected to List widget in normal mode.
      *
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hscollectionstate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hscollectionstate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -89,6 +89,8 @@
 
 private slots:
 
+    bool openTaskSwitcher();
+
     /**
      * Slot connected to List widget.
      *
@@ -239,6 +241,13 @@
     HbAction *mSecondarySoftkeyAction;
 
     /**
+     * Old navigation icon.
+     * Not own.
+     */
+    HbAction *mOldNavigationAction;
+   
+
+    /**
      * Item Model for the List.
      * Own.
      */
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h	Fri Apr 16 14:54:01 2010 +0300
@@ -87,6 +87,8 @@
                          QAbstractItemView::PositionAtTop);
 
 private:
+    HbAbstractItemView::ScrollHint convertScrollHint(
+            QAbstractItemView::ScrollHint hint);
     void connectItemViewsSignals();
     void disconnectItemViewsSignals();
 
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -80,6 +80,9 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::setMenuOptions");
     HbMenu *const mOptions = new HbMenu();
+    mOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
+                        this,
+                        SLOT(openTaskSwitcher()));
     mOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"),
                         this,
                         SLOT(addToCollection()));
@@ -188,6 +191,15 @@
     qDebug("AllAppsState::stateExited()");
 }
 
+/*!
+ Open task switcher.
+ \retval true if operation is successful.
+ */
+bool HsAllAppsState::openTaskSwitcher()
+{
+    return HsMenuService::launchTaskSwitcher();
+}
+
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
@@ -233,7 +245,6 @@
  Handles long-item-pressed event in all apps view by showing context menu
  \param item the event pertains to
  \param position at which context menu is shown
- \retval void
  */
 void HsAllAppsState::listItemLongPressed(HbAbstractViewItem *item,
         const QPointF &coords)
@@ -322,11 +333,16 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addToHomeScreen");
     const CaEntry *entry = mAllAppsModel->entry(index);
-
+    
+    QMap<QString, QString> attributes = entry->attributes();
+    
     machine()-> postEvent(HsMenuEventFactory::createAddToHomeScreenEvent(
-                              entry->id(), entry->entryTypeName(), entry->attribute(
-                                  widgetUriAttributeName()), entry->attribute(
-                                  widgetLibraryAttributeName())));
+                              entry->id(),
+                              entry->entryTypeName(),
+                              entry->attribute(widgetUriAttributeName()),
+                              entry->attribute(widgetLibraryAttributeName()),
+                              &attributes));
+
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addToHomeScreen");
 }
 
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -80,6 +80,9 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsAllCollectionsState::setMenuOptions");
     HbMenu *const options = new HbMenu();
+    options->addAction(hbTrId("txt_applib_opt_task_switcher"),
+                        this,
+                        SLOT(openTaskSwitcher()));
     options->addAction(hbTrId("txt_applib_opt_new_collection"),
                        this, SLOT(createNewCollection()));
 
@@ -203,6 +206,15 @@
     qDebug("AllCollectionsState::stateExited()");
 }
 
+/*!
+ Open task switcher.
+ \retval true if operation is successful.
+ */
+bool HsAllCollectionsState::openTaskSwitcher()
+{
+    return HsMenuService::launchTaskSwitcher();
+}
+
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -55,9 +55,8 @@
         HbInstance::instance()->allMainWindows().value(0);
 
     if (hbW) {
+        mMenuView.view()->setNavigationAction(NULL);
         hbW->removeView(mMenuView.view());
-        hbW->removeSoftKeyAction(Hb::SecondarySoftKey,
-                                 mSecondarySoftkeyAction);
     }
 }
 
@@ -155,8 +154,8 @@
     HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
     if (!hbW->views().contains(mMenuView.view())) {
         hbW->addView(mMenuView.view());
-    }
-    hbW->addSoftKeyAction(Hb::SecondarySoftKey, mSecondarySoftkeyAction);
+        mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction);
+    }    
     hbW->setCurrentView(mMenuView.view());
     HSTEST_FUNC_EXIT("AppLibraryState::stateEntered");
 }
@@ -166,14 +165,7 @@
 //
 void HsAppLibraryState::stateExited()
 {
-    HSTEST_FUNC_ENTRY("AppLibraryState::stateExited");
-    HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
-
-    //when exiting the pointer can be NULL
-    if (hbW) {
-        hbW->removeSoftKeyAction(Hb::SecondarySoftKey,
-                                 mSecondarySoftkeyAction);
-    }
+    HSTEST_FUNC_ENTRY("AppLibraryState::stateExited");   
     HSTEST_FUNC_EXIT("AppLibraryState::stateExited");
 }
 
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -122,6 +122,9 @@
 
     if (!mOptions) {
         mOptions = new HbMenu();
+        mOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
+                            this,
+                            SLOT(openTaskSwitcher()));
 
         EntryFlags flags =
             mCollectionModel->root().data(CaItemModel::FlagsRole).value<
@@ -170,13 +173,9 @@
         mOptions->setParent(this);
         mMenuView.view()->setMenu(mOptions);
     }
-
-    HbMainWindow *hbMainWindow =
-        HbInstance::instance()->allMainWindows().value(0);
-    // add BackStepping action
-
-    hbMainWindow->addSoftKeyAction(Hb::SecondarySoftKey,
-                                   mSecondarySoftkeyAction);
+    mOldNavigationAction = mMenuView.view()->navigationAction();
+    mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction);
+    
     makeConnect();
     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateEntered");
 }
@@ -194,12 +193,9 @@
     mMenuView.view()->setMenu(NULL);
     mMenuView.setLabelVisible(false);
 
-    HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
-    if (hbW) {
-        //remove BackStepping action
-        hbW->removeSoftKeyAction(Hb::SecondarySoftKey,
-                                 mSecondarySoftkeyAction);
-    }
+    // revert navigation action
+    mMenuView.view()->setNavigationAction(mOldNavigationAction);
+
     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateExited");
     qDebug("CollectionState::stateExited()");
 }
@@ -236,6 +232,15 @@
                this, SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
 }
 
+/*!
+ Open task switcher.
+ \retval true if operation is successful.
+ */
+bool HsCollectionState::openTaskSwitcher()
+{
+    return HsMenuService::launchTaskSwitcher();
+}
+
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
@@ -386,14 +391,16 @@
 void HsCollectionState::addElementToHomeScreen(const QModelIndex &index)
 {
     const CaEntry *entry = mCollectionModel->entry(index);
+    
+    QMap<QString, QString> attributes = entry->attributes();
 
-    machine()->
-    postEvent(
+    machine()->postEvent(
         HsMenuEventFactory::createAddToHomeScreenEvent(
             entry->id(),
             entry->entryTypeName(),
             entry->attribute(widgetUriAttributeName()),
-            entry->attribute(widgetLibraryAttributeName())));
+            entry->attribute(widgetLibraryAttributeName()),
+            &attributes));
 }
 
 /*!
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -287,14 +287,33 @@
   */
 void HsMenuView::scrollToRow(int row, QAbstractItemView::ScrollHint hint)
 {
-    // TODO: remove hint from the interface
-    Q_UNUSED(hint);
     HSMENUTEST_FUNC_ENTRY("HsMenuView::scrollToRow");
-    scrollTo(mModel->index(row), HbAbstractItemView::PositionAtTop);
+    scrollTo(mModel->index(row), convertScrollHint(hint));
     HSMENUTEST_FUNC_EXIT("HsMenuView::scrollToRow");
 }
 
 /*!
+     Converts scroll hints.
+     \param Qt hint Where the target item should be positioned in visible area
+     after scroll.
+     \return Qrbit version of hint
+ */
+HbAbstractItemView::ScrollHint HsMenuView::convertScrollHint(
+        QAbstractItemView::ScrollHint hint)
+{
+    switch (hint) {
+    case QAbstractItemView::EnsureVisible:
+        return HbAbstractItemView::EnsureVisible;
+    case QAbstractItemView::PositionAtTop:
+        return HbAbstractItemView::PositionAtTop;
+    case QAbstractItemView::PositionAtBottom:
+        return HbAbstractItemView::PositionAtBottom;
+    default:
+        return HbAbstractItemView::PositionAtCenter;
+    }
+}
+
+/*!
  Connects \a activated and \a longPressed signals coming from list
  view to trigger corresponding signal of this object.
 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hshomescreenstatecommon.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HSHOMESCREENSTATECOMMON_H
+#define HSHOMESCREENSTATECOMMON_H
+
+#define HSBOUNDARYEFFECT 20 // amount of extra pixels in wallpaper width reserved for boundary effect 
+
+#endif // HSHOMESCREENSTATECOMMON_H
\ No newline at end of file
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlestate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlestate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -53,6 +53,7 @@
     void event_toggleConnection();
 
 private:
+    Q_DISABLE_COPY(HsIdleState)
     void setupStates();
     qreal pageLayerXPos(int pageIndex) const;
     void startPageChangeAnimation(int targetPageIndex, int duration);
@@ -86,6 +87,7 @@
     void action_moveWidget_startWidgetDragAnimation();
     void action_moveWidget_connectMouseEventHandlers();
     void action_moveWidget_connectGestureTimers();
+
     void action_moveWidget_reparentToPage();
     void action_moveWidget_startWidgetDropAnimation();
     void action_moveWidget_disconnectMouseEventHandlers();
@@ -129,7 +131,7 @@
 
 private:
     HbView *mView;
-    HbAction *mSoftKeyAction;
+    HbAction *mNavigationAction;
     HsIdleWidget *mUiWidget;
     
     QTimer mTimer;
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlewidget.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlewidget.h	Fri Apr 16 14:54:01 2010 +0300
@@ -68,6 +68,7 @@
     void polishEvent();
 
 private:
+    Q_DISABLE_COPY(HsIdleWidget)
     void loadControlLayer();
     void setItemsUnfocusable(QGraphicsSceneMouseEvent *event);
     void setItemsFocusable();
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsselectbackgroundstate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsselectbackgroundstate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:  SelectBackground gui state.
+* Description:
 *
 */
 
@@ -24,10 +24,9 @@
 
 HOMESCREEN_TEST_CLASS(HomeScreenStatePluginTest)
 
+class QImage;
 class HbView;
-class HsContentService;
 class XQAIWGetImageClient;
-class QImage;
 
 class HsSelectBackgroundState : public QState
 {
@@ -41,16 +40,18 @@
     void event_waitInput();
 
 private:
+    Q_DISABLE_COPY(HsSelectBackgroundState)
     bool saveImage(QImage &image, const QString &path, Qt::Orientation orientation);
 
 private slots:
-    void selectPageBackgroundAction();
-    void disconnectImageFetcherAction();
-    void onBackgroundImageFetched(QStringList);
-    void onBackgroundImageFetchFailed(int);
+    void action_selectWallpaper();
+    void action_disconnectImageFetcher();
+
+    void onFetchComplete(QStringList imageStringList);
+    void onFetchFailed(int error);
 
 private:
-    XQAIWGetImageClient *mXQAIWGetImageClient;
+    XQAIWGetImageClient *mImageFetcher;
     HbView *mSourceView;
 
     HOMESCREEN_TEST_FRIEND_CLASS(HomeScreenStatePluginTest)
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -31,17 +31,18 @@
 
 #include "hsidlestate.h"
 #include "hsidlewidget.h"
+#include "hsdomainmodeldatastructures.h"
 #include "hsscene.h"
 #include "hspage.h"
 #include "hswidgethost.h"
 #include "hswallpaper.h"
-#include "hspagedata.h"
 #include "hsselectbackgroundstate.h"
 #include "hstrashbinwidget.h"
 #include "hspageindicator.h"
 #include "hsapptranslator.h"
 #include "hswidgetpositioningonorientationchange.h"
 #include "hsmenueventfactory.h"
+#include "hshomescreenstatecommon.h"
 
 // Helper macros for connecting state entry and exit actions.
 #define ENTRY_ACTION(state, action) \
@@ -51,31 +52,23 @@
 
 // Helper macros for connecting and disconnecting mouse event handlers.
 #define CONNECT_MOUSE_EVENT_HANDLER(signal, slot) \
-    connect(mUiWidget, SIGNAL(signal(QGraphicsItem*, QGraphicsSceneMouseEvent*, bool&)), \
-        SLOT(slot(QGraphicsItem*, QGraphicsSceneMouseEvent*, bool&)));
+    connect(mUiWidget, SIGNAL(signal(QGraphicsItem*,QGraphicsSceneMouseEvent*,bool&)), \
+        SLOT(slot(QGraphicsItem*,QGraphicsSceneMouseEvent*,bool&)));
 #define DISCONNECT_MOUSE_EVENT_HANDLER(signal, slot) \
-    disconnect(mUiWidget, SIGNAL(signal(QGraphicsItem*, QGraphicsSceneMouseEvent*, bool&)), \
-        this, SLOT(slot(QGraphicsItem*, QGraphicsSceneMouseEvent*, bool&)));
+    disconnect(mUiWidget, SIGNAL(signal(QGraphicsItem*,QGraphicsSceneMouseEvent*,bool&)), \
+        this, SLOT(slot(QGraphicsItem*,QGraphicsSceneMouseEvent*,bool&)));
 
 
 namespace
 {
-    const char APP_LIB_BUTTON[] = 
-        "hs_applib_button.png";
-    /*const char TXT_HOMESCREEN_TITLE_OFFLINE[] = 
-        "txt_homescreen_title_offline";*/
-    const char TXT_HOMESCREEN_OPT_ADD_PAGE[] = 
-        "txt_homescreen_opt_add_page";
-    const char TXT_HOMESCREEN_OPT_REMOVE_PAGE[] = 
-        "txt_homescreen_opt_remove_page";
-    const char TXT_HOMESCREEN_OPT_HOME_SCREEN_TO_ONLINE[] = 
-        "txt_homescreen_opt_home_screen_to_online";
-    const char TXT_HOMESCREEN_OPT_HOME_SCREEN_TO_OFFLINE[] = 
-        "txt_homescreen_opt_home_screen_to_offline";
-    const char TXT_HOMESCREEN_LIST_CHANGE_WALLPAPER[] = 
-        "txt_homescreen_list_change_wallpaper";
-    const char TXT_HOMESCREEN_LIST_ADD_CONTENT[] = 
-        "txt_homescreen_list_add_content";
+    const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
+    const char gAddPageTextName[]            = "txt_homescreen_opt_add_page";
+    const char gRemovePageTextName[]         = "txt_homescreen_opt_remove_page";
+    const char gToOnlineTextName[]           = "txt_homescreen_opt_home_screen_to_online";
+    const char gToOfflineTextName[]          = "txt_homescreen_opt_home_screen_to_offline";
+    const char gChangeWallpaperTextName[]    = "txt_homescreen_list_change_wallpaper";
+    const char gAddContentTextName[]         = "txt_homescreen_list_add_content";
+    //const char gTitleOfflineTextName[]       = "txt_homescreen_title_offline";
 }
 
 /*!
@@ -94,7 +87,7 @@
 */
 HsIdleState::HsIdleState(QState *parent)
   : QState(parent),
-    mView(0), mSoftKeyAction(0), mUiWidget(0),
+    mView(0), mNavigationAction(0), mUiWidget(0),
     mTapAndHoldDistance(16),
     mPageChangeZoneWidth(60)
 {
@@ -268,6 +261,7 @@
     ENTRY_ACTION(state_moveWidget, action_moveWidget_startWidgetDragAnimation)
     ENTRY_ACTION(state_moveWidget, action_moveWidget_connectMouseEventHandlers)
     ENTRY_ACTION(state_moveWidget, action_moveWidget_connectGestureTimers)
+
     EXIT_ACTION(state_moveWidget, action_moveWidget_reparentToPage)
     EXIT_ACTION(state_moveWidget, action_moveWidget_startWidgetDropAnimation)
     EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectMouseEventHandlers)
@@ -313,7 +307,7 @@
     animationGroup->addAnimation(animation);
 
     animation = new QPropertyAnimation(mUiWidget->sceneLayer(), "x");
-    animation->setEndValue(parallaxFactor() * pageLayerXPos(targetPageIndex));
+    animation->setEndValue((parallaxFactor() * pageLayerXPos(targetPageIndex)) - HSBOUNDARYEFFECT / 2);
     animation->setDuration(duration);
     animationGroup->addAnimation(animation);
         
@@ -362,7 +356,7 @@
 void HsIdleState::addPageToScene(int pageIndex)
 {
     HsPageData data;
-    data.setIndex(pageIndex);
+    data.indexPosition = pageIndex;
     HsPage *page = HsPage::createInstance(data);
     page->load();
     HsScene::instance()->addPage(page);    
@@ -376,7 +370,7 @@
 qreal HsIdleState::parallaxFactor() const
 {
     qreal clw = mUiWidget->controlLayer()->size().width();
-    qreal slw = mUiWidget->sceneLayer()->size().width();
+    qreal slw = mUiWidget->sceneLayer()->size().width() - HSBOUNDARYEFFECT;
     int n = HsScene::instance()->pages().count();
     if (n < 2) {
         return 1;
@@ -412,11 +406,12 @@
         mUiWidget = new HsIdleWidget;
         mView = HsScene::mainWindow()->addView(mUiWidget);
         mView->setContentFullScreen();
-        mView->setTitle("Home Screen"/*hbTrId(TXT_HOMESCREEN_TITLE_OFFLINE)*/);
+        mView->setTitle("Home Screen"/*hbTrId(gTitleOfflineTextName)*/);
         
-        mSoftKeyAction = new HbAction(this);
-        mSoftKeyAction->setIcon(HbIcon(APP_LIB_BUTTON));
-        connect(mSoftKeyAction, SIGNAL(triggered()), SIGNAL(event_applicationLibrary()));
+        mNavigationAction = new HbAction(this);
+        mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName));
+        connect(mNavigationAction, SIGNAL(triggered()), SIGNAL(event_applicationLibrary()));
+        mView->setNavigationAction(mNavigationAction);
         
 #ifndef Q_OS_SYMBIAN
         connect(HsAppTranslator::instance(), 
@@ -426,7 +421,6 @@
         QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
     }
 
-    HsScene::mainWindow()->addSoftKeyAction(Hb::SecondarySoftKey, mSoftKeyAction);
     HsScene::mainWindow()->setCurrentView(mView);
 }
 
@@ -452,7 +446,7 @@
     }
 
     page->layoutNewWidgets();
-    page->resetNewWidgets();
+
 }
 
 /*!
@@ -463,7 +457,7 @@
 {
     qreal x = pageLayerXPos(HsScene::instance()->activePageIndex());
     mUiWidget->pageLayer()->setX(x);
-    mUiWidget->sceneLayer()->setX(parallaxFactor() * x);
+    mUiWidget->sceneLayer()->setX((parallaxFactor() * x) - HSBOUNDARYEFFECT / 2);
 }
 
 /*!
@@ -481,8 +475,6 @@
 */
 void HsIdleState::action_idle_cleanupView()
 {
-    HsScene::mainWindow()->removeSoftKeyAction(
-        Hb::SecondarySoftKey, mSoftKeyAction);
 }
 
 /*!
@@ -500,19 +492,28 @@
 */
 void HsIdleState::action_waitInput_updateOptionsMenu()
 {
+    HsScene *scene = HsScene::instance();
+
     HbMenu *menu = new HbMenu();
     
-    menu->addAction(hbTrId(TXT_HOMESCREEN_OPT_ADD_PAGE), 
-        this, SIGNAL(event_addPage()));
-    menu->addAction(hbTrId(TXT_HOMESCREEN_OPT_REMOVE_PAGE), 
-        this, SIGNAL(event_removePage()))->setEnabled(
-        HsScene::instance()->activePage()->isRemovable());
-        
-    if (HsScene::instance()->isOnline()) {
-        menu->addAction(hbTrId(TXT_HOMESCREEN_OPT_HOME_SCREEN_TO_OFFLINE),
+    // Add page
+    if (scene->pages().count() < scene->maximumPageCount()) {
+        menu->addAction(hbTrId(gAddPageTextName), 
+            this, SIGNAL(event_addPage()));
+    }
+
+    // Remove page
+    if (scene->activePage()->isRemovable()) {
+        menu->addAction(hbTrId(gRemovePageTextName), 
+            this, SIGNAL(event_removePage()));
+    }
+    
+    // Online / Offline
+    if (scene->isOnline()) {
+        menu->addAction(hbTrId(gToOfflineTextName),
             this, SIGNAL(event_toggleConnection()));
     } else {
-        menu->addAction(hbTrId(TXT_HOMESCREEN_OPT_HOME_SCREEN_TO_ONLINE),
+        menu->addAction(hbTrId(gToOnlineTextName),
             this, SIGNAL(event_toggleConnection())); 
     }
 
@@ -728,9 +729,9 @@
     HbMenu menu;
 
     HbAction *changeWallpaperAction = 
-        menu.addAction(hbTrId(TXT_HOMESCREEN_LIST_CHANGE_WALLPAPER));
+        menu.addAction(hbTrId(gChangeWallpaperTextName));
     HbAction *addContentAction = 
-        menu.addAction(hbTrId(TXT_HOMESCREEN_LIST_ADD_CONTENT));
+        menu.addAction(hbTrId(gAddContentTextName));
 
     HbAction *action = menu.exec(mSceneMenuPos);
     if (action == changeWallpaperAction) {
@@ -756,7 +757,8 @@
     addPageToScene(pageIndex);    
     scene->setActivePageIndex(pageIndex);
     startPageChangeAnimation(pageIndex, 700);
-    mUiWidget->pageIndicator()->addItem(true, true);
+    mUiWidget->pageIndicator()->addItem(pageIndex);
+    mUiWidget->showPageIndicator();
 }
 
 /*!
@@ -770,7 +772,6 @@
 
     mUiWidget->removePage(pageIndex);
     scene->removePage(page);
-    page->deleteFromDatabase();
     delete page;
 
     pageIndex = pageIndex == 0 ? 0 : pageIndex - 1;
@@ -778,8 +779,9 @@
 
     startPageChangeAnimation(pageIndex, 200);
 
-    mUiWidget->pageIndicator()->removeItem();
+    mUiWidget->pageIndicator()->removeItem(pageIndex);
     mUiWidget->setActivePage(pageIndex);
+    mUiWidget->showPageIndicator();
 }
 
 /*!
@@ -843,7 +845,7 @@
     }
 
     QPointF point = 
-        event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton);
+        event->scenePos() - event->buttonDownScenePos(Qt::LeftButton);
     if (mTapAndHoldDistance < point.manhattanLength()) {
         mTimer.stop();
         mUiWidget->sendDelayedPress();
@@ -892,7 +894,7 @@
     }
 
     QPointF point = 
-        event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton);
+        event->scenePos() - event->buttonDownScenePos(Qt::LeftButton);
     if (mTapAndHoldDistance < point.manhattanLength()) {
         mTimer.stop();
         mUiWidget->clearDelayedPress();
@@ -936,7 +938,7 @@
     HsWidgetHost *widget = HsScene::instance()->activeWidget();
     Q_ASSERT(widget);
 
-    QPointF delta(event->screenPos() - event->lastScreenPos());
+    QPointF delta(event->scenePos() - event->lastScenePos());
     QRectF region =  mView->rect().adjusted(10, 55, -10, -10);
     QPointF position = widget->geometry().center() + delta;
     if (!region.contains(position)) {
@@ -962,7 +964,7 @@
         mUiWidget->trashBin()->deactivate();
     }
 
-    if (!mUiWidget->pageIndicator()->isAnimatingCurrentItemChange()) {
+    if (!mUiWidget->pageIndicator()->isAnimationRunning()) {
         mUiWidget->showTrashBin();
     }
 }
@@ -1023,14 +1025,14 @@
     
     HsScene *scene = HsScene::instance();
     qreal delta = 
-        event->screenPos().x() - event->buttonDownScreenPos(Qt::LeftButton).x();
-    
-    qreal x = qBound(pageLayerXPos(scene->pages().count() - 1),
+        event->scenePos().x() - event->buttonDownScenePos(Qt::LeftButton).x();
+
+    qreal x = qBound(pageLayerXPos(scene->pages().count() - 1) - HSBOUNDARYEFFECT / 2 / parallaxFactor(),
                      pageLayerXPos(scene->activePageIndex()) + delta,
-                     pageLayerXPos(0));
-    
+                     pageLayerXPos(0) + (HSBOUNDARYEFFECT / 2 / parallaxFactor()) - qreal(0.5));
+
     mUiWidget->pageLayer()->setX(x);
-    mUiWidget->sceneLayer()->setX(parallaxFactor() * x);
+    mUiWidget->sceneLayer()->setX((parallaxFactor() * x) - HSBOUNDARYEFFECT / 2);
 }
 
 /*!
@@ -1051,10 +1053,10 @@
     int pageIndex = HsScene::instance()->activePageIndex();
 
     QPointF delta(
-        event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton));
-    if (delta.x() < -pageSize.width() / 2) {
+        event->scenePos() - event->buttonDownScenePos(Qt::LeftButton));
+    if (delta.x() < -pageSize.width() / 3) {
         pageIndex = qMin(pageIndex + 1, pages.count() - 1);
-    } else if(pageSize.width() / 2 < delta.x()) {
+    } else if (pageSize.width() / 3 < delta.x()) {
         pageIndex = qMax(pageIndex - 1, 0);
     }
 
@@ -1075,22 +1077,25 @@
     QList<HsWidgetHost *> widgets;
     HsWidgetHost *widget = 0;
     
+    const int KChromeHeight = 64; // TODO: get this somewhere
+    const int KWidgetAdjust = 10; // TODO: get this somewhere
+    
     for (int i = 0; i < pages.count(); ++i) {        
         widgets = pages[i]->widgets();
         for (int j = 0; j < widgets.count(); ++j) {
             widget = widgets[j];
             HsWidgetPresentationData presentation = widget->widgetPresentation(orientation);
-            if (presentation.id() < 0) {
+            if (presentation.widgetId < 0) {
                 QList<QRectF> geometries = 
                     HsWidgetPositioningOnOrientationChange::instance()->convert(
-                        pages[i]->rect().adjusted(10, 10, -10, -10), QList<QRectF>() << widget->geometry(),
-                        QRectF(0, 0, pages[i]->rect().height() + 40, 
-                        pages[i]->rect().width() - 40).adjusted(10, 10, -10, -10));
+                        QRectF(0, KChromeHeight, pages[i]->rect().height(), pages[i]->rect().width()-KChromeHeight).adjusted(KWidgetAdjust, KWidgetAdjust, -KWidgetAdjust, -KWidgetAdjust),
+                        QList<QRectF>() << widget->geometry(),
+                        QRectF(0, KChromeHeight, pages[i]->rect().width(), pages[i]->rect().height()-KChromeHeight).adjusted(KWidgetAdjust, KWidgetAdjust, -KWidgetAdjust, -KWidgetAdjust));
                 widget->setGeometry(geometries.first());
                 widget->setWidgetPresentation();
             } else {
-                widget->setGeometry(QRectF(presentation.position(), presentation.size()));
-                widget->setZValue(presentation.zValue());
+                widget->setGeometry(presentation.geometry());
+                widget->setZValue(presentation.zValue);
             }
         }
     }
@@ -1138,10 +1143,12 @@
     if (pageIndex == scene->pages().count()) {
         if (scene->pages().last()->widgets().isEmpty()) {
             return;
-        } else {
+        } else if (scene->pages().count() < scene->maximumPageCount()) {
             addPageToScene(pageIndex);
             mUiWidget->showPageIndicator();
-            mUiWidget->pageIndicator()->addItem(true);
+            mUiWidget->pageIndicator()->addItem(pageIndex);
+        } else {
+            return; 
         }
     }
 
@@ -1192,7 +1199,7 @@
 */
 void HsIdleState::translateUi()
 {
-    mView->setTitle("Home Screen"/*hbTrId(TXT_HOMESCREEN_TITLE_OFFLINE)*/);
+    mView->setTitle("Home Screen"/*hbTrId(gTitleOfflineTextName)*/);
     action_waitInput_updateOptionsMenu();
 }
 #ifdef COVERAGE_MEASUREMENT
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlewidget.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlewidget.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -15,12 +15,13 @@
 *
 */
 
+#include <QApplication>
 #include <QGraphicsSceneMouseEvent>
 #include <QGraphicsLinearLayout>
 #include <QDir>
 
 #include <HbMainWindow>
-#include <HbInputMethod>
+#include <HbVkbHost>
 
 #include "hsidlewidget.h"
 #include "hsscene.h"
@@ -30,13 +31,14 @@
 #include "hstrashbinwidget.h"
 #include "hspageindicator.h"
 #include "hsdocumentloader.h"
+#include "hshomescreenstatecommon.h"
 
 namespace
 {
-    const char CONTROL_LAYER_DOCML_FILE[] = "controllayer.docml";
-    const char CONTROL_LAYER[] = "controlLayer";
-    const char TRASH_BIN[] = "trashBin";
-    const char PAGE_INDICATOR[] = "pageIndicator";
+    const char gControlLayerDocmlName[] = "controllayer.docml";
+    const char gControlLayerName[]      = "controlLayer";
+    const char gTrashBinName[]          = "trashBin";
+    const char gPageIndicatorName[]     = "pageIndicator";
 }
 
 /*!
@@ -109,7 +111,7 @@
     int n = HsScene::instance()->pages().count();
     mControlLayer->resize(rect.size());
     mPageLayer->resize(n * rect.width(), rect.height());
-    mSceneLayer->resize(2 * rect.width(), rect.height());
+    mSceneLayer->resize(2 * rect.width() + HSBOUNDARYEFFECT, rect.height());
     HbWidget::setGeometry(rect);
 }
 
@@ -153,7 +155,7 @@
 */
 void HsIdleWidget::setActivePage(int index)
 {
-    mPageIndicator->setCurrentIndex(index);
+    mPageIndicator->setActiveItemIndex(index);
 }
 
 /*!
@@ -265,8 +267,7 @@
 {
     Q_UNUSED(object)
 
-    if (HbInputMethod::activeInputMethod() &&
-        HbInputMethod::activeInputMethod()->focusObject()) {
+    if (HbVkbHost::activeVkbHost()) {
         setFiltersChildEvents(false);
         return false;
     }
@@ -338,8 +339,7 @@
     HsWallpaper *wallpaper = HsScene::instance()->wallpaper();
     layout->addItem(wallpaper);
            
-    mPageIndicator->setItemCount(pages.count());
-    setActivePage(scene->activePageIndex());
+    mPageIndicator->initialize(pages.count(), scene->activePageIndex());    
     showPageIndicator();
 
     HsScene::mainWindow()->scene()->installEventFilter(this);
@@ -359,8 +359,8 @@
     QString path = "c:";
 #endif
 
-    QString file = path + "/hsresources/" + CONTROL_LAYER_DOCML_FILE;
-    QString fallbackPath = QString(":/") + CONTROL_LAYER_DOCML_FILE;
+    QString file = path + "/hsresources/" + gControlLayerDocmlName;
+    QString fallbackPath = QString(":/") + gControlLayerDocmlName;
 
     if (QFile::exists(file)) {
         loader.load(file, &loaded);
@@ -372,14 +372,14 @@
     }
 
     if (loaded) {
-        mControlLayer = qobject_cast<HbWidget *>(loader.findWidget(CONTROL_LAYER));
+        mControlLayer = qobject_cast<HbWidget *>(loader.findWidget(gControlLayerName));
         mControlLayer->setZValue(2);
         mControlLayer->setParentItem(this);
 
-        mTrashBin = qobject_cast<HsTrashBinWidget *>(loader.findWidget(TRASH_BIN));
+        mTrashBin = qobject_cast<HsTrashBinWidget *>(loader.findWidget(gTrashBinName));
         mTrashBin->setZValue(1e6);
 
-        mPageIndicator = qobject_cast<HsPageIndicator *>(loader.findWidget(PAGE_INDICATOR));
+        mPageIndicator = qobject_cast<HsPageIndicator *>(loader.findWidget(gPageIndicatorName));
         mPageIndicator->setZValue(1e6);
     } else {
         // TODO: Handle error.
@@ -393,18 +393,33 @@
 void HsIdleWidget::setItemsUnfocusable(QGraphicsSceneMouseEvent *event)
 {
     mFocusableItems.clear();
-    QList<QGraphicsItem *> items = 
-        HsScene::mainWindow()->scene()->items(event->scenePos());
+
+    if (!scene()) {
+        return;
+    }
+
+    QList<QGraphicsItem *> items = scene()->items(event->scenePos());
+    if (items.isEmpty()) {
+        return;
+    }
+
     int i = 0;
-    while (!mPageLayer->isAncestorOf(items[i++])) {}
+    for (; i < items.count(); ++i) {
+        if (mPageLayer->isAncestorOf(items[i])) {
+            ++i;
+            break;
+        }
+    }
+ 
     HsPage *page = HsScene::instance()->activePage();
     QList<HsWidgetHost *> widgets = page->widgets();
+    
     for (; i < items.count(); ++i) {
         QGraphicsItem *item = items.at(i);
         if (page->isAncestorOf(item)) {
             foreach (HsWidgetHost *widget, widgets) {
                 if ((item == widget || widget->isAncestorOf(item))&& item->isEnabled() && (item->flags() & QGraphicsItem::ItemIsFocusable)) {
-                    if (!item->isWidget() || static_cast<QGraphicsWidget*>(item)->focusPolicy() & Qt::ClickFocus) {
+                    if (!item->isWidget() || static_cast<QGraphicsWidget *>(item)->focusPolicy() & Qt::ClickFocus) {
                         item->setFlag(QGraphicsItem::ItemIsFocusable, false);
                         mFocusableItems.append(item);
                     }
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsselectbackgroundstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsselectbackgroundstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -23,9 +23,10 @@
 
 #include "hsselectbackgroundstate.h"
 #include "hsscene.h"
-#include "hsscenedata.h"
+#include "hsdomainmodeldatastructures.h"
 #include "hswallpaper.h"
 #include "hsdatabase.h"
+#include "hshomescreenstatecommon.h"
 
 #include "xqaiwgetimageclient.h"
 #include "xqaiwcommon.h"
@@ -44,12 +45,12 @@
 */
 HsSelectBackgroundState::HsSelectBackgroundState(QState *parent):
     QState(parent),
-    mXQAIWGetImageClient(0),
+    mImageFetcher(0),
     mSourceView(0)
 {
-    mXQAIWGetImageClient = new XQAIWGetImageClient;
-    connect(this, SIGNAL(entered()), SLOT(selectPageBackgroundAction()));
-    connect(this, SIGNAL(exited()), SLOT(disconnectImageFetcherAction()));
+    mImageFetcher = new XQAIWGetImageClient;
+    connect(this, SIGNAL(entered()), SLOT(action_selectWallpaper()));
+    connect(this, SIGNAL(exited()), SLOT(action_disconnectImageFetcher()));
 }
 
 /*!
@@ -58,7 +59,7 @@
 */
 HsSelectBackgroundState::~HsSelectBackgroundState()
 {
-    delete mXQAIWGetImageClient;
+    delete mImageFetcher;
 }
 
 /*!
@@ -70,9 +71,9 @@
 {
     QRect rect;
     if (orientation == Qt::Vertical) {
-        rect.setRect(0, 0, 2 * 360, 640);
+        rect.setRect(0, 0, (2* 360) + HSBOUNDARYEFFECT, 640);
     } else {
-        rect.setRect(0, 0, 2 * 640, 360);
+        rect.setRect(0, 0, (2 * 640) + HSBOUNDARYEFFECT, 360);
     }
 
     if (image.rect().contains(rect)) {        
@@ -90,17 +91,16 @@
     Connects to image fetcher and launches "remote" ui from photos
     from which user can select background image
  */
-void HsSelectBackgroundState::selectPageBackgroundAction()
+void HsSelectBackgroundState::action_selectWallpaper()
 {
     mSourceView = HsScene::mainWindow()->currentView();
 
-    connect(mXQAIWGetImageClient, SIGNAL(fetchComplete(QStringList)),
-            SLOT(onBackgroundImageFetched(QStringList)));
-    connect(mXQAIWGetImageClient, SIGNAL(fetchFailed(int)),
-            SLOT(onBackgroundImageFetchFailed(int)));
+    connect(mImageFetcher, SIGNAL(fetchComplete(QStringList)),
+            SLOT(onFetchComplete(QStringList)));
+    connect(mImageFetcher, SIGNAL(fetchFailed(int)),
+            SLOT(onFetchFailed(int)));
     
-    QVariantMap filter;
-    mXQAIWGetImageClient->fetch(filter, SelectionSingle);
+    mImageFetcher->fetch(QVariantMap(), SelectionSingle);
 }
 
 /*!
@@ -108,17 +108,17 @@
     disconnects photos image fetcher services slots.
 */
 
-void HsSelectBackgroundState::disconnectImageFetcherAction()
+void HsSelectBackgroundState::action_disconnectImageFetcher()
 {
     HsScene::mainWindow()->setCurrentView(mSourceView);
-    mXQAIWGetImageClient->disconnect(this);
+    mImageFetcher->disconnect(this);
 }
 
 /*!
     \internal
     Called when user has selected an image    
 */
-void HsSelectBackgroundState::onBackgroundImageFetched(QStringList imageStringList)
+void HsSelectBackgroundState::onFetchComplete(QStringList imageStringList)
 {
     HsScene *scene = HsScene::instance();
         
@@ -137,8 +137,8 @@
         fileExtension = fileInfo.suffix();
     }
 
-    QFile::remove(sceneData.portraitWallpaper());
-    QFile::remove(sceneData.landscapeWallpaper()); 
+    QFile::remove(sceneData.portraitWallpaper);
+    QFile::remove(sceneData.landscapeWallpaper); 
 
     QString wallpaperDir = HsWallpaper::wallpaperDirectory();            
     QDir dir(wallpaperDir);
@@ -155,8 +155,8 @@
     
     if (saveImage(image, portraitPath, Qt::Vertical) && 
         saveImage(image, landscapePath, Qt::Horizontal)) {
-        sceneData.setPortraitWallpaper(portraitPath);
-        sceneData.setLandscapeWallpaper(landscapePath);
+        sceneData.portraitWallpaper = portraitPath;
+        sceneData.landscapeWallpaper = landscapePath;
         if (db->updateScene(sceneData)) {
             scene->wallpaper()->setImagesById(QString(), fileInfo.suffix());
         }
@@ -169,7 +169,7 @@
     \internal
     Called when selection of background image fails  
 */
-void HsSelectBackgroundState::onBackgroundImageFetchFailed(int error)
+void HsSelectBackgroundState::onFetchFailed(int error)
 {
     Q_UNUSED(error)
     emit event_waitInput();
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.qrc	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.qrc	Fri Apr 16 14:54:01 2010 +0300
@@ -1,5 +1,7 @@
 <RCC>
     <qresource prefix="/xml" >
-        <file alias="hsmenuworkerstateplugin.docml">resource/hsmenuworkerstateplugin.docml</file>
+        <file alias="hsappchecklist.docml">resource/hsappchecklist.docml</file>
+        <file alias="hswidgetpreviewdialog.docml">resource/hswidgetpreviewdialog.docml</file>
+        <file alias="hsarrangedialog.docml">resource/hsarrangedialog.docml</file>
     </qresource>
 </RCC>
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddtohomescreenstate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddtohomescreenstate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -73,11 +73,14 @@
 
     void showMessageWidgetCorrupted(int itemId);
 
-    void addWidget(HsContentService &service, const QString &library,
-                   const QString &uri, int entryId);
+    void addWidget(HsContentService &service, const QString &uri,
+                    int entryId);
 
     void addShortcut(HsContentService &contentService, int entryId);
 
+    void addTApplication(HsContentService &contentService, int entryId,
+                QVariantMap &data);
+
     void logActionResult(QString operationName, int entryId,
                          bool operationSucceded);
 
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsappschecklist.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsappschecklist.h	Fri Apr 16 14:54:01 2010 +0300
@@ -95,7 +95,12 @@
     HbView *mView;
 
     /**
-     * Action back. Owned.
+     * Previous view. Not owned.
+     */
+    HbView *mPreviousView;
+
+    /**
+     * Confirm action. Owned.
      */
     HbAction *mActionConfirm;
 
@@ -115,6 +120,11 @@
      */
     HsSortAttribute mSortAttribute;
 
+	/**
+     * List of objects loaded by document loader. Content owned.
+     */
+    QObjectList mLoadedObjects;
+
 };
 
 #endif /* APPSCHECKLIST_H */
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsarrangestate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsarrangestate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -81,22 +81,11 @@
      */
     void construct();
 
-    /*
-     * Fulfills collection list.
-     */
-    void fulfillEntriesList();
+    void fulfillEntriesList(HbListWidget& listWidget);
 
-    /**
-     * Appends new order of items to ids list.
-     */
-    void getArrangedEntriesIds();
+    void getArrangedEntriesIds(const HbListWidget& listWidget);
 
-    /**
-     * Saves data in content arsenal(selected applications in collection).
-     *
-     * @since S60 ?S60_version.
-     */
-    void save();
+    void save(const HbListWidget& listWidget);
 
 private:
 
@@ -134,6 +123,8 @@
      * Collection list.
      */
     QList<int> mArrangedCollIdList;
+    
+    QObjectList mObjectList;
 
 };
 
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsmenustates_global.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsmenustates_global.h	Fri Apr 16 14:54:01 2010 +0300
@@ -33,9 +33,17 @@
 #define HS_STATES_TEST_FRIEND_CLASS(className) friend class className;
 #endif
 
-static const char *const HS_MENU_WORKER_STATE_PROVIDER_LAYOUT =
-    ":/xml/hsmenuworkerstateplugin.docml";
+static const char *const HS_APP_CHECK_LIST_LAYOUT =
+    ":/xml/hsappchecklist.docml";
+static const char *const HS_WIDGET_PREVIEW_DIALOG_LAYOUT =
+    ":/xml/hswidgetpreviewdialog.docml";
+static const char *const HS_WIDGET_PREVIEW_DIALOG_NAME="preview_dialog";
+static const char *const HS_WIDGET_PREVIEW_SCROLL_AREA_NAME="preview_scroll_area";
 
+static const char *const HS_ARRANGE_DIALOG_LAYOUT =
+    ":/xml/hsarrangedialog.docml";
+static const char *const HS_ARRANGE_DIALOG_NAME="arrange_dialog";
+static const char *const HS_ARRANGE_LIST_NAME="arrange_list";
 /*!
  To enable logging of function entry and exit use the following flag for qmake:
  -config nft
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hspreviewhswidgetstate.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hspreviewhswidgetstate.h	Fri Apr 16 14:54:01 2010 +0300
@@ -101,10 +101,12 @@
     void subscribeForMemoryCardRemove(int entryId);
 
 private:
-
+    
     HbDialog *mPopupDialog;
 
     CaNotifier *mNotifier;
+    
+    QObjectList mObjectList;
 
 };
 
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -31,6 +31,7 @@
 
 const char SHORTCUT_WIDGET_URI[] = "hsshortcutwidgetplugin";
 const char SHORTCUT_ID[] = "mcsId";
+const char ADD_TO_HOMESCREEN_STATE[] = "AddToHomeScreenState";
 
 /*!
  \class HsAddToHomeScreenState
@@ -46,7 +47,7 @@
  \retval void
  */
 HsAddToHomeScreenState::HsAddToHomeScreenState(QState *parent) :
-    HsMenuBaseState("AddToHomeScreenState", parent)
+    HsMenuBaseState(ADD_TO_HOMESCREEN_STATE, parent)
 {
     requestServices(QList<QVariant> () << SHORTCUT_SERVICE_KEY
                     << CONTENT_SERVICE_KEY);
@@ -82,16 +83,16 @@
     const int entryId = data.value(itemIdKey()).toInt();
 
     if (entryTypeName == widgetTypeName()) {
-        const QString library =
-            data.value(widgetLibraryAttributeName()).toString();
-
         const QString uri = data.value(widgetUriAttributeName()).toString();
-
-        addWidget(*contentService(), library, uri, entryId);
+        addWidget(*contentService(), uri, entryId);
+        HsMenuService::touch(entryId);
+    } else if (entryTypeName==templatedApplicationTypeName()) {
+        addTApplication(*contentService(), entryId, data);
         HsMenuService::touch(entryId);
     } else {
         addShortcut(*contentService(), entryId);
     }
+
     HSMENUTEST_FUNC_EXIT("HsAddToHomeScreenState::onEntry");
 }
 
@@ -104,13 +105,12 @@
  \param activePage: active page of home screen
  \retval void
  */
-void HsAddToHomeScreenState::addWidget(HsContentService &contentService,
-                                       const QString &library, const QString &uri, int entryId)
+void HsAddToHomeScreenState::addWidget(HsContentService &contentService, 
+        const QString &uri, int entryId)
 {
     HSMENUTEST_FUNC_ENTRY("HsAddToHomeScreenState::addWidget");
-    QVariantMap params;
-    params["library"] = library;
-    params["uri"] = uri;
+    QVariantHash params;
+    params[URI] = uri;
     bool ok = contentService.createWidget(params);
     if (!ok) {
         showMessageWidgetCorrupted(entryId);
@@ -170,12 +170,12 @@
         }
     }
     if (!mLibraryPath.isEmpty()) {
-        QVariantMap params;
-        params["library"] = mLibraryPath;
-        params["uri"] = SHORTCUT_WIDGET_URI;
-        QVariantMap preferences;
+        QVariantHash params;
+        params[LIBRARY] = mLibraryPath;
+        params[URI] = SHORTCUT_WIDGET_URI;
+        QVariantHash preferences;
         preferences[SHORTCUT_ID] = QString::number(entryId);
-        params["preferences"] = preferences;
+        params[PREFERENCES] = preferences;
         const bool result = contentService.createWidget(params);
         logActionResult("Adding shortcut", entryId, result);
     }
@@ -183,6 +183,44 @@
 }
 
 /*!
+ Adds a tapplication to active page of home screen
+ \param shortcutService: service for adding shortcuts
+ \param entryId: menu entry id
+ \param data: data from event
+ \retval void
+ */
+void HsAddToHomeScreenState::addTApplication(HsContentService &contentService,
+        int entryId, QVariantMap &data)
+{
+    CaEntry* entry = CaService::instance()->getEntry(entryId);
+    
+
+    if (entry->attributes().contains(widgetUriAttributeName())) {
+        QVariantHash params;
+        const QString uri = entry->attribute(widgetUriAttributeName());
+        params[URI] = uri;
+        
+        QVariantHash preferences;
+        QVariantMap widgetParams = data.value(widgetParam()).toMap();
+        QMapIterator<QString, QVariant> i(widgetParams);
+        while (i.hasNext()) {
+            i.next();
+            QString key(i.key());
+            QString value = i.value().toString();
+            preferences.insert(key.remove(widgetParam()), value);
+        }
+        params[PREFERENCES] = preferences;
+
+        bool ok = contentService.createWidget(params);
+        if (!ok) {
+            addShortcut(contentService, entryId);
+        }
+    } else {
+        addShortcut(contentService, entryId);
+    }
+}
+
+/*!
  Provides debug logging of add widget/shortcut action
  \param operation name: results of which operation is logged
  \param entryId: menu entry id that was added to home screen
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsappschecklist.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsappschecklist.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -44,8 +44,8 @@
  \retval void
  */
 HsAppsCheckList::HsAppsCheckList() :
-    mView(0), mActionConfirm(0), mListView(0), mModel(0), mSortAttribute(
-        AscendingNameHsSortAttribute)
+    mView(0), mPreviousView(0), mActionConfirm(0), mListView(0), mModel(0),
+    mSortAttribute(AscendingNameHsSortAttribute)
 {
 }
 
@@ -64,12 +64,14 @@
 void HsAppsCheckList::cleanUp()
 {
     //clean up
-    delete mListView;
+
+    qDeleteAll(mLoadedObjects);
+    mLoadedObjects.clear();
     mListView = NULL;
+    mView = NULL;
+
     delete mActionConfirm;
     mActionConfirm = NULL;
-    delete mView;
-    mView = NULL;
     delete mModel;
     mModel = NULL;
     mSortAttribute = AscendingNameHsSortAttribute;
@@ -104,15 +106,13 @@
     // Add mListView to main window
     HbMainWindow *hbMainWindow = mainWindow();
 
-    // add action done
-    hbMainWindow->addSoftKeyAction(Hb::SecondarySoftKey, mActionConfirm);
+    // add confirm action
+    mView->setNavigationAction(mActionConfirm);
 
-    // We need to add the above created view into main window.
-    // We also need to hide the navi pane and turn off switching views.
-    hbMainWindow->setViewSwitchingEnabled(false);
-    hbMainWindow->hideItems(Hb::NaviPaneItem);
     hbMainWindow->addView(mView);
-    hbMainWindow->setCurrentViewIndex(hbMainWindow->viewCount() - 1);
+    // record the current view in order to activate it once done
+    mPreviousView = hbMainWindow->currentView();
+    hbMainWindow->setCurrentView(mView);
     hbMainWindow->show();
     HSMENUTEST_FUNC_EXIT("HsAppsCheckList::showAppsCheckboxList");
 }
@@ -126,32 +126,27 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::constructControls");
     if (!mActionConfirm) {
-        mActionConfirm = new HbAction(Hb::ConfirmAction, mView);
+        mActionConfirm = new HbAction(Hb::ConfirmNaviAction, mView);
         connect(mActionConfirm, SIGNAL(triggered()),SLOT(selectApplicationsDone()));
     }
 
     if (!mView) { // it implies that mListView is NULL as well
-
         bool loadStatusOk = false;
 
         HbDocumentLoader loader;
-        loader.load(HS_MENU_WORKER_STATE_PROVIDER_LAYOUT, &loadStatusOk);
+        mLoadedObjects = loader.load(HS_APP_CHECK_LIST_LAYOUT, &loadStatusOk);
 
         Q_ASSERT_X(loadStatusOk,
-                   HS_MENU_WORKER_STATE_PROVIDER_LAYOUT,
+                    HS_APP_CHECK_LIST_LAYOUT,
                    "Error while loading docml file.");
 
         static const QString VIEW_WIDGET_NAME("view");
-        mView
-        = qobject_cast<HbView *> (loader.findWidget(VIEW_WIDGET_NAME));
+        mView = qobject_cast<HbView *> (loader.findWidget(VIEW_WIDGET_NAME));
+        mView->setParent(this);
 
-        mView->setParent(this);
-        // TODO: configure via docml
-        mView->setTitle(hbTrId("txt_applib_title_select_applications"));
         static const QString LIST_VIEW_WIDGET_NAME("listView");
         mListView = qobject_cast<HbListView *> (loader.findWidget(
                 LIST_VIEW_WIDGET_NAME));
-
         mListView->setModel(mModel);
     }
     HSMENUTEST_FUNC_EXIT("HsAppsCheckList::constructControls");
@@ -168,12 +163,9 @@
     HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::selectApplicationsDone");
     // Remove mListView from main window and restore previous view.
     HbMainWindow *hbMainWindow = mainWindow();
+    hbMainWindow->setCurrentView(mPreviousView);
     hbMainWindow->removeView(mView);
-    hbMainWindow->setCurrentViewIndex(hbMainWindow->viewCount()-1);
-    hbMainWindow->showItems(Hb::NaviPaneItem);
-    hbMainWindow->setViewSwitchingEnabled(true);
-    hbMainWindow->removeSoftKeyAction(Hb::SecondarySoftKey, mActionConfirm);
-
+    
     QItemSelectionModel *itemSelectionModel = mListView->selectionModel();
     QList<int> itemsList;
     if (itemSelectionModel) {
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsarrangestate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsarrangestate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -18,6 +18,7 @@
 #include <QDebug>
 #include <hblistwidget.h>
 #include <hbdialog.h>
+#include <HbDocumentLoader>
 #include <hblabel.h>
 #include <hbaction.h>
 #include <hsmenuservice.h>
@@ -52,9 +53,6 @@
  */
 HsArrangeState::~HsArrangeState()
 {
-    if (mEntriesList) {
-        delete mEntriesList;
-    }
     if (mDialog) {
         delete mDialog;
     }
@@ -74,15 +72,16 @@
     HSMENUTEST_FUNC_EXIT("HsArrangeState::construct");
 }
 
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void HsArrangeState::save()
+/*!
+  Send data to storage (selected applications in collection).
+  \param listWidget List of items to be stored. 
+ */
+void HsArrangeState::save(const HbListWidget& listWidget)
 {
     qDebug("HsArrangeState::save()");
     HSMENUTEST_FUNC_ENTRY("HsArrangeState::save");
 
-    getArrangedEntriesIds();
+    getArrangedEntriesIds(listWidget);
     if (mArrangedCollIdList.count() == mCollIdList.count()) {
         for (int i(0); i < mArrangedCollIdList.count(); i++) {
             if (mArrangedCollIdList.at(i) != mCollIdList.at(i)) {
@@ -112,37 +111,45 @@
 
     mTopItemId = data.value(itemIdKey()).toInt();
 
-    mItemModel = HsMenuService::getAllCollectionsModel();
-
-    mEntriesList = new HbListWidget();
-    fulfillEntriesList();
+    HbDocumentLoader loader;
+    bool loadStatusOk = false;
+    mObjectList = 
+        loader.load(HS_ARRANGE_DIALOG_LAYOUT, &loadStatusOk);
+    Q_ASSERT_X(loadStatusOk,
+        HS_ARRANGE_DIALOG_LAYOUT,
+           "Error while loading docml file.");
+    
+    mEntriesList = qobject_cast<HbListWidget*>(
+        loader.findWidget(HS_ARRANGE_LIST_NAME));
+    
+    mDialog = qobject_cast<HbDialog*>(
+            loader.findWidget(HS_ARRANGE_DIALOG_NAME));
 
-    mEntriesList->scrollTo(mTopModelIndex,
-                           HbAbstractItemView::PositionAtTop);
-    mEntriesList->setArrangeMode(true);
-
-    mDialog = new HbDialog();
-    mDialog->setDismissPolicy(HbPopup::NoDismiss);
-    mDialog->setTimeout(HbPopup::NoTimeout);
-
-    mDialog->setPreferredSize(
-        HbInstance::instance()->allMainWindows().at(0)->size());
+    
+    if (mEntriesList != NULL && mDialog != NULL) {
 
-    HbLabel *label = new HbLabel(hbTrId("txt_applib_title_arrange"));
-    mDialog->setHeadingWidget(label);
-    mDialog->setContentWidget(mEntriesList);
-
-    mDialog->setPrimaryAction(new HbAction(hbTrId("txt_common_button_ok"),
-                                           mDialog));
-
-    HbAction *result = mDialog->exec();
-    mEntriesList->setArrangeMode(false);
-    if (result == mDialog->primaryAction()) {
-        save();
-    }
-    delete result;
-    result = NULL;
-
+        mItemModel = HsMenuService::getAllCollectionsModel();
+        
+        fulfillEntriesList(*mEntriesList);
+    
+        mEntriesList->scrollTo(mTopModelIndex,
+                               HbAbstractItemView::PositionAtTop);
+    
+        mEntriesList->setArrangeMode(true);
+    
+        mDialog->setTimeout(HbPopup::NoTimeout);
+    
+        mDialog->setPreferredSize(
+            HbInstance::instance()->allMainWindows().at(0)->size());
+    
+        HbAction const* action(mDialog->exec());
+        
+        mEntriesList->setArrangeMode(false);
+        
+        if (action == mDialog->primaryAction()) {
+            save(*mEntriesList);
+        }
+    }    
     HSMENUTEST_FUNC_EXIT("HsArrangeState::onEntry");
 }
 #ifdef COVERAGE_MEASUREMENT
@@ -155,10 +162,10 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsArrangeState::stateExited");
 
-    mDialog->setHeadingWidget(0); //delete label
-    mDialog->setContentWidget(0); //delete mEntriesList
+    qDeleteAll(mObjectList);
+    mObjectList.clear();
+    
     mEntriesList = NULL;
-    delete mDialog;
     mDialog = NULL;
     delete mItemModel;
     mItemModel = NULL;
@@ -170,10 +177,12 @@
     qDebug("HsArrangeState::stateExited()");
 }
 
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void HsArrangeState::fulfillEntriesList()
+
+/*!
+ Put items from model into arrangable list of items represented by \a listWidget
+  \param listWidget Object to be filled with list of items from model.
+ */
+void HsArrangeState::fulfillEntriesList(HbListWidget& listWidget)
 {
     qDebug() << "HsArrangeState::fulfillEntriesList";
 
@@ -190,22 +199,24 @@
         widgetItem->setData(mItemModel->data(idx, Qt::DecorationRole),
                             Qt::DecorationRole);
 
-        mEntriesList->addItem(widgetItem);
+        listWidget.addItem(widgetItem);
         if (mTopItemId == itemId) {
-            mEntriesList->indexCount();
-            mEntriesList->setCurrentItem(widgetItem);
-            mTopModelIndex = mEntriesList->currentIndex();
+            listWidget.indexCount();
+            listWidget.setCurrentItem(widgetItem);
+            mTopModelIndex = listWidget.currentIndex();
         }
     }
 }
 
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void HsArrangeState::getArrangedEntriesIds()
+
+/*!
+ Copy items in from \a listWidget to arranged collection id list
+ \param listWidget List of items in the requested order.
+ */
+void HsArrangeState::getArrangedEntriesIds(const HbListWidget& listWidget)
 {
-    for (int i(0); i < mEntriesList->count(); i++) {
-        HbListWidgetItem *widgetItem = mEntriesList->item(i);
+    for (int i(0); i < listWidget.count(); ++i) {
+        HbListWidgetItem *widgetItem = listWidget.item(i);
         QVariant entryId = widgetItem->data(CaItemModel::IdRole);
         mArrangedCollIdList.append(entryId.toInt());
     }
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hscollectionnamedialog.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hscollectionnamedialog.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -133,8 +133,8 @@
 //
 void HsCollectionNameDialog::makeConnect()
 {
-    /*connect(lineEdit(), SIGNAL(textChanged(const QString &text)),
-     SLOT(onTextChanged(const QString &text)));*/
+    /*connect(lineEdit(), SIGNAL(textChanged(QString&text)),
+     SLOT(onTextChanged(QString&text)));*/
 
     connect(lineEdit(), SIGNAL(contentsChanged()),
             SLOT(onContentsChanged()));
@@ -145,8 +145,8 @@
 //
 void HsCollectionNameDialog::makeDisconnect()
 {
-    /*disconnect(lineEdit(), SIGNAL(textChanged(const QString &text)),
-     this, SLOT(onTextChanged(const QString &text)));*/
+    /*disconnect(lineEdit(), SIGNAL(textChanged(QString&text)),
+     this, SLOT(onTextChanged(QString&text)));*/
     disconnect(lineEdit(), SIGNAL(contentsChanged()),
                this, SLOT(onContentsChanged()));
 }
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hspreviewhswidgetstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hspreviewhswidgetstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -21,14 +21,15 @@
 #include <hbmessagebox.h>
 #include <qstatemachine.h>
 #include <hbaction.h>
+#include <HbDocumentLoader>
 #include <hbdialog.h>
 #include <hbwidget.h>
 #include <hbscrollarea.h>
 #include <hbscrollbar.h>
+#include <QtAlgorithms>
 
 #include "hsmenueventfactory.h"
 #include "hsmenuservice.h"
-#include "hswidgetdata.h"
 #include "hswidgethost.h"
 #include "hspreviewhswidgetstate.h"
 #include "hsmenuevent.h"
@@ -43,13 +44,16 @@
 #include "hsdomainmodel_global.h"
 #include <hscontentservice.h>
 
+
+const char HS_PREVIEW_HS_WIDGET_STATE[] = "HsPreviewHSWidgetState";
+
 /*!
  Constructor
  \param parent: parent state
  \retval void
  */
 HsPreviewHSWidgetState::HsPreviewHSWidgetState(QState *parent) :
-    HsMenuBaseState("HsPreviewHSWidgetState", parent),
+    HsMenuBaseState(HS_PREVIEW_HS_WIDGET_STATE, parent),
     mPopupDialog(0),
     mNotifier(0)
 {
@@ -65,9 +69,6 @@
     if (mNotifier) {
         delete mNotifier;
     }
-    if (mPopupDialog) {
-        delete mPopupDialog;
-    }
 }
 
 /*!
@@ -94,65 +95,60 @@
 
     const int entryId = data.value(itemIdKey()).toInt();
 
-    QVariantMap widgetData;
-    widgetData.insert("library", data.value(widgetLibraryAttributeName()).toString());
-    widgetData.insert("uri", data.value(widgetUriAttributeName()).toString());
-    HsWidgetHost *widget = contentService()->createWidgetForPreview(widgetData);
+    QVariantHash widgetData;
+    widgetData.insert(LIBRARY, data.value(widgetLibraryAttributeName()).toString());
+    widgetData.insert(URI, data.value(widgetUriAttributeName()).toString());
+    QScopedPointer<HsWidgetHost> widget(
+        contentService()->createWidgetForPreview(widgetData));
 
     if (widget) {
         widget->setMinimumSize(widget->preferredWidth(),widget->preferredHeight());
-        HbScrollArea *scrollArea = new HbScrollArea();
-        scrollArea->setClampingStyle(HbScrollArea::StrictClamping);
-        scrollArea->setScrollingStyle(HbScrollArea::Pan);
-        scrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
-        scrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide);//
-        scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
-        scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide);//
-        scrollArea->verticalScrollBar()->setInteractive(true);
-        scrollArea->horizontalScrollBar()->setInteractive(true);
-        // this sets up the scroll area to scroll in both directions
-        scrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal);
-        scrollArea->setContentWidget(widget);   //ownership transferred
-        scrollArea->setAlignment(Qt::AlignCenter);
+
+        HbDocumentLoader loader;
 
-        // Instantiate a popup
-        mPopupDialog = new HbDialog();
-
-        // Set dismiss policy that determines what tap events will cause the dialog
-        // to be dismissed
-        mPopupDialog->setDismissPolicy(HbDialog::NoDismiss);
-        mPopupDialog->setTimeout(HbDialog::NoTimeout);
-
-        // Set content widget
-        mPopupDialog->setContentWidget(scrollArea); //ownership transferred
+        bool loadStatusOk = false;
+        mObjectList = 
+            loader.load(HS_WIDGET_PREVIEW_DIALOG_LAYOUT, &loadStatusOk);
+        Q_ASSERT_X(loadStatusOk,
+            HS_WIDGET_PREVIEW_DIALOG_LAYOUT,
+               "Error while loading docml file.");
 
-        // Sets the primary action and secondary action
-        mPopupDialog->setPrimaryAction(new HbAction(hbTrId("txt_applib_button_add_to_homescreen"),mPopupDialog));
-        mPopupDialog->setSecondaryAction(new HbAction(hbTrId("txt_common_button_close"),mPopupDialog));
-
-        subscribeForMemoryCardRemove(entryId);
-        widget->initializeWidget();
-        widget->showWidget();
-        // Launch popup syncronously
-        HbAction *result = mPopupDialog->exec();
-
-        disconnect(mNotifier,
-                   SIGNAL(entryChanged(const CaEntry &, ChangeType)),
-                   this, SLOT(memoryCardRemoved()));
-
-        if (result == mPopupDialog->primaryAction()) {
-            // take it back from scrollarea
+        mPopupDialog = 
+            qobject_cast<HbDialog*>(
+                loader.findWidget(HS_WIDGET_PREVIEW_DIALOG_NAME));
+        
+        HbScrollArea *const scrollArea( 
+            qobject_cast<HbScrollArea*>(
+                loader.findWidget(HS_WIDGET_PREVIEW_SCROLL_AREA_NAME)));
+        
+        if (mPopupDialog != NULL && scrollArea != NULL) {
+            mPopupDialog->setContentWidget(scrollArea); //ownership transferred
+            mPopupDialog->setTimeout(HbPopup::NoTimeout);
+            scrollArea->verticalScrollBar()->setInteractive(true);
+            scrollArea->horizontalScrollBar()->setInteractive(true);
+            scrollArea->setContentWidget(widget.data());
             scrollArea->takeContentWidget();
-            widget->hideWidget();
-            widget->uninitializeWidget();
-            HsScene::instance()->activePage()->addNewWidget(widget);
-        } else {
-            widget->deleteFromDatabase();
+            
+            subscribeForMemoryCardRemove(entryId);
+            widget->initializeWidget();
+            widget->showWidget();
+            // Launch popup syncronously
+            const HbAction *const action(mPopupDialog->exec());
+    
+            disconnect(mNotifier,
+                       SIGNAL(entryChanged(CaEntry,ChangeType)),
+                       this, SLOT(memoryCardRemoved()));
+    
+            if (action == mPopupDialog->primaryAction()) {
+                widget->hideWidget();
+                HsScene::instance()->activePage()->addNewWidget(
+                    widget.take()); // ownership transferred
+            } else {
+                widget->uninitializeWidget();
+                widget->deleteFromDatabase();
+            }
         }
 
-        delete result;
-        result = NULL;
-
     } else {
         showMessageWidgetCorrupted(entryId);
     }
@@ -171,15 +167,14 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsPreviewHSWidgetState::stateExited");
 
-    if (mNotifier) {
-        delete mNotifier;
-        mNotifier = NULL;
-    }
+
+    delete mNotifier;
+    mNotifier = NULL;
 
-    if (mPopupDialog) {
-        delete mPopupDialog;
-        mPopupDialog = NULL;
-    }
+    qDeleteAll(mObjectList);
+    mObjectList.clear();
+    
+    mPopupDialog = NULL;
 
     HSMENUTEST_FUNC_EXIT("HsPreviewHSWidgetState::stateExited");
     qDebug("HsPreviewHSWidgetState::stateExited()");
@@ -210,7 +205,7 @@
     mNotifier = CaService::instance()->createNotifier(filter);
     mNotifier->setParent(this);
     connect(mNotifier,
-            SIGNAL(entryChanged(const CaEntry &, ChangeType)),
+            SIGNAL(entryChanged(CaEntry,ChangeType)),
             SLOT(memoryCardRemoved()));
 }
 
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsclockwidgetplugin.s60xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsclockwidgetplugin.s60xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>z:/private/20022F35/import/widgetregistry/20022F6C/hsclockwidgetplugin.qtplugin</filepath>
     <description>Themable clock widget.</description>
     <interface>
-        <name>com.nokia.IHomeScreenWidget</name>
+        <name>com.nokia.symbian.IHomeScreenWidget</name>
         <version>1.0</version>
         <description>The clock widget displays current time.</description>
         <capabilities></capabilities>
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsclockwidgetplugin.xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsclockwidgetplugin.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>hsclockwidgetplugin</filepath>
     <description>Themable clock widget.</description>
     <interface>
-        <name>com.nokia.IHomeScreenWidget</name>
+        <name>com.nokia.symbian.IHomeScreenWidget</name>
         <version>1.0</version>
         <description>The clock widget displays current time.</description>
         <capabilities></capabilities>
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsclockwidget.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsclockwidget.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -114,8 +114,6 @@
     mLayout = new QGraphicsLinearLayout(Qt::Vertical);
     mLayout->setContentsMargins(0,0,0,0);
 
-    hide();
-
     mWidget = loadClockWidget();
     mLayout->addItem(mWidget);
     setPreferredSize(mWidget->preferredSize());
@@ -124,7 +122,6 @@
     mTimer = new QTimer(this);
     connect(mTimer, SIGNAL(timeout()), SLOT(updateTime()));
     setLayout(mLayout);
-
 }
 
 /*!
@@ -136,7 +133,6 @@
 {
     mWidgetShown = true;
     mTimer->start(clockUpdateInterval);
-    show();
 }
 
 
@@ -149,7 +145,6 @@
 {
     mWidgetShown = false;
     mTimer->stop();
-    hide();
 }
 
 /*!
@@ -158,7 +153,6 @@
 void HsClockWidget::onUninitialize()
 {
     mTimer->stop();
-    hide();
 }
 
 /*!
@@ -183,7 +177,10 @@
 */
 void HsClockWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
-    Q_UNUSED(event);    
+    if (!contains(event->pos())) {
+        return;
+    }
+
 #ifndef Q_OS_SYMBIAN    
     mTimer->stop();
     toggleClockType();
@@ -203,7 +200,6 @@
     updateTime();
     update();
 
-
     mTimer->start(clockUpdateInterval);
 #endif    
 }
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsclockwidgetplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsclockwidgetplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -43,7 +43,7 @@
     Q_UNUSED(context);
     Q_UNUSED(session);
 
-    if (descriptor.interfaceName() == QLatin1String("com.nokia.IHomeScreenWidget")) {
+    if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IHomeScreenWidget")) {
         return new HsClockWidget();
     } else {
         return 0;
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/inc/hsanalogclockstyleplugin.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/inc/hsanalogclockstyleplugin.h	Fri Apr 16 14:54:01 2010 +0300
@@ -34,7 +34,7 @@
 
 public:
     int primitiveCount() const;
-    HbWidgetBase *createPrimitive(HbStyle::Primitive primitive, QGraphicsItem *parent = 0) const;
+    QGraphicsItem *createPrimitive(HbStyle::Primitive primitive, QGraphicsItem *parent = 0) const;
     void updatePrimitive(QGraphicsItem *item, HbStyle::Primitive primitive, const QStyleOption *option) const;
     QString layoutPath() const;
 	
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/resource/hsanalogclockwidget.css	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/resource/hsanalogclockwidget.css	Fri Apr 16 14:54:01 2010 +0300
@@ -1,21 +1,21 @@
-HbWidget {
-    margin-left: 0un;
-    margin-top: 0un;
-}
-
 HsAnalogClockWidget {
 	layout: layout_1;
 }
 
 HsAnalogClockWidget::clock_background {
-    pref-width: 25.0un;
-    pref-height: 25.0un;
+  fixed-width: 25.0un;
+  fixed-height: 25.0un;
+  zvalue: 0;
+}
+
+HsAnalogClockWidget::clock_minute_hand {
+  fixed-width: 25.0un;
+  fixed-height: 25.0un;
+  zvalue: 1;
 }
 
 HsAnalogClockWidget::clock_hour_hand {
-	pref-height: 15.0un;
+  fixed-width: 25.0un;
+  fixed-height: 25.0un;
+  zvalue: 2;
 }
-
-HsAnalogClockWidget::clock_minute_hand {
-    pref-height: 20.0un;
-}
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/src/hsanalogclockstyleplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/styles/hsanalogclockstyleplugin/src/hsanalogclockstyleplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -38,24 +38,21 @@
 /*!
     @copydoc HbStyleInterface::createPrimitive()
  */
-HbWidgetBase* HsAnalogClockStylePlugin::createPrimitive(HbStyle::Primitive primitive, QGraphicsItem *parent) const
+QGraphicsItem* HsAnalogClockStylePlugin::createPrimitive(HbStyle::Primitive primitive, QGraphicsItem *parent) const
 {
     if (primitive == backgroundItemIndex) {
         HbIconItem *item = new HbIconItem("qtg_graf_clock_day_bg", parent);
         HbStyle::setItemName(item, "clock_background");
-        item->setZValue(1);
         return item;
     }
     else if (primitive == hourHandItemIndex) {
         HbIconItem *item = new HbIconItem("qtg_graf_clock_day_hour", parent);
         HbStyle::setItemName(item, "clock_hour_hand");
-        item->setZValue(3); // hour hand is on top of minute hand
         return item;
     }
     else if (primitive == minuteHandItemIndex) {
         HbIconItem *item = new HbIconItem("qtg_graf_clock_day_min", parent);
         HbStyle::setItemName(item, "clock_minute_hand");
-        item->setZValue(2); // minute hand is below hour hand
         return item;
     }
     return 0;
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidgetplugin.s60xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidgetplugin.s60xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>z:/private/20022F35/import/widgetregistry/20022F46/hsshortcutwidgetplugin.qtplugin</filepath>
     <description>Shortcut widget.</description>
     <interface>
-        <name>com.nokia.IHomeScreenWidget</name>
+        <name>com.nokia.symbian.IHomeScreenWidget</name>
         <version>1.0</version>
         <description></description>
         <capabilities></capabilities>
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidgetplugin.xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidgetplugin.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -4,7 +4,7 @@
     <filepath>hsshortcutwidgetplugin</filepath>
     <description>Shortcut widget</description>
     <interface>
-        <name>com.nokia.IHomeScreenWidget</name>
+        <name>com.nokia.symbian.IHomeScreenWidget</name>
         <version>1.0</version>
         <description></description>
         <capabilities></capabilities>
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidget.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidget.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -16,6 +16,7 @@
 */
 
 #include <QGraphicsLinearLayout>
+#include <QGraphicsSceneMouseEvent>
 
 #include <HbStackedLayout>
 #include <HbIconItem>
@@ -147,7 +148,6 @@
 */
 void HsShortcutWidget::onHide()
 {
-    hide();
 }
 
 /*!
@@ -156,9 +156,11 @@
     Executes configured action
 */
 void HsShortcutWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    Q_UNUSED(event)
-    
+{   
+    if (!contains(event->pos())) {
+        return;
+    }
+
     CaEntry *entry = CaService::instance()->getEntry(mMcsId);
     if (!entry) {
         return;
@@ -244,8 +246,8 @@
     itemNotifier->setParent(this);
 
     connect(itemNotifier,
-        SIGNAL(entryChanged(const CaEntry&, ChangeType)),
-        SLOT(onEntryChanged(const CaEntry&, ChangeType)),Qt::QueuedConnection);
+        SIGNAL(entryChanged(CaEntry,ChangeType)),
+        SLOT(onEntryChanged(CaEntry,ChangeType)),Qt::QueuedConnection);
 }
 
 /*!
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidgetplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidgetplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -46,7 +46,7 @@
     Q_UNUSED(context);
     Q_UNUSED(session);
 
-    if (descriptor.interfaceName() == QLatin1String("com.nokia.IHomeScreenWidget")) {
+    if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IHomeScreenWidget")) {
         return new HsShortcutWidget();
     } else {
         return 0;
--- a/layers.sysdef.xml	Fri Mar 19 09:27:44 2010 +0200
+++ b/layers.sysdef.xml	Fri Apr 16 14:54:01 2010 +0300
@@ -10,5 +10,11 @@
                 <unit name="homescreen" unitID="homescreen" bldFile="&layer_real_source_path;" mrp="" proFile="homescreen.pro" qmakeArgs="-r -config rom"/>
             </module>
         </layer>
+        
+        <layer name="unit_test_layer">
+          <module name="hs_app_unit_test">
+            <unit unitID="hsdo.hs_app_unit_test" name="hs_app_unit_test" bldFile="&layer_real_source_path;/tsrc" mrp="" proFile="tsrc.pro" qmakeArgs="-r MMP_RULES+=EXPORTUNFROZEN"/>
+          </module>
+        </layer>
     </systemModel>
 </SystemDefinition>
--- a/package_definition.xml	Fri Mar 19 09:27:44 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<SystemDefinition schema="3.0.0">
-  <package id="homescreen" name="Home Screen Apps" levels="fw apps">
-    <collection id="idlehomescreen" name="Idle Home Screen" level="apps">
-      <component id="nativeuicontroller" filter="s60" name="Native UI Controller">
-        <unit bldFile="idlehomescreen/nativeuicontroller/group"/>
-      </component>
-      <component id="exths" filter="s60" name="Active Idle Container" class="plugin">
-      	<!-- why is the ID so different from the name? Is one wrong? -->
-        <unit bldFile="idlehomescreen/exths/group"/>
-      </component>
-      <component id="activeidle3" filter="s60" name="Active Idle 3">
-        <unit bldFile="idlehomescreen/activeidle3/group"/>
-        <!-- do these need to be built? -->
-        <!-- <unit bldFile="idlehomescreen/activeidle3/data/group"/> -->
-        <!-- <unit bldFile="idlehomescreen/activeidle3/xmluirendering/uiengine/group"/> -->
-      </component>
-      <component id="hsplugins" filter="s60" name="Home Screen Plugins" class="plugin">
-        <unit bldFile="idlehomescreen/hsplugins/group"/>
-        <!-- do these need to be built? -->
-        <!-- <unit bldFile="idlehomescreen/hsplugins/organizer/qhd_tch/organizer_2001f481/group"/> -->
-        <!-- <unit bldFile="idlehomescreen/hsplugins/organizer/vga/organizer_2001f48d/group"/> -->
-        <!-- <unit bldFile="idlehomescreen/hsplugins/organizer/vga/organizer_2001fdba/group"/> -->
-      </component>
-    </collection>
-    <collection id="menufw" name="Menu Framework" level="fw">
-      <component id="hierarchynavigator" filter="s60" name="Hierarchy Navigator">
-        <unit bldFile="menufw/hierarchynavigator/group"/>
-      </component>
-      <component id="menufwui" filter="s60" name="Menu Framework UI">
-        <unit bldFile="menufw/menufwui/group"/>
-      </component>
-      <component id="menusuites" filter="s60" name="Menu Suites">
-        <unit bldFile="menufw/menusuites/group"/>
-      </component>
-      <component id="menufw_build" filter="s60" name="Menu Framework Build">
-      	<!-- can the exports be exported by the other components? -->
-        <unit bldFile="menufw/group"/>
-      </component>
-    </collection>
-    <collection id="homescreen_info" name="Home Screen Apps Info" level="apps">
-      <component id="homescreen_test" filter="s60" purpose="development" name="Home Screen Apps Test">
-      	<!-- should this be commented out or not? -->
-        <!-- <unit bldFile="tsrc/group"/> -->
-      </component>
-      <component id="homescreen_plat" filter="s60" name="Home Screen Apps Platform Interfaces" class="api">
-        <unit bldFile="homescreen_plat/group"/>
-      </component>
-    </collection>
-  </package>
-</SystemDefinition>
--- a/taskswitcherapp/common.pri	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/common.pri	Fri Apr 16 14:54:01 2010 +0300
@@ -36,8 +36,6 @@
 win32: OUTPUT_DIR = $$PWD/../../bin/$$SUBDIRPART
 symbian: OUTPUT_DIR = $$PWD/bin
 
-SOURCE_DIR = $$PWD/inc
-
 #test whether we have a unit test
 !testcase {
     OBJECTS_DIR = $$OUTPUT_DIR/tmp/$$TARGET
@@ -49,19 +47,24 @@
     QT *= testlib
     CONFIG += console
     CONFIG -= app_bundle
-    OBJECTS_DIR = $$OUTPUT_DIR/bin/tests/$$SUBDIRPART/tmp/$$TARGET
-    DESTDIR = $$OUTPUT_DIR/bin/tests/$$SUBDIRPART
-    MOC_DIR = $$OUTPUT_DIR/bin/tests/$$SUBDIRPART/tmp/$$TARGET/moc
-    RCC_DIR = $$OUTPUT_DIR/bin/tests/$$SUBDIRPART/tmp/$$TARGET/rcc
-    UI_DIR = $$OUTPUT_DIR/bin/tests/$$SUBDIRPART/tmp/$$TARGET/ui
-    LIBS += -L$$OUTPUT_DIR/bin/$$SUBDIRPART/bin  #link against library that we test
+    OBJECTS_DIR = $$OUTPUT_DIR/tests/tmp/$$TARGET
+    DESTDIR = $$OUTPUT_DIR
+    MOC_DIR = $$OUTPUT_DIR/tests/tmp/$$TARGET/moc
+    RCC_DIR = $$OUTPUT_DIR/tests/tmp/$$TARGET/rcc
+    UI_DIR = $$OUTPUT_DIR/tests/tmp/$$TARGET/ui
+    coverage {
+        DEFINES += COVERAGE_MEASUREMENT
+        DEFINES += QT_NO_DEBUG  # omit ASSERTS in coverage measurements
+    }
+    
+    symbian {
+        TARGET.SID = 0x2002677D
+    }
 }
 
 # Add the output dirs to the link path too
 LIBS += -L$$DESTDIR
 
-DEPENDPATH += . $$SOURCE_DIR
-INCLUDEPATH += . $$SOURCE_DIR
 #For some reason the default include path doesn't include MOC_DIR on symbian
 symbian {
     INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
@@ -73,70 +76,6 @@
 win32 {
     # add platfrom API for windows
     INCLUDEPATH += \
-                $$PWD/../../homescreensrv/homescreensrv_plat/appruntimemodel_api \
                 $$PWD/../../homescreensrv/homescreensrv_plat/contentstorage_api \
                 $$PWD/../../homescreensrv/homescreensrv_plat/hswidgetmodel_api \
-                $$PWD/../../homescreensrv/homescreensrv_plat/servicemodel_api \
-                $$PWD/../../homescreensrv/homescreensrv_plat/statemodel_api
 }
-
-plugin: !isEmpty(PLUGIN_SUBDIR): DESTDIR = $$OUTPUT_DIR/$$PLUGIN_SUBDIR
-
-win32: plugin { # copy manifiers
-    manifest.path = $$DESTDIR
-    manifest.files = ./resource/*.manifest
-    manifest.CONFIG += no_build
-
-    INSTALLS += manifest
-    PRE_TARGETDEPS += install_manifest
-
-}
-
-symbian: plugin { # copy qtstub and manifest
-
-    pluginstub.sources = $${TARGET}.dll
-    pluginstub.path = $$PLUGIN_SUBDIR
-
-    manifest.sources = resource/$${TARGET}.manifest
-    manifest.path = $$PLUGIN_SUBDIR
-    
-    DEPLOYMENT += pluginstub manifest
-
-    qtplugins.path = $$PLUGIN_SUBDIR
-    qtplugins.sources += qmakepluginstubs/$${TARGET}.qtplugin
-    qtplugins.sources += resource/$${TARGET}.manifest
-
-    for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin z:$$qtplugins.path/$$basename(qtplugin)"
-
-}
-
-defineTest(exportResources) {
-symbian {
-    for(subdirs, 1) {
-        entries = $$files($$subdirs)
-        for(entry, entries) : BLD_INF_RULES.prj_exports += "./$$entry z:/$$replace(2, ^/,)/$$basename(entry)"
-    }
-    export ( BLD_INF_RULES.prj_exports)
-}
-win32 {
-    name = $$replace(1, [/\\\\\.\*], _)
-    eval ($${name}.path = $${OUTPUT_DIR}/$${2})
-    eval ($${name}.files = $$1)
-    eval ($${name}.CONFIG += no_build)
-
-    INSTALLS += $$name
-    PRE_TARGETDEPS += install_$${name}
-
-    export ( $${name}.path )
-    export ( $${name}.files )
-    export ( $${name}.CONFIG )
-    export ( INSTALLS )
-    export ( PRE_TARGETDEPS )
-}
-}
-
-# support for NFT
-nft:DEFINES += NFT
-
-#ONLY FOR DEVELOPMENT! REMOVE THIS AFTER SPRINTS ENDS AT WK43 2009!
-symbian: MMP_RULES += EXPORTUNFROZEN
\ No newline at end of file
--- a/taskswitcherapp/rom/tsapplication_core.iby	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/rom/tsapplication_core.iby	Fri Apr 16 14:54:01 2010 +0300
@@ -29,6 +29,8 @@
 file=ABI_DIR\BUILD_DIR\tsdefaultruntimeplugin.dll					       SHARED_LIB_DIR\tsdefaultruntimeplugin.dll
 data=\epoc32\data\z\resource\qt\plugins\tsdefaultruntimeplugin.qtplugin    resource\qt\plugins\tsdefaultruntimeplugin.qtplugin
 
+data=\epoc32\data\z\resource\qt\crml\tsexternalactivation.qcrml             resource\qt\crml\tsexternalactivation.qcrml
+
 // stub sis
 data=ZSYSTEM/install/taskswitcher_stub.sis                  system/install/taskswitcher_stub.sis
 
--- a/taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/src/tsdefaultruntime.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/src/tsdefaultruntime.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -26,7 +26,7 @@
 
 /*!
     \class TsDefaultRuntime
-    \ingroup group_tsdefaultruntimeprovider
+    \ingroup group_tsdefaultruntimeplugin
     \brief Default implementation of the taskswitcher runtime.
 */
 
@@ -80,9 +80,7 @@
 QObject *TsDefaultRuntime::createCriticalInterface(QServiceManager *serviceManager, const QString &name)
 {
     QObject *interface = serviceManager->loadInterface(name);
-    if (!interface) {
-        qFatal("Cannot initialize critical %s interafce.", qPrintable(name));
-    }
+    Q_ASSERT_X(interface, "TsDefaultRuntime::createCriticalInterface", qPrintable(QString("Cannot initialize critical %1 interafce").arg(name)));
     interface->setParent(this);
     return interface;
 }
--- a/taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/src/tsdefaultruntimeplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/src/tsdefaultruntimeplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -24,11 +24,10 @@
 
 /*!
     \class TsDefaultRuntimePlugin
-    \ingroup group_tsdefaultruntimeprovider
+    \ingroup group_tsdefaultruntimeplugin
     \brief Provides a default implementation of the taskswitcher runtime.
 
     This provider includes a default implementation of the taskswitcher runtime.
-    The runtime is described in the tsdefaultruntimeplugin.xml file.
 */
 
 #ifdef COVERAGE_MEASUREMENT
--- a/taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/tsdefaultruntimeplugin.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/runtimeplugins/tsdefaultruntimeplugin/tsdefaultruntimeplugin.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -28,10 +28,10 @@
 
 symbian {
     load(data_caging_paths) 
-    TARGET.EPOCALLOWDLLDATA = 1
-    TARGET.CAPABILITY = ALL -TCB
 
     plugin.sources = tsdefaultruntimeplugin.dll
     plugin.path = $$QT_PLUGINS_BASE_DIR     
     DEPLOYMENT += plugin 
 }
+
+include(../../common.pri)
--- a/taskswitcherapp/sis/stubs/taskswitcher_stub.pkg	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/sis/stubs/taskswitcher_stub.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -46,3 +46,4 @@
 ""-"Z:\resource\qt\plugins\tsdefaultruntimeplugin.qtplugin"
 
 ""-"Z:\resource\qt\translations\taskswitcher.qm"
+""-"Z:\resource\qt\crml\tsexternalactivation.qcrml"
Binary file taskswitcherapp/sis/stubs/taskswitcher_stub.sis has changed
--- a/taskswitcherapp/sis/taskswitcher.pkg	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/sis/taskswitcher.pkg	Fri Apr 16 14:54:01 2010 +0300
@@ -40,3 +40,4 @@
 "/epoc32/data/z/resource/qt/plugins/tsdefaultruntimeplugin.qtplugin"-"!:\resource\qt\plugins\tsdefaultruntimeplugin.qtplugin"
 
 "/epoc32/data/z/resource/qt/translations/taskswitcher.qm"-"!:\resource\qt\translations\taskswitcher.qm"
+"/epoc32/data/z/resource/qt/crml/tsexternalactivation.qcrml"-"!:\resource\qt\crml\tsexternalactivation.qcrml"
--- a/taskswitcherapp/taskswitcherapp.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/taskswitcherapp.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -16,13 +16,13 @@
 
 TEMPLATE = subdirs
 
-SUBDIRS += taskswitcherappecom
+symbian:SUBDIRS += taskswitcherappecom
 SUBDIRS += tsserviceplugin
 SUBDIRS += runtimeplugins
 SUBDIRS += tsapplication
 
 tests {
-    SUBDIRS += taskswitcherappecom\tsrc
+    symbian:SUBDIRS += taskswitcherappecom\tsrc
     SUBDIRS += tsserviceplugin\tsrc
     SUBDIRS += runtimeplugins\tsdefaultruntimeplugin\tsrc
     SUBDIRS += tsapplication\tsrc
--- a/taskswitcherapp/tsapplication/tsapplication.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsapplication/tsapplication.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -15,8 +15,6 @@
 #
 
 TEMPLATE = app
-TARGET = tsapplication
-
 CONFIG += hb console mobility
 MOBILITY = serviceframework
 
@@ -31,7 +29,8 @@
 RESOURCES += tsapplication.qrc 
 
 symbian {
+    TARGET.EPOCHEAPSIZE = 0x700000 0xF00000    
     TARGET.UID3 = 0x2002677D
-    TARGET.EPOCALLOWDLLDATA = 1
-    TARGET.CAPABILITY = ALL -TCB
 }
+
+include(../common.pri)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/inc/s60/tsexternalactivationwatcher_p.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef TSEXTERNALACTIVATIONWATCHERPRIVATE_H
+#define TSEXTERNALACTIVATIONWATCHERPRIVATE_H
+
+#include <e32base.h>
+#include <e32property.h>
+
+class TsExternalActivationWatcher;
+
+class TsExternalActivationWatcherPrivate : public CActive
+{
+public:
+    TsExternalActivationWatcherPrivate(TsExternalActivationWatcher *parent);
+    virtual ~TsExternalActivationWatcherPrivate();
+
+public: //From CActive
+    /**
+    * Implements cancellation of an outstanding request.
+    */
+    virtual void DoCancel();
+
+    /**
+    Handles an active object's request completion event.
+    */
+    void RunL();
+    
+private:
+    bool CheckActivationFlag();
+    void ResetActivationFlag();
+
+private:
+    TsExternalActivationWatcher *mParent;
+    RProperty mProperty;
+
+};
+
+#endif // TSEXTERNALACTIVATIONWATCHERPRIVATE_H
--- a/taskswitcherapp/tsserviceplugin/inc/tsclosedapplicationsfiltermodel.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/inc/tsclosedapplicationsfiltermodel.h	Fri Apr 16 14:54:01 2010 +0300
@@ -20,15 +20,6 @@
 
 #include <QSortFilterProxyModel>
 
-/**
- * @ingroup group_tsserviceprovider
- * @brief TsClosedApplicationsFilterModel filtering model to hide closed apps.
- *
- * Filter closed apps by task switcher from currently presented.
- *
- * @lib tsserviceprovider.lib
- * @since S60 ?S60_version
- */
 class TsClosedApplicationsFilterModel : public QSortFilterProxyModel
 {
     Q_OBJECT
--- a/taskswitcherapp/tsserviceplugin/inc/tsdeactivation.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/inc/tsdeactivation.h	Fri Apr 16 14:54:01 2010 +0300
@@ -19,14 +19,18 @@
 
 #include "tsdeactivationinterface.h"
 
+class QEvent;
+
 class TsDeactivation : public TsDeactivationInterface
 {
-
     Q_OBJECT
 
 public:
     TsDeactivation(QObject *parent = 0);
 
+protected:
+    bool eventFilter(QObject *obj, QEvent *event);
+    
 };
 
 #endif // TSDEACTIVATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/inc/tsexternalactivationwatcher.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef TSEXTERNALACTIVATIONWATCHER_H
+#define TSEXTERNALACTIVATIONWATCHER_H
+
+#include <QObject>
+    
+class TsExternalActivationWatcherPrivate;    
+    
+class TsExternalActivationWatcher : public QObject
+{
+    Q_OBJECT
+
+public:
+    TsExternalActivationWatcher(QObject *parent = 0);
+    virtual ~TsExternalActivationWatcher();
+    
+signals:
+    void activationRequested();
+
+private:
+    TsExternalActivationWatcherPrivate *d_ptr;    
+    friend class TsExternalActivationWatcherPrivate;    
+    
+};
+
+#endif // TSEXTERNALACTIVATIONWATCHER_H
--- a/taskswitcherapp/tsserviceplugin/inc/tspresentation.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/inc/tspresentation.h	Fri Apr 16 14:54:01 2010 +0300
@@ -48,4 +48,3 @@
 };
 
 #endif // TSPRESENTATION_H
- 
\ No newline at end of file
--- a/taskswitcherapp/tsserviceplugin/inc/tsrecentapplicationsmodel.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/inc/tsrecentapplicationsmodel.h	Fri Apr 16 14:54:01 2010 +0300
@@ -28,15 +28,6 @@
 class CaService;
 class CaNotifier;
 
-/**
- * @ingroup group_tsserviceprovider
- * @brief TsRecentApplicationsModel model with recent application.
- *
- * Loads recent aplications from content arsenal.
- *
- * @lib tsserviceprovider.lib
- * @since S60 ?S60_version
- */
 class TsRecentApplicationsModel : public QAbstractListModel
 {
     Q_OBJECT
--- a/taskswitcherapp/tsserviceplugin/inc/tstasksgriditem.h	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/inc/tstasksgriditem.h	Fri Apr 16 14:54:01 2010 +0300
@@ -24,11 +24,11 @@
 
 class TsTasksGridItem : public HbAbstractViewItem
 {
-
     Q_OBJECT
 
 public:
     TsTasksGridItem();
+    TsTasksGridItem(const TsTasksGridItem& item);
     ~TsTasksGridItem();
 
     HbAbstractViewItem *createItem();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/inc/win/tsexternalactivationwatcher_p.h	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef TSEXTERNALACTIVATIONWATCHERPRIVATE_H
+#define TSEXTERNALACTIVATIONWATCHERPRIVATE_H
+
+#include <QObject>
+#include <qmobilityglobal.h>
+
+QTM_BEGIN_NAMESPACE
+    class QValueSpacePublisher;
+    class QValueSpaceSubscriber;
+QTM_END_NAMESPACE
+
+QTM_USE_NAMESPACE
+    
+class TsExternalActivationWatcherPrivate : public QObject
+{
+    Q_OBJECT
+
+public:
+    TsExternalActivationWatcherPrivate(QObject *parent);
+
+private slots:
+    void checkActivationFlag();
+    
+signals:
+    void activationRequested();
+
+private:
+    QValueSpacePublisher *mPublisher;
+    QValueSpaceSubscriber *mSubscriber;
+    
+};
+
+#endif // TSEXTERNALACTIVATIONWATCHERPRIVATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/resource/tsexternalactivation.qcrml	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<repository target="RProperty" uidValue="0x2002677D">
+    <key int="0x1" ref="/TaskSwitcher/Activation"/>
+</repository>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/src/s60/tsexternalactivationwatcher_p.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* 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 "tsexternalactivationwatcher_p.h"
+#include "tsexternalactivationwatcher.h"
+
+const TUid KTaskswitcherCategory = { 0x2002677D };
+const TUint KExternalActivationKey = 0x1;
+const TInt KTaskswitcherActivateFlag = 1;
+
+/*!
+    \class TsExternalActivationWatcherPrivate
+    \ingroup group_tsserviceplugin
+    \brief Private implementation of external activation watcher.
+*/
+
+TsExternalActivationWatcherPrivate::TsExternalActivationWatcherPrivate(TsExternalActivationWatcher *parent) : CActive(CActive::EPriorityStandard), mParent(parent)
+{
+    CActiveScheduler::Add(this);
+    
+    TInt err = RProperty::Define(KTaskswitcherCategory, KExternalActivationKey, RProperty::EInt);
+    if (err == KErrNone || err == KErrAlreadyExists) {
+        err = mProperty.Attach(KTaskswitcherCategory, KExternalActivationKey);
+    }
+    
+    Q_ASSERT_X(err == KErrNone, "TsExternalActivationWatcherPrivate", qPrintable(QString("Cannot define/attach to activation watcher property %1").arg(err)));
+    
+    mProperty.Subscribe(iStatus);
+    SetActive();
+}
+
+TsExternalActivationWatcherPrivate::~TsExternalActivationWatcherPrivate()
+{
+    Cancel();
+    mProperty.Close();
+}
+
+void TsExternalActivationWatcherPrivate::ResetActivationFlag()
+{
+    TInt value(0);
+    mProperty.Set(value);
+}
+
+void TsExternalActivationWatcherPrivate::DoCancel()
+{
+    mProperty.Cancel();
+}
+
+void TsExternalActivationWatcherPrivate::RunL()
+{
+    if (iStatus.Int() != KErrCancel) {
+        
+        if (CheckActivationFlag()) {
+            ResetActivationFlag();
+            QT_TRYCATCH_LEAVING(emit mParent->activationRequested());
+        }
+        mProperty.Subscribe(iStatus);
+        SetActive();
+    }
+}
+
+bool TsExternalActivationWatcherPrivate::CheckActivationFlag()
+{
+    TInt value(0);
+    TInt result = mProperty.Get(value);
+    return (result == KErrNone && value & KTaskswitcherActivateFlag);
+}
--- a/taskswitcherapp/tsserviceplugin/src/s60/tslongpresswatcher_p.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/s60/tslongpresswatcher_p.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -26,6 +26,12 @@
 const TInt KTaskswitcherForegroundValue = KTaskswitcherBackgroundValue << 1;
 const TInt KTaskswitcherLongAppKeyPressed = KTaskswitcherForegroundValue << 1;
 
+/*!
+    \class TsLongPressWatcherPrivate
+    \ingroup group_tsserviceplugin
+    \brief Private implementation of long press app key watcher.
+*/
+
 TsLongPressWatcherPrivate::TsLongPressWatcherPrivate(TsLongPressWatcher *parent) : CActive(CActive::EPriorityStandard), mParent(parent)
 {
     CActiveScheduler::Add(this);
--- a/taskswitcherapp/tsserviceplugin/src/tsactivation.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsactivation.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -18,9 +18,21 @@
 #include "tsactivation.h"
 
 #include "tslongpresswatcher.h"
+#include "tsexternalactivationwatcher.h"
 
+/*!
+    \class TsActivation
+    \ingroup group_tsserviceplugin
+    \brief Activation service.
+    
+    Service responsible for observing all events that might show TS. When any of them
+    occurs it is emiting activation signal.
+*/
 TsActivation::TsActivation(QObject *parent) : TsActivationInterface(parent)
 {
-    TsLongPressWatcher *watcher = new TsLongPressWatcher(this);
-    connect(watcher, SIGNAL(applicationKeyLongPress()), this, SIGNAL(activated()));
+    TsLongPressWatcher *longPressWatcher = new TsLongPressWatcher(this);
+    connect(longPressWatcher, SIGNAL(applicationKeyLongPress()), this, SIGNAL(activated()));
+    
+    TsExternalActivationWatcher *externalActivationWatcher = new TsExternalActivationWatcher(this);
+    connect(externalActivationWatcher, SIGNAL(activationRequested()), this, SIGNAL(activated()));    
 }
--- a/taskswitcherapp/tsserviceplugin/src/tsclosedapplicationsfiltermodel.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsclosedapplicationsfiltermodel.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -17,6 +17,15 @@
 #include "tsclosedapplicationsfiltermodel.h"
 #include "tsdataroles.h"
 
+
+/*!
+    \class TsClosedApplicationsFilterModel
+    \ingroup group_tsserviceplugin
+    \brief Filtering model to hide closed apps.
+	
+	When app is closed from Task Switcher it is hidden from it and will be presented when TS is started once more.
+*/
+
 /*!
     Constructor
     \param pointer to parent object
--- a/taskswitcherapp/tsserviceplugin/src/tsdeactivation.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsdeactivation.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -17,6 +17,26 @@
 
 #include "tsdeactivation.h"
 
+#include <QCoreApplication>
+#include <QEvent>
+
+/*!
+    \class TsDeactivation
+    \ingroup group_tsserviceplugin
+    \brief Deactivation service.
+	
+	Service responsible for observation of all events that might hide TS. When any of 
+	them occurs it is emiting signal.
+*/
 TsDeactivation::TsDeactivation(QObject *parent) : TsDeactivationInterface(parent)
 {
+    qApp->installEventFilter(this);
 }
+
+bool TsDeactivation::eventFilter(QObject *obj, QEvent *event)
+{
+    if (event->type() == QEvent::ApplicationDeactivate) {
+        emit deactivated();
+    } 
+    return TsDeactivationInterface::eventFilter(obj, event);  
+}
--- a/taskswitcherapp/tsserviceplugin/src/tsdocumentloader.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsdocumentloader.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -19,6 +19,14 @@
 #include "tstasksgrid.h"
 #include "tstasksgriditem.h"
 
+/*!
+    \class TsDocumentLoader
+    \ingroup group_tsserviceplugin
+    \brief Document loader.
+	
+	TS implementation of document loader. It is creating TS objects used in UI
+*/
+
 QObject *TsDocumentLoader::createObject(const QString &type, const QString &name)
 {
     if (type == TsTasksGrid::staticMetaObject.className()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/src/tsexternalactivationwatcher.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "tsexternalactivationwatcher.h"
+#include "tsexternalactivationwatcher_p.h"
+
+TsExternalActivationWatcher::TsExternalActivationWatcher(QObject *parent) : QObject(parent)
+{
+    d_ptr = new TsExternalActivationWatcherPrivate(this);
+}
+
+TsExternalActivationWatcher::~TsExternalActivationWatcher()
+{
+    delete d_ptr;
+}
--- a/taskswitcherapp/tsserviceplugin/src/tsitemprovider.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsitemprovider.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -26,6 +26,15 @@
 #include "tsclosedapplicationsfiltermodel.h"
 #include "tsdataroles.h"
 
+/*!
+    \class TsItemProvider
+    \ingroup group_tsserviceplugin
+    \brief Returns items that should be presented in TS.
+	
+	Service providing information about items that should be presented in TS. It also allows to
+	start some action on it (open/close).
+*/
+
 TsItemProvider::TsItemProvider(QObject *parent) : TsItemProviderInterface(parent), mService(CaService::instance())
 {
     TsRecentApplicationsModel *recentAppModel = new TsRecentApplicationsModel(this);
@@ -63,8 +72,18 @@
 
 void TsItemProvider::closeAllApplications()
 {
+    QList<int> closableList;
     for (int row(0); row < mModel->rowCount(); ++row) {
-        closeApplication(mModel->index(row, 0));
+        if (mModel->index(row, 0).data(TsDataRoles::Closable).toBool()) {
+            QVariant entryId = mModel->index(row, 0).data(TsDataRoles::EntryId);
+            if (entryId.isValid()) {
+                closableList.append(entryId.toInt());
+            }
+        }
+    }
+    foreach (int entryId, closableList) {
+        mModel->addId(entryId);
+        mService->executeCommand(entryId, QString("close"));        
     }
 }
 
--- a/taskswitcherapp/tsserviceplugin/src/tslongpresswatcher.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tslongpresswatcher.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -18,6 +18,11 @@
 #include "tslongpresswatcher.h"
 #include "tslongpresswatcher_p.h"
 
+/*!
+    \class TsLongPressWatcher
+    \ingroup group_tsserviceplugin
+    \brief Class watching app key events.
+*/
 TsLongPressWatcher::TsLongPressWatcher(QObject *parent) : QObject(parent)
 {
     d_ptr = new TsLongPressWatcherPrivate(this);
--- a/taskswitcherapp/tsserviceplugin/src/tspresentation.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tspresentation.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -26,10 +26,15 @@
 
 // FIXME: workaround for Orbit bug: not moving to foreground after QWidget::activateWindow();
 #ifdef Q_OS_SYMBIAN
-#include <APGTASK.H>
+#include <apgtask.h>
 #include <eikenv.h>
 #endif    
 
+/*!
+    \class TsPresentation
+    \ingroup group_tsserviceplugin
+    \brief Class providing UI for presenting TS data.
+*/
 TsPresentation::TsPresentation(QObject *parent) : TsPresentationInterface(parent), mDialog(NULL), mGrid(NULL)
 {
     HbMainWindow *mainWindow = HbInstance::instance()->allMainWindows().first();
@@ -92,12 +97,9 @@
     // FIXME: workaround for Orbit bug: not moving to foreground after QWidget::activateWindow();
     TApaTaskList taskList(CEikonEnv::Static()->WsSession());
     TApaTask task = taskList.FindApp(RProcess().Type()[2]);
-    if (task.Exists()) {
-        task.BringToForeground();
-    } else {
-        qWarning("Can't bring TaskSwitcher to foreground: task not found");
-    }    
-#endif    
+    Q_ASSERT_X(task.Exists(), "Bringing task switcher to foreground", "Application couldn't find task with its own UID");
+    task.BringToForeground();
+#endif
    
     mDialog->show();
 }
--- a/taskswitcherapp/tsserviceplugin/src/tsrecentapplicationsmodel.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsrecentapplicationsmodel.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -25,6 +25,12 @@
 #include "tsdataroles.h"
 
 /*!
+    \class TsRecentApplicationsModel
+    \ingroup group_tsserviceplugin
+    \brief Model storing recent application.
+*/
+
+/*!
     Constructor
     \param query used to create model
     \param pointer to parent object
--- a/taskswitcherapp/tsserviceplugin/src/tsserviceplugin.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tsserviceplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -26,6 +26,16 @@
 #include "tsdeactivation.h"
 #include "tspresentation.h"
 
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+
+/*!
+    \class TsServicePlugin
+    \ingroup group_tsserviceplugin
+    \brief Plugin implementation.
+*/
+
 QObject *TsServicePlugin::createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session)
 {
     Q_UNUSED(context);
@@ -45,3 +55,7 @@
 }
 
 Q_EXPORT_PLUGIN2(tsserviceplugin, TsServicePlugin)
+
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
--- a/taskswitcherapp/tsserviceplugin/src/tstaskpopuphandler.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tstaskpopuphandler.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -21,6 +21,12 @@
 
 #include "tsdataroles.h"
 
+/*!
+    \class TsTaskPopupHandler
+    \ingroup group_tsserviceplugin
+    \brief Create popup with options for TS app.
+*/
+
 TsTaskPopupHandler::TsTaskPopupHandler(QObject *parent) : QObject(parent)
 {
 }
--- a/taskswitcherapp/tsserviceplugin/src/tstasksgriditem.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/src/tstasksgriditem.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -22,8 +22,19 @@
 #include <hbanchorlayout.h>
 #include "tsdataroles.h"
 
+/*!
+    \class TsTasksGridItem
+    \ingroup group_tsserviceplugin
+    \brief Item that should be presented in grid.
+*/
+
+
 TsTasksGridItem::TsTasksGridItem() : HbAbstractViewItem()
 {
+}
+
+TsTasksGridItem::TsTasksGridItem(const TsTasksGridItem &item) : HbAbstractViewItem(item)
+{
     // add screenshot
     mScreenshotLabel = new HbLabel();
     mScreenshotLabel->setAlignment(Qt::AlignHCenter);
@@ -67,7 +78,7 @@
 
 HbAbstractViewItem *TsTasksGridItem::createItem()
 {
-    TsTasksGridItem *newItem = new TsTasksGridItem();
+    TsTasksGridItem *newItem = new TsTasksGridItem(*this);
     connect(newItem, SIGNAL(deleteClicked(QModelIndex)), itemView(), SIGNAL(deleteButtonClicked(QModelIndex)));
     return newItem;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcherapp/tsserviceplugin/src/win/tsexternalactivationwatcher_p.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "tsexternalactivationwatcher_p.h"
+
+#include <qvaluespacesubscriber.h>
+#include <qvaluespacepublisher.h>
+
+QTM_USE_NAMESPACE
+
+TsExternalActivationWatcherPrivate::TsExternalActivationWatcherPrivate(QObject *parent) : QObject()
+{
+    mSubscriber = new QValueSpaceSubscriber("/TaskSwitcher/Activation", this);
+    mPublisher = new QValueSpacePublisher("/TaskSwitcher", this);
+    connect(mSubscriber, SIGNAL(contentsChanged()), this, SLOT(checkActivationFlag()));
+    connect(this, SIGNAL(activationRequested()), parent, SIGNAL(activationRequested()));
+}
+
+void TsExternalActivationWatcherPrivate::checkActivationFlag()
+{
+    if (mSubscriber->value().isValid()) {
+        mPublisher->resetValue("Activation");
+        mPublisher->sync();
+        emit activationRequested();
+    }
+}
Binary file taskswitcherapp/tsserviceplugin/tsrc/t_tsitemprovider/data/castorage.db has changed
Binary file taskswitcherapp/tsserviceplugin/tsrc/t_tsitemprovider/data/castoragedb has changed
--- a/taskswitcherapp/tsserviceplugin/tsserviceplugin.pro	Fri Mar 19 09:27:44 2010 +0200
+++ b/taskswitcherapp/tsserviceplugin/tsserviceplugin.pro	Fri Apr 16 14:54:01 2010 +0300
@@ -15,10 +15,12 @@
 #
 
 TEMPLATE = lib
-TARGET = tsserviceplugin
+CONFIG += plugin hb mobility
+MOBILITY = serviceframework 
 
-CONFIG += plugin hb mobility
-MOBILITY = serviceframework
+win32 {
+    MOBILITY += publishsubscribe
+}
 
 INCLUDEPATH += . inc
 
@@ -27,6 +29,7 @@
             inc/tsactivationinterface.h \
             inc/tsactivation.h \
             inc/tslongpresswatcher.h \
+            inc/tsexternalactivationwatcher.h \
             inc/tsdeactivationinterface.h \
             inc/tsdeactivation.h \
             inc/tsitemproviderinterface.h \
@@ -43,6 +46,7 @@
 SOURCES +=  src/tsserviceplugin.cpp \
             src/tsactivation.cpp \
             src/tslongpresswatcher.cpp \
+            src/tsexternalactivationwatcher.cpp \
             src/tsdeactivation.cpp \
             src/tsitemprovider.cpp \
             src/tsclosedapplicationsfiltermodel.cpp \
@@ -60,8 +64,6 @@
 
 symbian {
     load(data_caging_paths) 
-    TARGET.EPOCALLOWDLLDATA = 1
-    TARGET.CAPABILITY = ALL -TCB
 
     plugin.sources = tsserviceplugin.dll
     plugin.path = $$QT_PLUGINS_BASE_DIR     
@@ -70,23 +72,37 @@
     translation.sources = ./*.qm
     translation.path = $$QT_PLUGINS_BASE_DIR/../translations
 
-    DEPLOYMENT += plugin translation
-}
-
-symbian: {
-    INCLUDEPATH += inc/s60
-    HEADERS += inc/s60/tslongpresswatcher_p.h
-    SOURCES += src/s60/tslongpresswatcher_p.cpp
-    LIBS += -lcone -lapgrfx -lws32
+    # another ugly hack 
+    crml.sources = ./resource/*.qcrml
+    crml.path = $$QT_PLUGINS_BASE_DIR/../crml
+    
+    DEPLOYMENT += plugin translation crml
 }
 
-win32: {
+symbian {
+    INCLUDEPATH += inc/s60
+    HEADERS +=  inc/s60/tslongpresswatcher_p.h \
+                inc/s60/tsexternalactivationwatcher_p.h \
+                
+    SOURCES +=  src/s60/tslongpresswatcher_p.cpp \
+                src/s60/tsexternalactivationwatcher_p.cpp \
+                
+    LIBS += -lcone \
+            -lapgrfx \
+            -lws32 \
+
+}
+
+win32 {
     INCLUDEPATH +=  inc/win
 
-    HEADERS += inc/win/tslongpresswatcher_p.h
-    SOURCES += src/win/tslongpresswatcher_p.cpp                    
-    LIBS += -lUser32
+    HEADERS +=  inc/win/tslongpresswatcher_p.h \
+                inc/win/tsexternalactivationwatcher_p.h \
     
-    INCLUDEPATH += $$PWD/../../../../homescreensrv/homescreensrv_plat/contentstorage_api
-    LIBS += -L$$PWD/../../../../bin/debug    
+    SOURCES +=  src/win/tslongpresswatcher_p.cpp \
+                src/win/tsexternalactivationwatcher_p.cpp \
+                
+    LIBS += -lUser32
 }
+
+include(../common.pri)